This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 3938534 Add missing examples to Properties component doc (#4063)
3938534 is described below
commit 3938534681297fe871545f7a5b797632cb2a3574
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Aug 2 10:04:59 2020 +0200
Add missing examples to Properties component doc (#4063)
---
.../camel/catalog/docs/properties-component.adoc | 77 ++++++++++++++++++++++
.../src/main/docs/properties-component.adoc | 77 ++++++++++++++++++++++
.../modules/ROOT/pages/properties-component.adoc | 11 +---
3 files changed, 157 insertions(+), 8 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/properties-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/properties-component.adoc
index 111b9ec..f5cb04e 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/properties-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/properties-component.adoc
@@ -317,9 +317,39 @@ 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
@@ -462,12 +492,49 @@ Each location is separated by comma.
When using Blueprint property placeholder in the Blueprint XML file, you
can declare the properties directly in the XML file as shown below:
+[source,xml]
+----
+<!-- blueprint property placeholders -->
+<cm:property-placeholder persistent-id="my-placeholders"
update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="greeting" value="Hello"/>
+ <cm:property name="destination" value="mock:result"/>
+ </cm:default-properties>
+</cm:property-placeholder>
+
+<!-- a bean that uses a blueprint property placeholder -->
+<bean id="myCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
+ <property name="say" value="${greeting}"/>
+</bean>
+
+<camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+ <route>
+ <from uri="direct:start"/>
+ <bean ref="myCoolBean" method="saySomething"/>
+ <to uri="{{destination}}"/>
+ </route>
+
+</camelContext>
+----
+
Notice that we have a `<bean>` which refers to one of the properties. And
in the Camel route we refer to the other using the `{{` and `}}` notation.
Now if you want to override these Blueprint properties from an unit
test, you can do this as shown below:
+[source,java]
+----
+protected String useOverridePropertiesWithConfigAdmin(Dictionary props) {
+ // add the properties we want to override
+ props.put("greeting", "Bye");
+
+ // return the PID of the config-admin we are using in the blueprint xml
file
+ return "my-placeholders";
+}
+----
+
To do this we override and implement the
`useOverridePropertiesWithConfigAdmin` method. We can then put the
properties we want to override on the given props parameter. And the
@@ -491,6 +558,16 @@ Now if you want to unit test this blueprint XML file, then
you can
override the `loadConfigAdminConfigurationFile` and tell Camel which
file to load as shown below:
+[source,java]
+----
+@Override
+protected String[] loadConfigAdminConfigurationFile() {
+ // String[0] = tell Camel the path of the .cfg file to use for OSGi
ConfigAdmin in the blueprint XML file
+ // String[1] = tell Camel the persistence-id of the
cm:property-placeholder in the blueprint XML file
+ return new String[]{"src/test/resources/etc/stuff.cfg", "stuff"};
+}
+----
+
Notice that this method requires to return a `String[]` with 2 values. The
1st value is the path for the configuration file to load.
The 2nd value is the `persistence-id` of the `<cm:property-placeholder>`
diff --git a/core/camel-base/src/main/docs/properties-component.adoc
b/core/camel-base/src/main/docs/properties-component.adoc
index 111b9ec..f5cb04e 100644
--- a/core/camel-base/src/main/docs/properties-component.adoc
+++ b/core/camel-base/src/main/docs/properties-component.adoc
@@ -317,9 +317,39 @@ 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
@@ -462,12 +492,49 @@ Each location is separated by comma.
When using Blueprint property placeholder in the Blueprint XML file, you
can declare the properties directly in the XML file as shown below:
+[source,xml]
+----
+<!-- blueprint property placeholders -->
+<cm:property-placeholder persistent-id="my-placeholders"
update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="greeting" value="Hello"/>
+ <cm:property name="destination" value="mock:result"/>
+ </cm:default-properties>
+</cm:property-placeholder>
+
+<!-- a bean that uses a blueprint property placeholder -->
+<bean id="myCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
+ <property name="say" value="${greeting}"/>
+</bean>
+
+<camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+ <route>
+ <from uri="direct:start"/>
+ <bean ref="myCoolBean" method="saySomething"/>
+ <to uri="{{destination}}"/>
+ </route>
+
+</camelContext>
+----
+
Notice that we have a `<bean>` which refers to one of the properties. And
in the Camel route we refer to the other using the `{{` and `}}` notation.
Now if you want to override these Blueprint properties from an unit
test, you can do this as shown below:
+[source,java]
+----
+protected String useOverridePropertiesWithConfigAdmin(Dictionary props) {
+ // add the properties we want to override
+ props.put("greeting", "Bye");
+
+ // return the PID of the config-admin we are using in the blueprint xml
file
+ return "my-placeholders";
+}
+----
+
To do this we override and implement the
`useOverridePropertiesWithConfigAdmin` method. We can then put the
properties we want to override on the given props parameter. And the
@@ -491,6 +558,16 @@ Now if you want to unit test this blueprint XML file, then
you can
override the `loadConfigAdminConfigurationFile` and tell Camel which
file to load as shown below:
+[source,java]
+----
+@Override
+protected String[] loadConfigAdminConfigurationFile() {
+ // String[0] = tell Camel the path of the .cfg file to use for OSGi
ConfigAdmin in the blueprint XML file
+ // String[1] = tell Camel the persistence-id of the
cm:property-placeholder in the blueprint XML file
+ return new String[]{"src/test/resources/etc/stuff.cfg", "stuff"};
+}
+----
+
Notice that this method requires to return a `String[]` with 2 values. The
1st value is the path for the configuration file to load.
The 2nd value is the `persistence-id` of the `<cm:property-placeholder>`
diff --git a/docs/components/modules/ROOT/pages/properties-component.adoc
b/docs/components/modules/ROOT/pages/properties-component.adoc
index 3f1b2bd..365090e 100644
--- a/docs/components/modules/ROOT/pages/properties-component.adoc
+++ b/docs/components/modules/ROOT/pages/properties-component.adoc
@@ -323,9 +323,9 @@ The example below has property placeholder in the
`<jmxAgent>` tag:
----
<camelContext xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties"
location="org/apache/camel/spring/jmx.properties"/>
- <!-- we can use propery placeholders when we define the JMX agent -->
- <jmxAgent id="agent" registryPort="{{myjmx.port}}"
disabled="{{myjmx.disabled}}"
- usePlatformMBeanServer="{{myjmx.usePlatform}}"
createConnector="true"
+ <!-- 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"/>
@@ -334,7 +334,6 @@ The example below has property placeholder in the
`<jmxAgent>` tag:
</camelContext>
----
-
You can also define property placeholders in the various attributes on
the `<camelContext>` tag such as `trace` as shown here:
@@ -353,7 +352,6 @@ the `<camelContext>` tag such as `trace` as shown here:
</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
@@ -522,7 +520,6 @@ can declare the properties directly in the XML file as
shown below:
</camelContext>
----
-
Notice that we have a `<bean>` which refers to one of the properties. And
in the Camel route we refer to the other using the `{{` and `}}` notation.
@@ -540,7 +537,6 @@ protected String
useOverridePropertiesWithConfigAdmin(Dictionary props) {
}
----
-
To do this we override and implement the
`useOverridePropertiesWithConfigAdmin` method. We can then put the
properties we want to override on the given props parameter. And the
@@ -574,7 +570,6 @@ protected String[] loadConfigAdminConfigurationFile() {
}
----
-
Notice that this method requires to return a `String[]` with 2 values. The
1st value is the path for the configuration file to load.
The 2nd value is the `persistence-id` of the `<cm:property-placeholder>`