You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/02/15 09:59:02 UTC
[camel] 05/05: CAMEL-17647: camel-core - Properties component should support pluggable functions
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch pf
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6f5135bf6b6137597295b15343929988c0266e09
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Feb 15 10:55:02 2022 +0100
CAMEL-17647: camel-core - Properties component should support pluggable functions
---
.../ROOT/pages/using-propertyplaceholder.adoc | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc b/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc
index 3f79a92..2ffee01 100644
--- a/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc
+++ b/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc
@@ -558,6 +558,34 @@ PropertiesComponent pc = context.getPropertiesComponent();
pc.addFunction(new MyBeerFunction());
----
+==== Pluggable custom properties functions
+
+If you want custom properties functions to be easier to use then we recommend making them pluggable.
+For example the beer function from above, can be made pluggable simply by adding the `PropertiesFunction` annotations as shown:
+
+[source,java]
+----
+@org.apache.camel.spi.annotations.PropertiesFunction("beer")
+public class MyBeerFunction implements PropertiesFunction {
+
+ @Override
+ public String getName() {
+ return "beer";
+ }
+
+ @Override
+ public String apply(String remainder) {
+ return "mock:" + remainder.toLowerCase();
+ }
+}
+----
+
+Then by having the `camel-component-maven-plugin` as part of building the component will
+then ensure that this custom properties has necessary source code generated that makes Camel
+able to automatically discover the custom function.
+
+TIP: For an example see the `camel-base64` component.
+
== Using third party property sources
The properties component allows to plugin 3rd party sources to load and lookup properties via the `PropertySource`