Author: buildbot Date: Wed Feb 1 18:19:58 2017 New Revision: 1006044 Log: Production update by buildbot for camel
Modified: websites/production/camel/content/book-component-appendix.html websites/production/camel/content/book-in-one-page.html websites/production/camel/content/cache/main.pageCache websites/production/camel/content/properties.html websites/production/camel/content/using-propertyplaceholder.html Modified: websites/production/camel/content/book-component-appendix.html ============================================================================== --- websites/production/camel/content/book-component-appendix.html (original) +++ websites/production/camel/content/book-component-appendix.html Wed Feb 1 18:19:58 2017 @@ -621,8 +621,8 @@ cometds://localhost:8443/service/mychann <div class="confluence-information-macro-body"> <p>When using CXF in streaming modes (see DataFormat option), then also read about <a shape="rect" href="stream-caching.html">Stream caching</a>.</p> </div> -</div><p>The <strong>cxf:</strong> component provides integration with <a shape="rect" href="http://cxf.apache.org">Apache CXF</a> for connecting to JAX-WS services hosted in CXF.</p><p><style type="text/css">/**/ div.rbtoc1485818260800 {padding: 0px;} div.rbtoc1485818260800 ul {list-style: disc;margin-left: 0px;} div.rbtoc1485818260800 li {margin-left: 0px;padding-left: 0px;} /**/</style> - </p><div class="toc-macro rbtoc1485818260800"> +</div><p>The <strong>cxf:</strong> component provides integration with <a shape="rect" href="http://cxf.apache.org">Apache CXF</a> for connecting to JAX-WS services hosted in CXF.</p><p><style type="text/css">/**/ div.rbtoc1485973067488 {padding: 0px;} div.rbtoc1485973067488 ul {list-style: disc;margin-left: 0px;} div.rbtoc1485973067488 li {margin-left: 0px;padding-left: 0px;} /**/</style> + </p><div class="toc-macro rbtoc1485973067488"> <ul class="toc-indentation"><li><a shape="rect" href="#BookComponentAppendix-CXFComponent">CXF Component</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookComponentAppendix-URIformat">URI format</a></li><li><a shape="rect" href="#BookComponentAppendix-Options">Options</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookComponentAppendix-Thedescriptionsofthedataformats">The descriptions of the dataformats</a> @@ -4582,38 +4582,44 @@ cometds://localhost:8443/service/mychann <div class="confluence-information-macro-body"> <p>You can use the method <strong><code>resolvePropertyPlaceholders</code></strong> on the <strong><code>CamelContext</code></strong> to resolve a property from any Java code.</p> </div> -</div><p></p><h2 id="BookComponentAppendix-UsingPropertyPlaceholder">Using <code>PropertyPlaceholder</code></h2><p><strong>Available as of Camel 2.3</strong></p><p>Camel now provides a new <strong><code>PropertiesComponent</code></strong> in <strong>camel-core</strong> which allows you to use property placeholders when defining Camel <a shape="rect" href="endpoint.html">Endpoint</a> URIs. This works much like you would do if using Spring's <strong><code><property-placeholder></code></strong> tag. However Spring has a limitation that prevents 3rd party frameworks from fully leveraging Spring property placeholders.</p><p>For more details see: <a shape="rect" href="how-do-i-use-spring-property-placeholder-with-camel-xml.html">How do I use Spring Property Placeholder with Camel XML</a>.</p> +</div><p></p><h2 id="BookComponentAppendix-UsingPropertyPlaceholder">Using <strong><code>PropertyPlaceholder</code></strong></h2><p><strong>Available as of Camel 2.3</strong></p><p>Camel now provides a new <strong><code>PropertiesComponent</code></strong> in <strong><code>camel-core</code></strong> which allows you to use property placeholders when defining Camel <a shape="rect" href="endpoint.html">Endpoint</a> URIs. This works much like you would do if using Spring's <strong><code><property-placeholder></code></strong> tag. However Spring has a limitation that prevents third-party frameworks from fully leveraging Spring property placeholders.</p><p>For more details see: <a shape="rect" href="how-do-i-use-spring-property-placeholder-with-camel-xml.html">How do I use Spring Property Placeholder with Camel XML</a>.</p> <div class="confluence-information-macro confluence-information-macro-tip"> <p class="title">Bridging Spring and Camel property placeholders</p> <span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span> <div class="confluence-information-macro-body"> <p>From <strong>Camel 2.10</strong>: Spring's property placeholder can be bridged with Camel's. See below for more details.</p> </div> - </div><p>The property placeholder is generally in use when doing any of the following:</p> - <ul class="alternate"><li>lookup or creating endpoints.</li><li>lookup of beans in the <a shape="rect" href="registry.html">Registry.</a></li><li>additional supported in Spring XML (see below in examples).</li><li>using Blueprint <strong><code>PropertyPlaceholder</code></strong> with Camel <a shape="rect" href="properties.html">Properties</a> component.</li><li>using <strong><code>@PropertyInject</code></strong> to inject a property in a POJO.</li><li><strong>Camel 2.14.1</strong> Using default value if a property does not exists.</li><li><strong>Camel 2.14.1</strong> Include out of the box functions, to lookup property values from OS environment variables, JVM system properties, or the service idiom.</li><li><strong>Camel 2.14.1</strong> Using custom functions, which can be plugged into the property component.</li></ul><h3 id="BookComponentAppendix-Syntax">Syntax</h3><p>The syntax to use Camel's property placeholder is to use <strong>{{<code>key</code>}}</strong> for example <strong>{{<code>file.uri</code>}}</strong> where <strong><code>file.uri</code></strong> is the property key. You can use property placeholders in parts of the endpoint URI's which for example you can use placeholders for parameters in the URIs.</p><p>From <strong>Camel 2.14.1</strong>: you can specify a default value to use if a property with the key does not exists, e.g., <strong><code>file.url:/some/path</code></strong> where the default value is the text after the colon, e.g., <strong><code>/some/path</code></strong>.</p> + </div><p>The property placeholder is typically used when trying to do any of the following:</p> + <ul class="alternate"><li>Lookup or creating endpoints.</li><li>Lookup of beans in the <a shape="rect" href="registry.html">Registry.</a></li><li>Additional supported in Spring XML (see below in examples).</li><li>Using Blueprint <strong><code>PropertyPlaceholder</code></strong> with Camel <a shape="rect" href="properties.html">Properties</a> component.</li><li>Using <strong><code>@PropertyInject</code></strong> to inject a property in a POJO.</li><li><strong>Camel 2.14.1</strong> Using default value if a property does not exists.</li><li><strong>Camel 2.14.1</strong> Include out of the box functions, to lookup property values from OS environment variables, JVM system properties, or the service idiom.</li><li><strong>Camel 2.14.1</strong> Using custom functions, which can be plugged into the property component.</li></ul><h3 id="BookComponentAppendix-Format">Format</h3><p>The value of a Camel property can be obtained by specifying its key name within a property placeholder, usi ng the following format: <strong>{{<code>key</code>}}</strong>.</p><p>For example:</p> + <div class="code panel pdl" style="border-width: 1px;"> + <div class="codeContent panelContent pdl"> + <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">{{file.uri}}</script> + </div> + </div><p>where <strong><code>file.uri</code></strong> is the property key.</p><p>Property placeholders can be used to specify parts, or all, of an endpoint's URI by embedding one or more placeholders in the URI's string definition.</p><p>From <strong>Camel 2.14.1</strong>: you can specify a default value to use if a property with the key does not exists, e.g., <strong><code>file.url:/some/path</code></strong> where the default value is the text after the colon, e.g., <strong><code>/some/path</code></strong>.</p> <div class="confluence-information-macro confluence-information-macro-information"> <span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span> <div class="confluence-information-macro-body"> <p>From <strong>Camel 2.14.1</strong>: do <em>not</em> use a colon in the property key. The colon character is used as a token separator when providing a default value.</p> </div> - </div><h3 id="BookComponentAppendix-UsingPropertyResolver">Using <code>PropertyResolver</code></h3><p>Camel provides a pluggable mechanism which allows 3rd part to provide their own resolver to lookup properties. Camel provides a default implementation <strong><code>org.apache.camel.component.properties.DefaultPropertiesResolver</code></strong> which is capable of loading properties from the file system, classpath or <a shape="rect" href="registry.html">Registry</a>. You can prefix the locations with either:</p> - <ul class="alternate"><li><strong><code>ref:</code> Camel 2.4:</strong> to lookup in the <a shape="rect" href="registry.html">Registry.</a></li><li><strong><code>file:</code></strong> to load the from file system.</li><li><strong><code>classpath:</code></strong> to load from classpath (this is also the default if no prefix is provided).</li><li><strong><code>blueprint:</code> Camel 2.7:</strong> to use a specific OSGi blueprint placeholder service.</li></ul><h3 id="BookComponentAppendix-DefiningLocation">Defining Location</h3><p>The <strong><code>PropertiesResolver</code></strong> need to know a location(s) where to resolve the properties. You can define 1 to many locations. If you define the location in a single String property you can separate multiple locations with comma such as:</p> + </div><h3 id="BookComponentAppendix-UsingPropertyResolver">Using <code>PropertyResolver</code></h3><p>Camel provides a pluggable mechanism that allows third-parties to specify their own resolver to use for the lookup of properties.</p><p>Camel provides a default implementation <strong><code>org.apache.camel.component.properties.DefaultPropertiesResolver</code></strong> which is capable of loading properties from the file system, classpath or <a shape="rect" href="registry.html">Registry</a>. To indicate which source to use the location must contain the appropriate prefix.</p><p>The list of prefixes is:</p> + <div class="table-wrap"> + <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Prefix</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ref:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Lookup in the <a shape="rect" href="registry.html">Registry.</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>file:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Load the from file system.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>classpath:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Load from the classpath (this is also the default if no prefix is provided).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>blueprint:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Use a specific OSGi blueprint placeholder service.</ p></td></tr></tbody></table> + </div><h3 id="BookComponentAppendix-DefiningLocation">Defining Location</h3><p>The <strong><code>PropertiesResolver</code></strong> must be configured with the location(s) to use when resolving properties. One or more locations can be given. Specifying multiple locations can be done a couple of ways: using either a single comma separated string, or an array of strings.</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> - <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocation(&quot;com/mycompany/myprop.properties,com/mycompany/other.properties&quot;); </script> + <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocation(&quot;com/mycompany/myprop.properties,com/mycompany/other.properties&quot;); pc.setLocation(new String[] {&quot;com/mycompany/myprop.properties&quot;, &quot;com/mycompany/other.properties&quot;}); </script> </div> </div> <div> - <p><span><br clear="none"></span></p> - <p><strong>Available as of Camel 2.19.0</strong></p> - <p>You can set which location can be discarded if missing by by setting the <code>optional</code> attribute, which is false by default, i.e:</p> + <p> </p> + <p>From<strong> Camel 2.19.0</strong>: you can set which location can be discarded if missing by setting  <strong><code>optional=true</code></strong>, (<strong><code>false</code></strong> by default).</p> + <p>Example:</p> </div> <div> - <h4 id="BookComponentAppendix-ConfiguringinSpringXML">Configuring in Spring XML</h4> <p> </p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> - <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocations( &quot;com/mycompany/override.properties;optional=true&quot; &quot;com/mycompany/defaults.properties&quot;);</script> + <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocations(&quot;com/mycompany/override.properties;optional=true,com/mycompany/defaults.properties&quot;);</script> </div> </div> <p> </p> @@ -4627,28 +4633,27 @@ cometds://localhost:8443/service/mychann <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">location=file:${env:APP_HOME}/etc/foo.properties </script> </div> - </div><p>Where <strong><code>APP_HOME</code></strong> is an OS environment.</p><p>You can have multiple placeholders in the same location, such as:</p> + </div><p>Where <strong><code>APP_HOME</code></strong> is an OS environment variable.</p><p>You can have multiple placeholders in the same location, such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">location=file:${env:APP_HOME}/etc/${prop.name}.properties </script> </div> - </div><h4 id="BookComponentAppendix-UsingSystemandEnvironmentVariablestoConfigurePropertyPrefixesandSuffixes">Using System and Environment Variables to Configure Property Prefixes and Suffixes</h4><p><strong>Available as of Camel 2.12.5, 2.13.3, 2.14.0</strong></p><p><strong><code>propertyPrefix</code></strong>, <strong><code>propertySuffix</code></strong> configuration properties support using placeholders for JVM system properties and OS environments variables.</p><p>For example, if <strong><code>PropertiesComponent</code></strong> is configured with the following properties file:</p> - <div class="preformatted panel" style="border-width: 1px;"> - <div class="preformattedContent panelContent"> - <pre>dev.endpoint = result1 -test.endpoint = result2</pre> + </div><h4 id="BookComponentAppendix-UsingSystemorEnvironmentVariablestoConfigurePropertyPrefixesandSuffixes">Using System or Environment Variables to Configure Property Prefixes and Suffixes</h4><p>From<strong> Camel 2.12.5, 2.13.3, 2.14.0</strong>:<strong><code> propertyPrefix</code></strong>, <strong><code>propertySuffix</code></strong> configuration properties support the use of placeholders for de-referencing JVM system properties and OS environments variables.</p><p>Example:</p><p>Assume the <strong><code>PropertiesComponent</code></strong> is configured with the following properties file:</p> + <div class="code panel pdl" style="border-width: 1px;"> + <div class="codeContent panelContent pdl"> + <script class="brush: text; gutter: false; theme: Default" type="syntaxhighlighter">dev.endpoint = result1 test.endpoint = result2</script> </div> - </div><p>Then with the following route definition:</p> + </div><p>The same properties file is then referenced from a route definition:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">PropertiesComponent pc = context.getComponent(&quot;properties&quot;, PropertiesComponent.class); pc.setPropertyPrefix(&quot;${stage}.&quot;); // ... context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(&quot;direct:start&quot;) .to(&quot;properties:mock:{{endpoint}}&quot;); } });</script> </div> - </div><p>it is possible to change the target endpoint by changing system property <strong><code>stage</code></strong> either to <strong><code>dev</code></strong> (the message will be routed to <strong><code>mock:result1</code></strong>) or <strong><code>test</code></strong> (the message will be routed to <strong><code>mock:result2</code></strong>).</p><h3 id="BookComponentAppendix-ConfiguringinJavaDSL">Configuring in Java DSL</h3><p>You have to create and register the <strong><code>PropertiesComponent</code></strong> under the name <strong><code>properties</code></strong> such as:</p> + </div><p>By using the configuration options <strong><code>propertyPrefix</code></strong> it's possible to change the target endpoint simply by changing the value of the system property <strong><code>stage</code></strong> either to <strong><code>dev</code></strong> (the message will be routed to <strong><code>mock:result1</code></strong>) or <strong><code>test</code></strong> (the message will be routed to <strong><code>mock:result2</code></strong>).</p><h3 id="BookComponentAppendix-ConfiguringinJavaDSL">Configuring in Java DSL</h3><p>You have to create and register the <strong><code>PropertiesComponent</code></strong> under the name <strong><code>properties</code></strong> such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">PropertiesComponent pc = new PropertiesComponent(); pc.setLocation(&quot;classpath:com/mycompany/myprop.properties&quot;); context.addComponent(&quot;properties&quot;, pc); </script> </div> - </div><h3 id="BookComponentAppendix-ConfiguringinSpringXML.1">Configuring in Spring XML</h3><p>Spring XML offers two variations to configure. You can define a spring bean as a <strong><code>PropertiesComponent</code></strong> which resembles the way done in Java DSL. Or you can use the <strong><code><propertyPlaceholder></code></strong> tag.</p> + </div><h3 id="BookComponentAppendix-ConfiguringinSpringXML">Configuring in Spring XML</h3><p>Spring XML offers two variations to configure. You can define a spring bean as a <strong><code>PropertiesComponent</code></strong> which resembles the way done in Java DSL. Or you can use the <strong><code><propertyPlaceholder></code></strong> tag.</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;bean id=&quot;properties&quot; class=&quot;org.apache.camel.component.properties.PropertiesComponent&quot;&gt; &lt;property name=&quot;location&quot; value=&quot;classpath:com/mycompany/myprop.properties&quot;/&gt; &lt;/bean&gt; </script> @@ -4658,7 +4663,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;camelContext ...&gt; &lt;propertyPlaceholder id=&quot;properties&quot; location=&quot;com/mycompany/myprop.properties&quot;/&gt; &lt;/camelContext&gt; </script> </div> - </div><p><span>Setting the properties location through the location tag works just fine but sometime you have a number of resources to take into account and starting from </span><strong>Camel 2.19.0</strong><span> you can set the properties location with a dedicated propertiesLocation:</span></p> + </div><p><span>Setting the properties location through the location tag works just fine but sometime you have a number of resources to take into account and starting from </span><strong>Camel 2.19.0</strong><span> you can set the properties location with a dedicated <strong><code>propertiesLocation</code></strong>:</span></p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;camelContext ...&gt; &lt;propertyPlaceholder id=&quot;myPropertyPlaceholder&quot;&gt; &lt;propertiesLocation resolver = &quot;classpath&quot; path = &quot;com/my/company/something/my-properties-1.properties&quot; optional = &quot;false&quot;/&gt; &lt;propertiesLocation resolver = &quot;classpath&quot; path = &quot;com/my/company/something/my-properties-2.properties&quot; optional = &quot;false&quot;/&gt; &lt;propertiesLocation resolver = &quot;file&quot; path = &quot;${karaf.home}/etc/my-override.properties&quot; optional = &quot;true&quot;/&gt; &lt;/propertyPlaceholder&gt; &lt;/camelContext&gt;</script> @@ -4685,7 +4690,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">// properties cool.foo=result // route from(&quot;direct:start&quot;) .to(&quot;properties:mock:{{cool.foo}}&quot;); </script> </div> - </div><p>In the example above the to endpoint will be resolved to <code>mock:result</code>.</p><p>You can also have properties with refer to each other such as:</p> + </div><p>In the example above the to endpoint will be resolved to <strong><code>mock:result</code></strong>.</p><p>You can also have properties with refer to each other such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">// properties cool.foo=result cool.concat=mock:{{cool.foo}} // route from(&quot;direct:start&quot;) .to(&quot;properties:mock:{{cool.concat}}&quot;); </script> @@ -4794,7 +4799,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"> @Override protected String useOverridePropertiesWithConfigAdmin(Dictionary props) { // add the properties we want to override props.put(&quot;greeting&quot;, &quot;Bye&quot;); // return the PID of the config-admin we are using in the blueprint xml file return &quot;my-placeholders&quot;; } </script> </div> - </div> <p>To do this we override and implement the <strong><code>useOverridePropertiesWithConfigAdmin</code></strong> method. We can then put the properties we want to override on the given props parameter. And the return value <em>must</em> be the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag, which you define in the blueprint XML file.</p><h4 id="BookComponentAppendix-Usinga.cfgor.propertiesFileforBlueprintPropertyPlaceholders">Using a <code>.cfg</code> or <code>.properties</code> File for Blueprint Property Placeholders</h4><p><strong>Available as of Camel 2.10.4</strong></p><p>When using Blueprint property placeholder in the Blueprint XML file, you can declare the properties in a .properties or <strong><code>.cfg</code></strong> file. If you use Apache ServieMix/Karaf then this container has a convention that it loads the properties from a file in the etc directory with the naming <strong><code>etc/pid.cfg</code></s trong>, where <strong><code>pid</code></strong> is the persistence-id.</p><p>For example in the blueprint XML file we have the <strong><code>persistence-id="stuff"</code></strong>, which mean it will load the configuration file as <strong><code>etc/stuff.cfg</code></strong>. + </div> <p>To do this we override and implement the <strong><code>useOverridePropertiesWithConfigAdmin</code></strong> method. We can then put the properties we want to override on the given props parameter. And the return value <em>must</em> be the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag, which you define in the blueprint XML file.</p><h4 id="BookComponentAppendix-Usinga.cfgor.propertiesFileforBlueprintPropertyPlaceholders">Using a <code>.cfg</code> or <code>.properties</code> File for Blueprint Property Placeholders</h4><p><strong>Available as of Camel 2.10.4</strong></p><p>When using Blueprint property placeholder in the Blueprint XML file, you can declare the properties in a .properties or <strong><code>.cfg</code></strong> file. If you use Apache ServiceMix/Karaf then this container has a convention that it loads the properties from a file in the etc directory with the naming <strong><code>etc/pid.cfg</code></ strong>, where <strong><code>pid</code></strong> is the persistence-id.</p><p>For example in the blueprint XML file we have the <strong><code>persistence-id="stuff"</code></strong>, which mean it will load the configuration file as <strong><code>etc/stuff.cfg</code></strong>. </p><div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"> &lt;!-- blueprint property placeholders, that will use etc/stuff.cfg as the properties file --&gt; &lt;cm:property-placeholder persistent-id=&quot;stuff&quot; update-strategy=&quot;reload&quot;/&gt; &lt;!-- a bean that uses a blueprint property placeholder --&gt; &lt;bean id=&quot;myCoolBean&quot; class=&quot;org.apache.camel.test.blueprint.MyCoolBean&quot;&gt; &lt;property name=&quot;say&quot; value=&quot;${greeting}&quot;/&gt; &lt;/bean&gt; &lt;camelContext xmlns=&quot;http://camel.apache.org/schema/blueprint&quot;&gt; &lt;route&gt; &lt;from uri=&quot;direct:start&quot;/&gt; &lt;bean ref=&quot;myCoolBean&quot; method=&quot;saySomething&quot;/&gt; &lt;to uri=&quot;mock:result&quot;/&gt; &lt;/route&gt; &lt;/came lContext&gt; </script> @@ -4804,7 +4809,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"> @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[]{&quot;src/test/resources/etc/stuff.cfg&quot;, &quot;stuff&quot;}; } </script> </div> - </div> <p>Notice that this method requires to return a <strong><code>String[]</code></strong> with 2 values. The 1st value is the path for the configuration file to load. The 2nd value is the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag.</p><p>The <strong><code>stuff.cfg</code></strong> file is just a plain properties file with the property placeholders such as:</p> + </div> <p>Notice that this method requires to return a <strong><code>String[]</code></strong> with 2 values. The 1st value is the path for the configuration file to load. The second value is the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag.</p><p>The <strong><code>stuff.cfg</code></strong> file is just a plain properties file with the property placeholders such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">## this is a comment greeting=Bye </script> @@ -4824,7 +4829,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">greeting=Bye echo=Yay destination=mock:result </script> </div> - </div><h3 id="BookComponentAppendix-BridgingSpringandCamelPropertyPlaceholders">Bridging Spring and Camel Property Placeholders</h3><p><strong>Available as of Camel 2.10</strong></p><p>The Spring Framework does not allow 3rd party frameworks such as Apache Camel to seamless hook into the Spring property placeholder mechanism. However you can easily bridge Spring and Camel by declaring a Spring bean with the type <strong><code>org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer</code></strong>, which is a Spring <strong><code>org.springframework.beans.factory.config.PropertyPlaceholderConfigurer</code></strong> type.</p><p>To bridge Spring and Camel you must define a single bean as shown below: + </div><h3 id="BookComponentAppendix-BridgingSpringandCamelPropertyPlaceholders">Bridging Spring and Camel Property Placeholders</h3><p><strong>Available as of Camel 2.10</strong></p><p>The Spring Framework does not allow third-party frameworks such as Apache Camel to seamless hook into the Spring property placeholder mechanism. However you can easily bridge Spring and Camel by declaring a Spring bean with the type <strong><code>org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer</code></strong>, which is a Spring <strong><code>org.springframework.beans.factory.config.PropertyPlaceholderConfigurer</code></strong> type.</p><p>To bridge Spring and Camel you must define a single bean as shown below: </p><div class="code panel pdl" style="border-width: 1px;"> <div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"> <b>Bridging Spring and Camel property placeholders</b> @@ -4859,7 +4864,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"> // override this method to provide our custom properties we use in this unit test @Override protected Properties useOverridePropertiesWithPropertiesComponent() { Properties extra = new Properties(); extra.put(&quot;destination&quot;, &quot;mock:extra&quot;); extra.put(&quot;greeting&quot;, &quot;Bye&quot;); return extra; } </script> </div> - </div> <p>This can be done from any of the Camel Test kits, such as <code>camel-test</code>, <code>camel-test-spring</code> and <code>camel-test-blueprint</code>.</p><p>The <strong><code>ignoreMissingLocationWithPropertiesComponent</code></strong> can be used to instruct Camel to ignore any locations which was not discoverable. For example if you run the unit test, in an environment that does not have access to the location of the properties.</p><h3 id="BookComponentAppendix-Using@PropertyInject">Using <code>@PropertyInject</code></h3><p><strong>Available as of Camel 2.12</strong></p><p>Camel allows to inject property placeholders in POJOs using the <strong><code>@PropertyInject</code></strong> annotation which can be set on fields and setter methods. For example you can use that with <strong><code>RouteBuilder</code></strong> classes, such as shown below:</p> + </div> <p>This can be done from any of the Camel Test kits, such as <strong><code>camel-test</code></strong>, <strong><code>camel-test-spring</code></strong> and <strong><code>camel-test-blueprint</code></strong>.</p><p>The <strong><code>ignoreMissingLocationWithPropertiesComponent</code></strong> can be used to instruct Camel to ignore any locations which was not discoverable. For example if you run the unit test, in an environment that does not have access to the location of the properties.</p><h3 id="BookComponentAppendix-Using@PropertyInject">Using <code>@PropertyInject</code></h3><p><strong>Available as of Camel 2.12</strong></p><p>Camel allows to inject property placeholders in POJOs using the <strong><code>@PropertyInject</code></strong> annotation which can be set on fields and setter methods. For example you can use that with <strong><code>RouteBuilder</code></strong> classes, such as shown below:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">public class MyRouteBuilder extends RouteBuilder { @PropertyInject(&quot;hello&quot;) private String greeting; @Override public void configure() throws Exception { from(&quot;direct:start&quot;) .transform().constant(greeting) .to(&quot;{{result}}&quot;); } } </script> @@ -4875,7 +4880,7 @@ test.endpoint = result2</pre> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">@PropertyInject(value = &quot;myTimeout&quot;, defaultValue = &quot;5000&quot;) private int timeout; </script> </div> </div><h3 id="BookComponentAppendix-UsingOutoftheBoxFunctions">Using Out of the Box Functions</h3><p><strong>Available as of Camel 2.14.1</strong></p><p>The <a shape="rect" href="properties.html">Properties</a> component includes the following functions out of the box</p> - <ul><li><code>env</code> - A function to lookup the property from OS environment variables.</li><li><code>sys</code> - A function to lookup the property from Java JVM system properties.</li><li><code>service</code> - A function to lookup the property from OS environment variables using the service naming idiom.</li><li><code>service.host</code> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the hostname part only.</li><li><code>service.port</code> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the port part only.</li></ul><p>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:</p> + <ul><li><strong><code>env</code></strong> - A function to lookup the property from OS environment variables.</li><li><strong><code>sys</code></strong> - A function to lookup the property from Java JVM system properties.</li><li><strong><code>service</code></strong> - A function to lookup the property from OS environment variables using the service naming idiom.</li><li><strong><code>service.host</code></strong> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the hostname part only.</li><li><strong><code>service.port</code></strong> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the port part only.</li></ul><p>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:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;camelContext xmlns=&quot;http://camel.apache.org/schema/blueprint&quot;&gt; &lt;route&gt; &lt;from uri=&quot;direct:start&quot;/&gt; &lt;to uri=&quot;{{env:SOMENAME}}&quot;/&gt; &lt;to uri=&quot;{{sys:MyJvmPropertyName}}&quot;/&gt; &lt;/route&gt; &lt;/camelContext&gt;</script> Modified: websites/production/camel/content/book-in-one-page.html ============================================================================== --- websites/production/camel/content/book-in-one-page.html (original) +++ websites/production/camel/content/book-in-one-page.html Wed Feb 1 18:19:58 2017 @@ -3930,11 +3930,11 @@ The tutorial has been designed in two pa While not actual tutorials you might find working through the source of the various <a shape="rect" href="examples.html">Examples</a> useful.</li></ul> <h2 id="BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</h2><p> </p><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Thanks</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This tutorial was kindly donated to Apache Camel by Martin Gilday.</p></div></div><h2 id="BookInOnePage-Preface">Preface</h2><p>This tutorial aims to guide the reader through the stages of creating a project which uses Camel to facilitate the routing of messages from a JMS queue to a <a shape="rect" class="external-link" href="http://www.springramework.org" rel="nofollow">Spring</a> service. The route works in a synchronous fashion returning a response to the client.</p><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1485818270439 {padding: 0px;} -div.rbtoc1485818270439 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1485818270439 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1485973100154 {padding: 0px;} +div.rbtoc1485973100154 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1485973100154 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1485818270439"> +/*]]>*/</style></p><div class="toc-macro rbtoc1485973100154"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</a></li><li><a shape="rect" href="#BookInOnePage-Preface">Preface</a></li><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-About">About</a></li><li><a shape="rect" href="#BookInOnePage-CreatetheCamelProject">Create the Camel Project</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-UpdatethePOMwithDependencies">Update the POM with Dependencies</a></li></ul> </li><li><a shape="rect" href="#BookInOnePage-WritingtheServer">Writing the Server</a> @@ -6049,11 +6049,11 @@ So we completed the last piece in the pi <p>This example has been removed from <strong>Camel 2.9</strong> onwards. Apache Axis 1.4 is a very old and unsupported framework. We encourage users to use <a shape="rect" href="cxf.html">CXF</a> instead of Axis.</p></div></div> <style type="text/css">/*<![CDATA[*/ -div.rbtoc1485818270674 {padding: 0px;} -div.rbtoc1485818270674 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1485818270674 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1485973100892 {padding: 0px;} +div.rbtoc1485973100892 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1485973100892 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style><div class="toc-macro rbtoc1485818270674"> +/*]]>*/</style><div class="toc-macro rbtoc1485973100892"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialusingAxis1.4withApacheCamel">Tutorial using Axis 1.4 with Apache Camel</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-Introduction">Introduction</a></li><li><a shape="rect" href="#BookInOnePage-SettinguptheprojecttorunAxis">Setting up the project to run Axis</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Maven2">Maven 2</a></li><li><a shape="rect" href="#BookInOnePage-wsdl">wsdl</a></li><li><a shape="rect" href="#BookInOnePage-ConfiguringAxis">Configuring Axis</a></li><li><a shape="rect" href="#BookInOnePage-RunningtheExample">Running the Example</a></li></ul> @@ -14234,8 +14234,8 @@ cometds://localhost:8443/service/mychann <div class="confluence-information-macro-body"> <p>When using CXF in streaming modes (see DataFormat option), then also read about <a shape="rect" href="stream-caching.html">Stream caching</a>.</p> </div> -</div><p>The <strong>cxf:</strong> component provides integration with <a shape="rect" href="http://cxf.apache.org">Apache CXF</a> for connecting to JAX-WS services hosted in CXF.</p><p><style type="text/css">/**/ div.rbtoc1485818274472 {padding: 0px;} div.rbtoc1485818274472 ul {list-style: disc;margin-left: 0px;} div.rbtoc1485818274472 li {margin-left: 0px;padding-left: 0px;} /**/</style> - </p><div class="toc-macro rbtoc1485818274472"> +</div><p>The <strong>cxf:</strong> component provides integration with <a shape="rect" href="http://cxf.apache.org">Apache CXF</a> for connecting to JAX-WS services hosted in CXF.</p><p><style type="text/css">/**/ div.rbtoc1485973123869 {padding: 0px;} div.rbtoc1485973123869 ul {list-style: disc;margin-left: 0px;} div.rbtoc1485973123869 li {margin-left: 0px;padding-left: 0px;} /**/</style> + </p><div class="toc-macro rbtoc1485973123869"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-CXFComponent">CXF Component</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-URIformat">URI format</a></li><li><a shape="rect" href="#BookInOnePage-Options">Options</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Thedescriptionsofthedataformats">The descriptions of the dataformats</a> @@ -18195,38 +18195,44 @@ cometds://localhost:8443/service/mychann <div class="confluence-information-macro-body"> <p>You can use the method <strong><code>resolvePropertyPlaceholders</code></strong> on the <strong><code>CamelContext</code></strong> to resolve a property from any Java code.</p> </div> -</div><p></p><h2 id="BookInOnePage-UsingPropertyPlaceholder">Using <code>PropertyPlaceholder</code></h2><p><strong>Available as of Camel 2.3</strong></p><p>Camel now provides a new <strong><code>PropertiesComponent</code></strong> in <strong>camel-core</strong> which allows you to use property placeholders when defining Camel <a shape="rect" href="endpoint.html">Endpoint</a> URIs. This works much like you would do if using Spring's <strong><code><property-placeholder></code></strong> tag. However Spring has a limitation that prevents 3rd party frameworks from fully leveraging Spring property placeholders.</p><p>For more details see: <a shape="rect" href="how-do-i-use-spring-property-placeholder-with-camel-xml.html">How do I use Spring Property Placeholder with Camel XML</a>.</p> +</div><p></p><h2 id="BookInOnePage-UsingPropertyPlaceholder">Using <strong><code>PropertyPlaceholder</code></strong></h2><p><strong>Available as of Camel 2.3</strong></p><p>Camel now provides a new <strong><code>PropertiesComponent</code></strong> in <strong><code>camel-core</code></strong> which allows you to use property placeholders when defining Camel <a shape="rect" href="endpoint.html">Endpoint</a> URIs. This works much like you would do if using Spring's <strong><code><property-placeholder></code></strong> tag. However Spring has a limitation that prevents third-party frameworks from fully leveraging Spring property placeholders.</p><p>For more details see: <a shape="rect" href="how-do-i-use-spring-property-placeholder-with-camel-xml.html">How do I use Spring Property Placeholder with Camel XML</a>.</p> <div class="confluence-information-macro confluence-information-macro-tip"> <p class="title">Bridging Spring and Camel property placeholders</p> <span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span> <div class="confluence-information-macro-body"> <p>From <strong>Camel 2.10</strong>: Spring's property placeholder can be bridged with Camel's. See below for more details.</p> </div> - </div><p>The property placeholder is generally in use when doing any of the following:</p> - <ul class="alternate"><li>lookup or creating endpoints.</li><li>lookup of beans in the <a shape="rect" href="registry.html">Registry.</a></li><li>additional supported in Spring XML (see below in examples).</li><li>using Blueprint <strong><code>PropertyPlaceholder</code></strong> with Camel <a shape="rect" href="properties.html">Properties</a> component.</li><li>using <strong><code>@PropertyInject</code></strong> to inject a property in a POJO.</li><li><strong>Camel 2.14.1</strong> Using default value if a property does not exists.</li><li><strong>Camel 2.14.1</strong> Include out of the box functions, to lookup property values from OS environment variables, JVM system properties, or the service idiom.</li><li><strong>Camel 2.14.1</strong> Using custom functions, which can be plugged into the property component.</li></ul><h3 id="BookInOnePage-Syntax.1">Syntax</h3><p>The syntax to use Camel's property placeholder is to use <strong>{{<code>key</code>}}</strong> for example <stron g>{{<code>file.uri</code>}}</strong> where <strong><code>file.uri</code></strong> is the property key. You can use property placeholders in parts of the endpoint URI's which for example you can use placeholders for parameters in the URIs.</p><p>From <strong>Camel 2.14.1</strong>: you can specify a default value to use if a property with the key does not exists, e.g., <strong><code>file.url:/some/path</code></strong> where the default value is the text after the colon, e.g., <strong><code>/some/path</code></strong>.</p> + </div><p>The property placeholder is typically used when trying to do any of the following:</p> + <ul class="alternate"><li>Lookup or creating endpoints.</li><li>Lookup of beans in the <a shape="rect" href="registry.html">Registry.</a></li><li>Additional supported in Spring XML (see below in examples).</li><li>Using Blueprint <strong><code>PropertyPlaceholder</code></strong> with Camel <a shape="rect" href="properties.html">Properties</a> component.</li><li>Using <strong><code>@PropertyInject</code></strong> to inject a property in a POJO.</li><li><strong>Camel 2.14.1</strong> Using default value if a property does not exists.</li><li><strong>Camel 2.14.1</strong> Include out of the box functions, to lookup property values from OS environment variables, JVM system properties, or the service idiom.</li><li><strong>Camel 2.14.1</strong> Using custom functions, which can be plugged into the property component.</li></ul><h3 id="BookInOnePage-Format">Format</h3><p>The value of a Camel property can be obtained by specifying its key name within a property placeholder, using the f ollowing format: <strong>{{<code>key</code>}}</strong>.</p><p>For example:</p> + <div class="code panel pdl" style="border-width: 1px;"> + <div class="codeContent panelContent pdl"> + <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">{{file.uri}}</script> + </div> + </div><p>where <strong><code>file.uri</code></strong> is the property key.</p><p>Property placeholders can be used to specify parts, or all, of an endpoint's URI by embedding one or more placeholders in the URI's string definition.</p><p>From <strong>Camel 2.14.1</strong>: you can specify a default value to use if a property with the key does not exists, e.g., <strong><code>file.url:/some/path</code></strong> where the default value is the text after the colon, e.g., <strong><code>/some/path</code></strong>.</p> <div class="confluence-information-macro confluence-information-macro-information"> <span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span> <div class="confluence-information-macro-body"> <p>From <strong>Camel 2.14.1</strong>: do <em>not</em> use a colon in the property key. The colon character is used as a token separator when providing a default value.</p> </div> - </div><h3 id="BookInOnePage-UsingPropertyResolver">Using <code>PropertyResolver</code></h3><p>Camel provides a pluggable mechanism which allows 3rd part to provide their own resolver to lookup properties. Camel provides a default implementation <strong><code>org.apache.camel.component.properties.DefaultPropertiesResolver</code></strong> which is capable of loading properties from the file system, classpath or <a shape="rect" href="registry.html">Registry</a>. You can prefix the locations with either:</p> - <ul class="alternate"><li><strong><code>ref:</code> Camel 2.4:</strong> to lookup in the <a shape="rect" href="registry.html">Registry.</a></li><li><strong><code>file:</code></strong> to load the from file system.</li><li><strong><code>classpath:</code></strong> to load from classpath (this is also the default if no prefix is provided).</li><li><strong><code>blueprint:</code> Camel 2.7:</strong> to use a specific OSGi blueprint placeholder service.</li></ul><h3 id="BookInOnePage-DefiningLocation">Defining Location</h3><p>The <strong><code>PropertiesResolver</code></strong> need to know a location(s) where to resolve the properties. You can define 1 to many locations. If you define the location in a single String property you can separate multiple locations with comma such as:</p> + </div><h3 id="BookInOnePage-UsingPropertyResolver">Using <code>PropertyResolver</code></h3><p>Camel provides a pluggable mechanism that allows third-parties to specify their own resolver to use for the lookup of properties.</p><p>Camel provides a default implementation <strong><code>org.apache.camel.component.properties.DefaultPropertiesResolver</code></strong> which is capable of loading properties from the file system, classpath or <a shape="rect" href="registry.html">Registry</a>. To indicate which source to use the location must contain the appropriate prefix.</p><p>The list of prefixes is:</p> + <div class="table-wrap"> + <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Prefix</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ref:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Lookup in the <a shape="rect" href="registry.html">Registry.</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>file:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Load the from file system.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>classpath:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Load from the classpath (this is also the default if no prefix is provided).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>blueprint:</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Use a specific OSGi blueprint placeholder service.</ p></td></tr></tbody></table> + </div><h3 id="BookInOnePage-DefiningLocation">Defining Location</h3><p>The <strong><code>PropertiesResolver</code></strong> must be configured with the location(s) to use when resolving properties. One or more locations can be given. Specifying multiple locations can be done a couple of ways: using either a single comma separated string, or an array of strings.</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> - <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocation(&quot;com/mycompany/myprop.properties,com/mycompany/other.properties&quot;); </script> + <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocation(&quot;com/mycompany/myprop.properties,com/mycompany/other.properties&quot;); pc.setLocation(new String[] {&quot;com/mycompany/myprop.properties&quot;, &quot;com/mycompany/other.properties&quot;}); </script> </div> </div> <div> - <p><span><br clear="none"></span></p> - <p><strong>Available as of Camel 2.19.0</strong></p> - <p>You can set which location can be discarded if missing by by setting the <code>optional</code> attribute, which is false by default, i.e:</p> + <p> </p> + <p>From<strong> Camel 2.19.0</strong>: you can set which location can be discarded if missing by setting  <strong><code>optional=true</code></strong>, (<strong><code>false</code></strong> by default).</p> + <p>Example:</p> </div> <div> - <h4 id="BookInOnePage-ConfiguringinSpringXML">Configuring in Spring XML</h4> <p> </p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> - <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocations( &quot;com/mycompany/override.properties;optional=true&quot; &quot;com/mycompany/defaults.properties&quot;);</script> + <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">pc.setLocations(&quot;com/mycompany/override.properties;optional=true,com/mycompany/defaults.properties&quot;);</script> </div> </div> <p> </p> @@ -18240,28 +18246,27 @@ cometds://localhost:8443/service/mychann <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">location=file:${env:APP_HOME}/etc/foo.properties </script> </div> - </div><p>Where <strong><code>APP_HOME</code></strong> is an OS environment.</p><p>You can have multiple placeholders in the same location, such as:</p> + </div><p>Where <strong><code>APP_HOME</code></strong> is an OS environment variable.</p><p>You can have multiple placeholders in the same location, such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">location=file:${env:APP_HOME}/etc/${prop.name}.properties </script> </div> - </div><h4 id="BookInOnePage-UsingSystemandEnvironmentVariablestoConfigurePropertyPrefixesandSuffixes">Using System and Environment Variables to Configure Property Prefixes and Suffixes</h4><p><strong>Available as of Camel 2.12.5, 2.13.3, 2.14.0</strong></p><p><strong><code>propertyPrefix</code></strong>, <strong><code>propertySuffix</code></strong> configuration properties support using placeholders for JVM system properties and OS environments variables.</p><p>For example, if <strong><code>PropertiesComponent</code></strong> is configured with the following properties file:</p> - <div class="preformatted panel" style="border-width: 1px;"> - <div class="preformattedContent panelContent"> - <pre>dev.endpoint = result1 -test.endpoint = result2</pre> + </div><h4 id="BookInOnePage-UsingSystemorEnvironmentVariablestoConfigurePropertyPrefixesandSuffixes">Using System or Environment Variables to Configure Property Prefixes and Suffixes</h4><p>From<strong> Camel 2.12.5, 2.13.3, 2.14.0</strong>:<strong><code> propertyPrefix</code></strong>, <strong><code>propertySuffix</code></strong> configuration properties support the use of placeholders for de-referencing JVM system properties and OS environments variables.</p><p>Example:</p><p>Assume the <strong><code>PropertiesComponent</code></strong> is configured with the following properties file:</p> + <div class="code panel pdl" style="border-width: 1px;"> + <div class="codeContent panelContent pdl"> + <script class="brush: text; gutter: false; theme: Default" type="syntaxhighlighter">dev.endpoint = result1 test.endpoint = result2</script> </div> - </div><p>Then with the following route definition:</p> + </div><p>The same properties file is then referenced from a route definition:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">PropertiesComponent pc = context.getComponent(&quot;properties&quot;, PropertiesComponent.class); pc.setPropertyPrefix(&quot;${stage}.&quot;); // ... context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(&quot;direct:start&quot;) .to(&quot;properties:mock:{{endpoint}}&quot;); } });</script> </div> - </div><p>it is possible to change the target endpoint by changing system property <strong><code>stage</code></strong> either to <strong><code>dev</code></strong> (the message will be routed to <strong><code>mock:result1</code></strong>) or <strong><code>test</code></strong> (the message will be routed to <strong><code>mock:result2</code></strong>).</p><h3 id="BookInOnePage-ConfiguringinJavaDSL">Configuring in Java DSL</h3><p>You have to create and register the <strong><code>PropertiesComponent</code></strong> under the name <strong><code>properties</code></strong> such as:</p> + </div><p>By using the configuration options <strong><code>propertyPrefix</code></strong> it's possible to change the target endpoint simply by changing the value of the system property <strong><code>stage</code></strong> either to <strong><code>dev</code></strong> (the message will be routed to <strong><code>mock:result1</code></strong>) or <strong><code>test</code></strong> (the message will be routed to <strong><code>mock:result2</code></strong>).</p><h3 id="BookInOnePage-ConfiguringinJavaDSL">Configuring in Java DSL</h3><p>You have to create and register the <strong><code>PropertiesComponent</code></strong> under the name <strong><code>properties</code></strong> such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">PropertiesComponent pc = new PropertiesComponent(); pc.setLocation(&quot;classpath:com/mycompany/myprop.properties&quot;); context.addComponent(&quot;properties&quot;, pc); </script> </div> - </div><h3 id="BookInOnePage-ConfiguringinSpringXML.1">Configuring in Spring XML</h3><p>Spring XML offers two variations to configure. You can define a spring bean as a <strong><code>PropertiesComponent</code></strong> which resembles the way done in Java DSL. Or you can use the <strong><code><propertyPlaceholder></code></strong> tag.</p> + </div><h3 id="BookInOnePage-ConfiguringinSpringXML">Configuring in Spring XML</h3><p>Spring XML offers two variations to configure. You can define a spring bean as a <strong><code>PropertiesComponent</code></strong> which resembles the way done in Java DSL. Or you can use the <strong><code><propertyPlaceholder></code></strong> tag.</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;bean id=&quot;properties&quot; class=&quot;org.apache.camel.component.properties.PropertiesComponent&quot;&gt; &lt;property name=&quot;location&quot; value=&quot;classpath:com/mycompany/myprop.properties&quot;/&gt; &lt;/bean&gt; </script> @@ -18271,7 +18276,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;camelContext ...&gt; &lt;propertyPlaceholder id=&quot;properties&quot; location=&quot;com/mycompany/myprop.properties&quot;/&gt; &lt;/camelContext&gt; </script> </div> - </div><p><span>Setting the properties location through the location tag works just fine but sometime you have a number of resources to take into account and starting from </span><strong>Camel 2.19.0</strong><span> you can set the properties location with a dedicated propertiesLocation:</span></p> + </div><p><span>Setting the properties location through the location tag works just fine but sometime you have a number of resources to take into account and starting from </span><strong>Camel 2.19.0</strong><span> you can set the properties location with a dedicated <strong><code>propertiesLocation</code></strong>:</span></p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;camelContext ...&gt; &lt;propertyPlaceholder id=&quot;myPropertyPlaceholder&quot;&gt; &lt;propertiesLocation resolver = &quot;classpath&quot; path = &quot;com/my/company/something/my-properties-1.properties&quot; optional = &quot;false&quot;/&gt; &lt;propertiesLocation resolver = &quot;classpath&quot; path = &quot;com/my/company/something/my-properties-2.properties&quot; optional = &quot;false&quot;/&gt; &lt;propertiesLocation resolver = &quot;file&quot; path = &quot;${karaf.home}/etc/my-override.properties&quot; optional = &quot;true&quot;/&gt; &lt;/propertyPlaceholder&gt; &lt;/camelContext&gt;</script> @@ -18298,7 +18303,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">// properties cool.foo=result // route from(&quot;direct:start&quot;) .to(&quot;properties:mock:{{cool.foo}}&quot;); </script> </div> - </div><p>In the example above the to endpoint will be resolved to <code>mock:result</code>.</p><p>You can also have properties with refer to each other such as:</p> + </div><p>In the example above the to endpoint will be resolved to <strong><code>mock:result</code></strong>.</p><p>You can also have properties with refer to each other such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">// properties cool.foo=result cool.concat=mock:{{cool.foo}} // route from(&quot;direct:start&quot;) .to(&quot;properties:mock:{{cool.concat}}&quot;); </script> @@ -18407,7 +18412,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"> @Override protected String useOverridePropertiesWithConfigAdmin(Dictionary props) { // add the properties we want to override props.put(&quot;greeting&quot;, &quot;Bye&quot;); // return the PID of the config-admin we are using in the blueprint xml file return &quot;my-placeholders&quot;; } </script> </div> - </div> <p>To do this we override and implement the <strong><code>useOverridePropertiesWithConfigAdmin</code></strong> method. We can then put the properties we want to override on the given props parameter. And the return value <em>must</em> be the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag, which you define in the blueprint XML file.</p><h4 id="BookInOnePage-Usinga.cfgor.propertiesFileforBlueprintPropertyPlaceholders">Using a <code>.cfg</code> or <code>.properties</code> File for Blueprint Property Placeholders</h4><p><strong>Available as of Camel 2.10.4</strong></p><p>When using Blueprint property placeholder in the Blueprint XML file, you can declare the properties in a .properties or <strong><code>.cfg</code></strong> file. If you use Apache ServieMix/Karaf then this container has a convention that it loads the properties from a file in the etc directory with the naming <strong><code>etc/pid.cfg</code></strong>, where <strong><code>pid</code></strong> is the persistence-id.</p><p>For example in the blueprint XML file we have the <strong><code>persistence-id="stuff"</code></strong>, which mean it will load the configuration file as <strong><code>etc/stuff.cfg</code></strong>. + </div> <p>To do this we override and implement the <strong><code>useOverridePropertiesWithConfigAdmin</code></strong> method. We can then put the properties we want to override on the given props parameter. And the return value <em>must</em> be the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag, which you define in the blueprint XML file.</p><h4 id="BookInOnePage-Usinga.cfgor.propertiesFileforBlueprintPropertyPlaceholders">Using a <code>.cfg</code> or <code>.properties</code> File for Blueprint Property Placeholders</h4><p><strong>Available as of Camel 2.10.4</strong></p><p>When using Blueprint property placeholder in the Blueprint XML file, you can declare the properties in a .properties or <strong><code>.cfg</code></strong> file. If you use Apache ServiceMix/Karaf then this container has a convention that it loads the properties from a file in the etc directory with the naming <strong><code>etc/pid.cfg</code></strong>, where <strong><code>pid</code></strong> is the persistence-id.</p><p>For example in the blueprint XML file we have the <strong><code>persistence-id="stuff"</code></strong>, which mean it will load the configuration file as <strong><code>etc/stuff.cfg</code></strong>. </p><div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"> &lt;!-- blueprint property placeholders, that will use etc/stuff.cfg as the properties file --&gt; &lt;cm:property-placeholder persistent-id=&quot;stuff&quot; update-strategy=&quot;reload&quot;/&gt; &lt;!-- a bean that uses a blueprint property placeholder --&gt; &lt;bean id=&quot;myCoolBean&quot; class=&quot;org.apache.camel.test.blueprint.MyCoolBean&quot;&gt; &lt;property name=&quot;say&quot; value=&quot;${greeting}&quot;/&gt; &lt;/bean&gt; &lt;camelContext xmlns=&quot;http://camel.apache.org/schema/blueprint&quot;&gt; &lt;route&gt; &lt;from uri=&quot;direct:start&quot;/&gt; &lt;bean ref=&quot;myCoolBean&quot; method=&quot;saySomething&quot;/&gt; &lt;to uri=&quot;mock:result&quot;/&gt; &lt;/route&gt; &lt;/came lContext&gt; </script> @@ -18417,7 +18422,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"> @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[]{&quot;src/test/resources/etc/stuff.cfg&quot;, &quot;stuff&quot;}; } </script> </div> - </div> <p>Notice that this method requires to return a <strong><code>String[]</code></strong> with 2 values. The 1st value is the path for the configuration file to load. The 2nd value is the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag.</p><p>The <strong><code>stuff.cfg</code></strong> file is just a plain properties file with the property placeholders such as:</p> + </div> <p>Notice that this method requires to return a <strong><code>String[]</code></strong> with 2 values. The 1st value is the path for the configuration file to load. The second value is the persistence-id of the <strong><code><cm:property-placeholder></code></strong> tag.</p><p>The <strong><code>stuff.cfg</code></strong> file is just a plain properties file with the property placeholders such as:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">## this is a comment greeting=Bye </script> @@ -18437,7 +18442,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">greeting=Bye echo=Yay destination=mock:result </script> </div> - </div><h3 id="BookInOnePage-BridgingSpringandCamelPropertyPlaceholders">Bridging Spring and Camel Property Placeholders</h3><p><strong>Available as of Camel 2.10</strong></p><p>The Spring Framework does not allow 3rd party frameworks such as Apache Camel to seamless hook into the Spring property placeholder mechanism. However you can easily bridge Spring and Camel by declaring a Spring bean with the type <strong><code>org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer</code></strong>, which is a Spring <strong><code>org.springframework.beans.factory.config.PropertyPlaceholderConfigurer</code></strong> type.</p><p>To bridge Spring and Camel you must define a single bean as shown below: + </div><h3 id="BookInOnePage-BridgingSpringandCamelPropertyPlaceholders">Bridging Spring and Camel Property Placeholders</h3><p><strong>Available as of Camel 2.10</strong></p><p>The Spring Framework does not allow third-party frameworks such as Apache Camel to seamless hook into the Spring property placeholder mechanism. However you can easily bridge Spring and Camel by declaring a Spring bean with the type <strong><code>org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer</code></strong>, which is a Spring <strong><code>org.springframework.beans.factory.config.PropertyPlaceholderConfigurer</code></strong> type.</p><p>To bridge Spring and Camel you must define a single bean as shown below: </p><div class="code panel pdl" style="border-width: 1px;"> <div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"> <b>Bridging Spring and Camel property placeholders</b> @@ -18472,7 +18477,7 @@ test.endpoint = result2</pre> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"> // override this method to provide our custom properties we use in this unit test @Override protected Properties useOverridePropertiesWithPropertiesComponent() { Properties extra = new Properties(); extra.put(&quot;destination&quot;, &quot;mock:extra&quot;); extra.put(&quot;greeting&quot;, &quot;Bye&quot;); return extra; } </script> </div> - </div> <p>This can be done from any of the Camel Test kits, such as <code>camel-test</code>, <code>camel-test-spring</code> and <code>camel-test-blueprint</code>.</p><p>The <strong><code>ignoreMissingLocationWithPropertiesComponent</code></strong> can be used to instruct Camel to ignore any locations which was not discoverable. For example if you run the unit test, in an environment that does not have access to the location of the properties.</p><h3 id="BookInOnePage-Using@PropertyInject">Using <code>@PropertyInject</code></h3><p><strong>Available as of Camel 2.12</strong></p><p>Camel allows to inject property placeholders in POJOs using the <strong><code>@PropertyInject</code></strong> annotation which can be set on fields and setter methods. For example you can use that with <strong><code>RouteBuilder</code></strong> classes, such as shown below:</p> + </div> <p>This can be done from any of the Camel Test kits, such as <strong><code>camel-test</code></strong>, <strong><code>camel-test-spring</code></strong> and <strong><code>camel-test-blueprint</code></strong>.</p><p>The <strong><code>ignoreMissingLocationWithPropertiesComponent</code></strong> can be used to instruct Camel to ignore any locations which was not discoverable. For example if you run the unit test, in an environment that does not have access to the location of the properties.</p><h3 id="BookInOnePage-Using@PropertyInject">Using <code>@PropertyInject</code></h3><p><strong>Available as of Camel 2.12</strong></p><p>Camel allows to inject property placeholders in POJOs using the <strong><code>@PropertyInject</code></strong> annotation which can be set on fields and setter methods. For example you can use that with <strong><code>RouteBuilder</code></strong> classes, such as shown below:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">public class MyRouteBuilder extends RouteBuilder { @PropertyInject(&quot;hello&quot;) private String greeting; @Override public void configure() throws Exception { from(&quot;direct:start&quot;) .transform().constant(greeting) .to(&quot;{{result}}&quot;); } } </script> @@ -18488,7 +18493,7 @@ test.endpoint = result2</pre> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter">@PropertyInject(value = &quot;myTimeout&quot;, defaultValue = &quot;5000&quot;) private int timeout; </script> </div> </div><h3 id="BookInOnePage-UsingOutoftheBoxFunctions">Using Out of the Box Functions</h3><p><strong>Available as of Camel 2.14.1</strong></p><p>The <a shape="rect" href="properties.html">Properties</a> component includes the following functions out of the box</p> - <ul><li><code>env</code> - A function to lookup the property from OS environment variables.</li><li><code>sys</code> - A function to lookup the property from Java JVM system properties.</li><li><code>service</code> - A function to lookup the property from OS environment variables using the service naming idiom.</li><li><code>service.host</code> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the hostname part only.</li><li><code>service.port</code> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the port part only.</li></ul><p>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:</p> + <ul><li><strong><code>env</code></strong> - A function to lookup the property from OS environment variables.</li><li><strong><code>sys</code></strong> - A function to lookup the property from Java JVM system properties.</li><li><strong><code>service</code></strong> - A function to lookup the property from OS environment variables using the service naming idiom.</li><li><strong><code>service.host</code></strong> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the hostname part only.</li><li><strong><code>service.port</code></strong> - <strong>Camel 2.16.1: </strong>A function to lookup the property from OS environment variables using the service naming idiom returning the port part only.</li></ul><p>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:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter">&lt;camelContext xmlns=&quot;http://camel.apache.org/schema/blueprint&quot;&gt; &lt;route&gt; &lt;from uri=&quot;direct:start&quot;/&gt; &lt;to uri=&quot;{{env:SOMENAME}}&quot;/&gt; &lt;to uri=&quot;{{sys:MyJvmPropertyName}}&quot;/&gt; &lt;/route&gt; &lt;/camelContext&gt;</script> Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available.