This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new efc011e Polish and cleanup documentation
efc011e is described below
commit efc011e8861f269519f873039076c12c723de8f1
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Aug 18 20:04:19 2021 +0200
Polish and cleanup documentation
---
.../src/main/docs/properties-component.adoc | 222 +--------------------
.../modules/ROOT/pages/properties-component.adoc | 222 +--------------------
.../ROOT/pages/using-propertyplaceholder.adoc | 114 ++++-------
3 files changed, 38 insertions(+), 520 deletions(-)
diff --git a/core/camel-base/src/main/docs/properties-component.adoc
b/core/camel-base/src/main/docs/properties-component.adoc
index c3c2e91..530a3bf 100644
--- a/core/camel-base/src/main/docs/properties-component.adoc
+++ b/core/camel-base/src/main/docs/properties-component.adoc
@@ -16,7 +16,7 @@ However, for historical reasons it was named
`PropertiesComponent` and this name
IMPORTANT: See the
xref:latest@manual:ROOT:using-propertyplaceholder.adoc[Property Placeholder]
documentation for general information on using property placeholders in Camel.
The properties component requires to load the properties (key=value pairs)
from an external source such as `.properties` files.
-The component is pluggable and you can configure to use other sources or write
a custom implementation (for example to load from a database).
+The component is pluggable, and you can configure to use other sources or
write a custom implementation (for example to load from a database).
== Defining location of properties files
@@ -120,226 +120,6 @@ For fine grained configuration of the location, then this
can be done as follows
</camelContext>
----
-== Additional property placeholder supported in Spring XML
-
-The property placeholders is also supported in many of the Camel Spring XML
tags such as `<package>, <packageScan>, <contextScan>, <jmxAgent>, <endpoint>,
<routeBuilder>, and the others.
-
-The example below has property placeholder in the `<jmxAgent>` tag:
-
-[source,xml]
-----
-<camelContext xmlns="http://camel.apache.org/schema/spring">
- <propertyPlaceholder id="properties"
location="org/apache/camel/spring/jmx.properties"/>
- <!-- we can use property placeholders when we define the JMX agent -->
- <jmxAgent id="agent" disabled="{{myjmx.disabled}}"
- usePlatformMBeanServer="{{myjmx.usePlatform}}"
- statisticsLevel="RoutesOnly" useHostIPAddress="true"/>
- <route id="foo" autoStartup="false">
- <from uri="seda:start"/>
- <to uri="mock:result"/>
- </route>
-</camelContext>
-----
-
-You can also define property placeholders in the various attributes on the
`<camelContext>` tag such as `trace` as shown here:
-
-[source,xml]
-----
-<camelContext trace="{{foo.trace}}"
xmlns="http://camel.apache.org/schema/spring">
- <propertyPlaceholder id="properties"
location="org/apache/camel/spring/processor/myprop.properties"/>
- <template id="camelTemplate" defaultEndpoint="{{foo.cool}}"/>
- <route>
- <from uri="direct:start"/>
- <setHeader name="{{foo.header}}">
- <simple>${in.body} World!</simple>
- </setHeader>
- <to uri="mock:result"/>
- </route>
-</camelContext>
-----
-
-== Using JVM system properties or Environment variables as override or
fallback values
-
-The properties components supports using JVM system properties and also OS
environment variables as values which can either be used as override or
fallback values.
-
-The default mode is that both of them are in override mode, and they are check
in the following order:
-
-1. OS environment variable (override mode)
-2. JVM system property (override mode)
-3. Property files and other locations
-4. OS environment variable (fallback mode)
-5. JVM system property (fallback mode)
-
-The check stops at first found property value for the key.
-
-You can control these modes using the `systemPropertiesMode` and
`environmentVariableMode`
-options on the properties component.
-
-
-== Using out of the box functions
-
-The xref:properties-component.adoc[Properties] component includes the
following functions out of the box:
-
-* `env` - A function to lookup the property from OS environment variables
-* `sys` - A function to lookup the property from Java JVM system properties
-* `service` - A function to lookup the property from OS environment variables
using the service naming idiom
-* `service.name` - A function to lookup the property from OS environment
variables using the service naming idiom returning the hostname part only
-* `service.port` - A function to lookup the property from OS environment
variables using the service naming idiom returning the port part only
-
-As you can see these functions is intended to make it easy to lookup values
from the environment.
-As they are provided out of the box, they can easily be used as shown below:
-
-[source,xml]
-----
- <camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="{{env:SOMENAME}}"/>
- <to uri="{{sys:MyJvmPropertyName}}"/>
- </route>
- </camelContext>
-----
-
-You can use default values as well, so if the property does not exist, you can
define a default value as shown below, where the default value is a `log:foo`
and `log:bar` value.
-
-[source,xml]
-----
- <camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="{{env:SOMENAME:log:foo}}"/>
- <to uri="{{sys:MyJvmPropertyName:log:bar}}"/>
- </route>
- </camelContext>
-----
-
-The service function is for looking up a service which is defined using OS
environment variables using the service naming idiom, to refer to a service
location using `hostname : port`
-
-* __NAME__**_SERVICE_HOST**
-* __NAME__**_SERVICE_PORT**
-
-in other words the service uses `_SERVICE_HOST` and `_SERVICE_PORT` as prefix.
-So if the service is named FOO, then the OS environment variables should be
set as
-
-[source]
-----
-export $FOO_SERVICE_HOST=myserver
-export $FOO_SERVICE_PORT=8888
-----
-
-For example if the FOO service a remote HTTP service, then we can refer to the
service in the Camel endpoint uri, and use the HTTP component to make the HTTP
call:
-
-[source,xml]
-----
-<camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="http://{`{service:FOO}`}/myapp"/>
- </route>
-</camelContext>
-----
-
-And we can use default values if the service has not been defined, for example
to call a service on localhost, maybe for unit testing etc
-
-[source,xml]
-----
-<camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="http://{`{service:FOO:localhost:8080}`}/myapp"/>
- </route>
-</camelContext>
-----
-
-== Using custom functions (advanced)
-
-The xref:properties-component.adoc[Properties] component allow to plugin 3rd
party functions which can be used during parsing of the property placeholders.
-These functions are then able to do custom logic to resolve the placeholders,
such as looking up in databases, do custom computations, or whatnot.
-The name of the function becomes the prefix used in the placeholder.
-This is best illustrated in the example code below
-
-[source,xml]
-----
-<beans>
- <bean id="beerFunction" class="MyBeerFunction"/>
-
- <camelContext>
- <propertyPlaceholder id="properties">
- <propertiesFunction ref="beerFunction"/>
- </propertyPlaceholder>
-
- <route>
- <from uri="direct:start"/>
- <to uri="{{beer:FOO}}"/>
- <to uri="{{beer:BAR}}"/>
- </route>
- </camelContext>
-</beans>
-----
-
-Here we have a Camel XML route where we have defined the
-`<propertyPlaceholder>` to use a custom function, which we refer to be the
bean id - eg the `beerFunction`.
-As the beer function uses `"beer"` as its name, then the placeholder syntax
can trigger the beer function by starting with `beer:value`.
-
-The implementation of the function is only two methods as shown below:
-
-[source,java]
-----
-public static final class MyBeerFunction implements PropertiesFunction {
-
- @Override
- public String getName() {
- return "beer";
- }
-
- @Override
- public String apply(String remainder) {
- return "mock:" + remainder.toLowerCase();
- }
-}
-----
-
-The function must implement the `org.apache.camel.spi.PropertiesFunction`
interface.
-The method `getName` is the name of the function, eg beer.
-And the `apply` method is where we implement the custom logic to do.
-As the sample code is from an unit test, it just returns a value to refer to a
mock endpoint.
-
-To register a custom function from Java code is as shown below:
-
-[source,java]
-----
-PropertiesComponent pc = context.getPropertiesComponent();
-pc.addFunction(new MyBeerFunction());
-----
-
-== PropertySource
-
-The regular `PropertySource` will lookup the property on-demand, for example
to lookup values from a backend source such as a database or HashiCorp Vault
etc.
-
-=== LoadablePropertySource
-
-A `PropertySource` can define that it supports loading all its properties from
the source at once, for example from file system.
-This allows Camel properties component to load these properties at once during
startup.
-
-=== Using 3rd-party PropertySource
-
-The properties component allows to plugin 3rd party sources to load and lookup
properties via the `PropertySource`
-API from camel-api.
-
-For example the `camel-microprofile-config` component is implemented using
this.
-The 3rd-party `PropertySource` can automatic be discovered from classpath when
Camel is starting up.
-This is done by include the file
`META-INF/services/org/apache/camel/property-source-factory` file which refers
to the fully qualified class name of the `PropertySource` implementation.
-
-See xref:components:others:microprofile-config.adoc[MicroProfile Config]
component as an example.
-
-You can also register 3rd-party property sources via Java API:
-
-[source,java]
-----
-PropertiesComponent pc = context.getPropertiesComponent();
-pc.addPropertySource(myPropertySource);
-----
-
== Spring Boot Auto-Configuration
diff --git a/docs/components/modules/ROOT/pages/properties-component.adoc
b/docs/components/modules/ROOT/pages/properties-component.adoc
index 4da1bfc..e52792d 100644
--- a/docs/components/modules/ROOT/pages/properties-component.adoc
+++ b/docs/components/modules/ROOT/pages/properties-component.adoc
@@ -18,7 +18,7 @@ However, for historical reasons it was named
`PropertiesComponent` and this name
IMPORTANT: See the
xref:latest@manual:ROOT:using-propertyplaceholder.adoc[Property Placeholder]
documentation for general information on using property placeholders in Camel.
The properties component requires to load the properties (key=value pairs)
from an external source such as `.properties` files.
-The component is pluggable and you can configure to use other sources or write
a custom implementation (for example to load from a database).
+The component is pluggable, and you can configure to use other sources or
write a custom implementation (for example to load from a database).
== Defining location of properties files
@@ -122,226 +122,6 @@ For fine grained configuration of the location, then this
can be done as follows
</camelContext>
----
-== Additional property placeholder supported in Spring XML
-
-The property placeholders is also supported in many of the Camel Spring XML
tags such as `<package>, <packageScan>, <contextScan>, <jmxAgent>, <endpoint>,
<routeBuilder>, and the others.
-
-The example below has property placeholder in the `<jmxAgent>` tag:
-
-[source,xml]
-----
-<camelContext xmlns="http://camel.apache.org/schema/spring">
- <propertyPlaceholder id="properties"
location="org/apache/camel/spring/jmx.properties"/>
- <!-- we can use property placeholders when we define the JMX agent -->
- <jmxAgent id="agent" disabled="{{myjmx.disabled}}"
- usePlatformMBeanServer="{{myjmx.usePlatform}}"
- statisticsLevel="RoutesOnly" useHostIPAddress="true"/>
- <route id="foo" autoStartup="false">
- <from uri="seda:start"/>
- <to uri="mock:result"/>
- </route>
-</camelContext>
-----
-
-You can also define property placeholders in the various attributes on the
`<camelContext>` tag such as `trace` as shown here:
-
-[source,xml]
-----
-<camelContext trace="{{foo.trace}}"
xmlns="http://camel.apache.org/schema/spring">
- <propertyPlaceholder id="properties"
location="org/apache/camel/spring/processor/myprop.properties"/>
- <template id="camelTemplate" defaultEndpoint="{{foo.cool}}"/>
- <route>
- <from uri="direct:start"/>
- <setHeader name="{{foo.header}}">
- <simple>${in.body} World!</simple>
- </setHeader>
- <to uri="mock:result"/>
- </route>
-</camelContext>
-----
-
-== Using JVM system properties or Environment variables as override or
fallback values
-
-The properties components supports using JVM system properties and also OS
environment variables as values which can either be used as override or
fallback values.
-
-The default mode is that both of them are in override mode, and they are check
in the following order:
-
-1. OS environment variable (override mode)
-2. JVM system property (override mode)
-3. Property files and other locations
-4. OS environment variable (fallback mode)
-5. JVM system property (fallback mode)
-
-The check stops at first found property value for the key.
-
-You can control these modes using the `systemPropertiesMode` and
`environmentVariableMode`
-options on the properties component.
-
-
-== Using out of the box functions
-
-The xref:properties-component.adoc[Properties] component includes the
following functions out of the box:
-
-* `env` - A function to lookup the property from OS environment variables
-* `sys` - A function to lookup the property from Java JVM system properties
-* `service` - A function to lookup the property from OS environment variables
using the service naming idiom
-* `service.name` - A function to lookup the property from OS environment
variables using the service naming idiom returning the hostname part only
-* `service.port` - A function to lookup the property from OS environment
variables using the service naming idiom returning the port part only
-
-As you can see these functions is intended to make it easy to lookup values
from the environment.
-As they are provided out of the box, they can easily be used as shown below:
-
-[source,xml]
-----
- <camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="{{env:SOMENAME}}"/>
- <to uri="{{sys:MyJvmPropertyName}}"/>
- </route>
- </camelContext>
-----
-
-You can use default values as well, so if the property does not exist, you can
define a default value as shown below, where the default value is a `log:foo`
and `log:bar` value.
-
-[source,xml]
-----
- <camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="{{env:SOMENAME:log:foo}}"/>
- <to uri="{{sys:MyJvmPropertyName:log:bar}}"/>
- </route>
- </camelContext>
-----
-
-The service function is for looking up a service which is defined using OS
environment variables using the service naming idiom, to refer to a service
location using `hostname : port`
-
-* __NAME__**_SERVICE_HOST**
-* __NAME__**_SERVICE_PORT**
-
-in other words the service uses `_SERVICE_HOST` and `_SERVICE_PORT` as prefix.
-So if the service is named FOO, then the OS environment variables should be
set as
-
-[source]
-----
-export $FOO_SERVICE_HOST=myserver
-export $FOO_SERVICE_PORT=8888
-----
-
-For example if the FOO service a remote HTTP service, then we can refer to the
service in the Camel endpoint uri, and use the HTTP component to make the HTTP
call:
-
-[source,xml]
-----
-<camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="http://{`{service:FOO}`}/myapp"/>
- </route>
-</camelContext>
-----
-
-And we can use default values if the service has not been defined, for example
to call a service on localhost, maybe for unit testing etc
-
-[source,xml]
-----
-<camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="http://{`{service:FOO:localhost:8080}`}/myapp"/>
- </route>
-</camelContext>
-----
-
-== Using custom functions (advanced)
-
-The xref:properties-component.adoc[Properties] component allow to plugin 3rd
party functions which can be used during parsing of the property placeholders.
-These functions are then able to do custom logic to resolve the placeholders,
such as looking up in databases, do custom computations, or whatnot.
-The name of the function becomes the prefix used in the placeholder.
-This is best illustrated in the example code below
-
-[source,xml]
-----
-<beans>
- <bean id="beerFunction" class="MyBeerFunction"/>
-
- <camelContext>
- <propertyPlaceholder id="properties">
- <propertiesFunction ref="beerFunction"/>
- </propertyPlaceholder>
-
- <route>
- <from uri="direct:start"/>
- <to uri="{{beer:FOO}}"/>
- <to uri="{{beer:BAR}}"/>
- </route>
- </camelContext>
-</beans>
-----
-
-Here we have a Camel XML route where we have defined the
-`<propertyPlaceholder>` to use a custom function, which we refer to be the
bean id - eg the `beerFunction`.
-As the beer function uses `"beer"` as its name, then the placeholder syntax
can trigger the beer function by starting with `beer:value`.
-
-The implementation of the function is only two methods as shown below:
-
-[source,java]
-----
-public static final class MyBeerFunction implements PropertiesFunction {
-
- @Override
- public String getName() {
- return "beer";
- }
-
- @Override
- public String apply(String remainder) {
- return "mock:" + remainder.toLowerCase();
- }
-}
-----
-
-The function must implement the `org.apache.camel.spi.PropertiesFunction`
interface.
-The method `getName` is the name of the function, eg beer.
-And the `apply` method is where we implement the custom logic to do.
-As the sample code is from an unit test, it just returns a value to refer to a
mock endpoint.
-
-To register a custom function from Java code is as shown below:
-
-[source,java]
-----
-PropertiesComponent pc = context.getPropertiesComponent();
-pc.addFunction(new MyBeerFunction());
-----
-
-== PropertySource
-
-The regular `PropertySource` will lookup the property on-demand, for example
to lookup values from a backend source such as a database or HashiCorp Vault
etc.
-
-=== LoadablePropertySource
-
-A `PropertySource` can define that it supports loading all its properties from
the source at once, for example from file system.
-This allows Camel properties component to load these properties at once during
startup.
-
-=== Using 3rd-party PropertySource
-
-The properties component allows to plugin 3rd party sources to load and lookup
properties via the `PropertySource`
-API from camel-api.
-
-For example the `camel-microprofile-config` component is implemented using
this.
-The 3rd-party `PropertySource` can automatic be discovered from classpath when
Camel is starting up.
-This is done by include the file
`META-INF/services/org/apache/camel/property-source-factory` file which refers
to the fully qualified class name of the `PropertySource` implementation.
-
-See xref:components:others:microprofile-config.adoc[MicroProfile Config]
component as an example.
-
-You can also register 3rd-party property sources via Java API:
-
-[source,java]
-----
-PropertiesComponent pc = context.getPropertiesComponent();
-pc.addPropertySource(myPropertySource);
-----
-
== Spring Boot Auto-Configuration
diff --git a/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc
b/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc
index 30b35c9..4310936 100644
--- a/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc
+++ b/docs/user-manual/modules/ROOT/pages/using-propertyplaceholder.adoc
@@ -101,9 +101,9 @@ In the example above then the FTP route or the JMS route
should only be started.
We can do this be negating the `autoStartup` in the JMS route, by using
`!integration.ftpEnabled` as the key.
-== Example using property placeholders
+== Using property placeholders
-When using property placeholders in the endpoint URIs you should use this with
the syntax `{{key}}` as shown in this example:
+When using property placeholders in the endpoint xref:uris.adoc[URIs] you
should use this with the syntax `{{key}}` as shown in this example:
[source,properties]
----
@@ -226,45 +226,6 @@ This can also be done when using
xref:consumertemplate.adoc[ConsumerTemplate], s
Object body = template.receiveBody("{{cool.start}}");
----
-== Using property placeholders with Simple language
-
-The xref:components:languages:simple-language.adoc[Simple] language now also
support using property
-placeholders, for example in the route below:
-
-[source,properties]
-----
-cheese.quote = Camel rocks
-----
-
-And in the route you can use the placeholder with the usual syntax `{{key}}`
as shown:
-
-[source,java]
-----
-from("direct:start")
- .transform().simple("Hi ${body} do you think {{cheese.quote}}?");
-----
-
-What happens is that Camel will resolve the placeholder during initialization
of the route,
-so the route becomes:
-
-[source,java]
-----
-from("direct:start")
- .transform().simple("Hi ${body} do you think Camel rocks?");
-----
-
-So the simple language would not have any property placeholders anymore.
-This is the most common way.
-
-However, if the placeholder must be resolved by simple language itself,
-then you can use its `${properties}` function:
-
-[source,java]
-----
-from("direct:start")
- .transform().simple("Hi ${body} do you think ${properties:cheese.quote}?");
-----
-
== Resolving property placeholders from Java code
If you need to resolve property placeholder(s) from some Java code, then Camel
has two APIs for this:
@@ -434,7 +395,7 @@ Notice how the hello bean is using pure Spring property
placeholders using
the `${}` notation. And in the Camel routes we use the Camel
placeholder notation with `{{key}}`.
-== Using out of the box functions
+== Using property placeholder functions
The xref:components::properties-component.adoc[Properties] component includes
the following functions out of the box:
@@ -444,31 +405,30 @@ The
xref:components::properties-component.adoc[Properties] component includes th
* `service.name` - A function to lookup the property from OS environment
variables using the service naming idiom returning the hostname part only
* `service.port` - A function to lookup the property from OS environment
variables using the service naming idiom returning the port part only
-As you can see these functions is intended to make it easy to lookup values
from the environment.
-As they are provided out of the box, they can easily be used as shown below:
+These functions are intended to make it easy to lookup values from the
environment, as shown in the example below:
[source,xml]
----
- <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+<camelContext>
<route>
- <from uri="direct:start"/>
- <to uri="{{env:SOMENAME}}"/>
- <to uri="{{sys:MyJvmPropertyName}}"/>
+ <from uri="direct:start"/>
+ <to uri="{{env:SOMENAME}}"/>
+ <to uri="{{sys:MyJvmPropertyName}}"/>
</route>
- </camelContext>
+</camelContext>
----
You can use default values as well, so if the property does not exist, you can
define a default value as shown below, where the default value is a `log:foo`
and `log:bar` value.
[source,xml]
----
- <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+<camelContext>
<route>
- <from uri="direct:start"/>
- <to uri="{{env:SOMENAME:log:foo}}"/>
- <to uri="{{sys:MyJvmPropertyName:log:bar}}"/>
+ <from uri="direct:start"/>
+ <to uri="{{env:SOMENAME:log:foo}}"/>
+ <to uri="{{sys:MyJvmPropertyName:log:bar}}"/>
</route>
- </camelContext>
+</camelContext>
----
The service function is for looking up a service which is defined using OS
environment variables using the service naming idiom, to refer to a service
location using `hostname : port`
@@ -479,7 +439,7 @@ The service function is for looking up a service which is
defined using OS envir
in other words the service uses `_SERVICE_HOST` and `_SERVICE_PORT` as prefix.
So if the service is named FOO, then the OS environment variables should be
set as
-[source]
+[source,bash]
----
export $FOO_SERVICE_HOST=myserver
export $FOO_SERVICE_PORT=8888
@@ -489,33 +449,33 @@ For example if the FOO service a remote HTTP service,
then we can refer to the s
[source,xml]
----
-<camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
- <from uri="direct:start"/>
- <to uri="http://{`{service:FOO}`}/myapp"/>
- </route>
+<camelContext>
+ <route>
+ <from uri="direct:start"/>
+ <to uri="http://{{service:FOO}}/myapp"/>
+ </route>
</camelContext>
----
-And we can use default values if the service has not been defined, for example
to call a service on localhost, maybe for unit testing etc
+And we can use default values if the service has not been defined, for example
to call a service on localhost, maybe for unit testing.
[source,xml]
----
-<camelContext xmlns="http://camel.apache.org/schema/blueprint">
- <route>
+<camelContext>
+<route>
<from uri="direct:start"/>
- <to uri="http://{`{service:FOO:localhost:8080}`}/myapp"/>
- </route>
+ <to uri="http://{{service:FOO:localhost:8080}}/myapp"/>
+</route>
</camelContext>
----
-== Using custom functions (advanced)
+=== Using custom property placeholder functions
The xref:components::properties-component.adoc[Properties] component allow to
plugin 3rd party functions which can be used during parsing of the property
placeholders.
These functions are then able to do custom logic to resolve the placeholders,
such as looking up in databases, do custom computations, or whatnot.
The name of the function becomes the prefix used in the placeholder.
-This is best illustrated in the example code below
+This is best illustrated in the example code below with Spring XML files:
[source,xml]
----
@@ -536,15 +496,15 @@ This is best illustrated in the example code below
</beans>
----
-Here we have a Camel XML route where we have defined the
-`<propertyPlaceholder>` to use a custom function, which we refer to be the
bean id - eg the `beerFunction`.
+Here we have a Camel Spring XML route where we have defined the
+`<propertyPlaceholder>` to use a custom function, which we refer to be the
bean id (`beerFunction`).
As the beer function uses `"beer"` as its name, then the placeholder syntax
can trigger the beer function by starting with `beer:value`.
The implementation of the function is only two methods as shown below:
[source,java]
----
-public static final class MyBeerFunction implements PropertiesFunction {
+public class MyBeerFunction implements PropertiesFunction {
@Override
public String getName() {
@@ -559,9 +519,9 @@ public static final class MyBeerFunction implements
PropertiesFunction {
----
The function must implement the `org.apache.camel.spi.PropertiesFunction`
interface.
-The method `getName` is the name of the function, eg beer.
+The method `getName` is the name of the function (beer).
And the `apply` method is where we implement the custom logic to do.
-As the sample code is from an unit test, it just returns a value to refer to a
mock endpoint.
+As the sample code is from a unit test, it just returns a value to refer to a
mock endpoint.
To register a custom function from Java code is as shown below:
@@ -571,7 +531,10 @@ PropertiesComponent pc = context.getPropertiesComponent();
pc.addFunction(new MyBeerFunction());
----
-== Writing custom property sources (advanced)
+== Using third party property sources
+
+The properties component allows to plugin 3rd party sources to load and lookup
properties via the `PropertySource`
+API from camel-api.
The regular `PropertySource` will lookup the property on-demand,
for example to lookup values from a backend source such as a database or
HashiCorp Vault etc.
@@ -580,11 +543,6 @@ A `PropertySource` can define that it supports loading all
its properties
(by implementing `LoadablePropertiesSource`) from the source at once, for
example from file system.
This allows Camel properties component to load these properties at once during
startup.
-=== Using third party property sources
-
-The properties component allows to plugin 3rd party sources to load and lookup
properties via the `PropertySource`
-API from camel-api.
-
For example the `camel-microprofile-config` component is implemented using
this.
The 3rd-party `PropertySource` can automatic be discovered from classpath when
Camel is starting up.
This is done by include the file
`META-INF/services/org/apache/camel/property-source-factory` file which refers
to the fully qualified class name of the `PropertySource` implementation.