Author: buildbot
Date: Thu Sep 8 16:19:03 2016
New Revision: 996964
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 Thu Sep 8
16:19:03 2016
@@ -1042,11 +1042,11 @@ template.send("direct:alias-verify&
]]></script>
</div></div><p></p><h3 id="BookComponentAppendix-SeeAlso.8">See Also</h3>
<ul><li><a shape="rect" href="configuring-camel.html">Configuring
Camel</a></li><li><a shape="rect"
href="component.html">Component</a></li><li><a shape="rect"
href="endpoint.html">Endpoint</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li></ul><ul><li><a
shape="rect" href="crypto.html">Crypto</a> Crypto is also available as a <a
shape="rect" href="data-format.html">Data Format</a></li></ul> <h2
id="BookComponentAppendix-CXFComponent">CXF Component</h2><div
class="confluence-information-macro confluence-information-macro-note"><span
class="aui-icon aui-icon-small aui-iconfont-warning
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>When using CXF as a consumer, the
<a shape="rect" href="cxf-bean-component.html">CXF Bean Component</a> allows
you to factor out how message payloads are received from their processing as a
RESTful or SOAP web service. This has the potential of using a multitude of
transports to cons
ume web services. The bean component's configuration is also simpler and
provides the fastest method to implement web services using Camel and
CXF.</p></div></div><div class="confluence-information-macro
confluence-information-macro-tip"><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><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">/*<![CDATA[*/
-div.rbtoc1473347896066 {padding: 0px;}
-div.rbtoc1473347896066 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1473347896066 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1473351453650 {padding: 0px;}
+div.rbtoc1473351453650 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1473351453650 li {margin-left: 0px;padding-left: 0px;}
-/*]]>*/</style></p><div class="toc-macro rbtoc1473347896066">
+/*]]>*/</style></p><div class="toc-macro rbtoc1473351453650">
<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>
@@ -7901,62 +7901,66 @@ lpr://remotehost:port/path/to/printer[?o
</div></div> <h2 id="BookComponentAppendix-PropertiesComponent">Properties
Component</h2><p><strong>Available as of Camel 2.3</strong></p><h3
id="BookComponentAppendix-URIformat.53">URI format</h3><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[properties:key[?options]
]]></script>
-</div></div><p>Where <strong><code>key</code></strong> is the key for the
property to be looked up.</p><h3
id="BookComponentAppendix-Options.40">Options</h3><div
class="confluenceTableSmall"><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>cache</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>boolean</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Whether or not to cache loaded
properties.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>encoding</code></p></td><td colspan="1"
rowspan="1" c
lass="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.14.3/2.15.1:</strong> To use a specific
charset to load the properties, such as UTF-8. By
default <code>ISO-8859-1</code> (<code>latin1</code>) is
used.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>fallbackToUnaugmentedProperty</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9</strong> If
<strong><code>true</code></strong>, first attempt resolution of property name
augmented with <strong><code>propertyPrefix</code></strong> and
<strong><code>propertySuffix</code></strong> before falling back the plain
property name specified.</p><p>If <strong><code>false</code></st
rong>, only the augmented property name is searched.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>ignoreMissingLocation</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Whether to
silently ignore if a location cannot be located, such as a properties file not
found.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>locations</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A list of locations to load properties. You
can use comma to separate multiple locations. This option will override any
default locations and <strong>only</strong> use the locations fr
om this option.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>prefixToken</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>{{</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9</strong> The token to
indicate the beginning of a property token.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>propertyPrefix</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9</strong>
Optional prefix prepended to property names before
resolution.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>propertySuffix</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></
td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.9</strong> Optional suffix appended to
property names before resolution.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>suffixToken</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>}}<br
clear="none"></code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.9</strong> The token to indicate the
end of a property token.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>systemPropertiesMode</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>int</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>2</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.16</strong> The
mode to use for whether
to resolve and use system
properties:</p><p><strong><code>0</code></strong> = never - JVM system
properties are never used.<br
clear="none"><strong><code>1</code></strong> = fallback - JVM system
properties are only used as fallback if no regular property with the key
exists.<br clear="none"><strong><code>2</code></strong> = override - JVM
system properties are used if exists, otherwise the regular property will be
used.</p><p><strong>Note</strong>: when bridging this to Spring's property
placeholder with
<strong><code>org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer</code></strong>
then the configuration on
<strong><code>BridgePropertyPlaceholderConfigurer</code></strong> takes
precedence over the configuration on the
<strong><code>PropertiesComponent</code></strong>. </p></td></tr></tbody></table></div></div><div
class="confluence-information-macro confluence-information-macro-tip"><p
class="title">Resolving property from Java code</p><span clas
s="aui-icon aui-icon-small aui-iconfont-approve
confluence-information-macro-icon"></span><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
PropertyPlaceholder</h2><p><strong>Available as of Camel
2.3</strong></p><p>Camel now provides a new <code>PropertiesComponent</code> in
<strong>camel-core</strong> which allows you to use property placeholders when
defining Camel <a shape="rect" href="endpoint.html">Endpoint</a> URIs. <br
clear="none"> This works much like you would do if using Spring's
<code><property-placeholder></code> tag. However Spring have a limitation
which prevents 3rd party frameworks to leverage Spring property placeholders to
the fullest. See more at <a shape="rect"
href="how-do-i-use-spring-property-placeho
lder-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 Camel 2.10 onwards, you can
bridge the Spring property placeholder with Camel, see further below for more
details.</p></div></div><p>The property placeholder is generally in use when
doing:</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 PropertyPlaceholder with Camel
<a shape="rect" href="properties.html">Properties</a> component</li><li>using
<code>@PropertyInject</code> to inject a property in a POJO</li><li><strong>Came
l 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 {{<code>key</code>}} for example
{{<code>file.uri</code>}} where <code>file.uri</code> is the property key.<br
clear="none"> 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> onwards you can specify a
default value to use if a property with the key does not exists,
eg <code>file.url:/some/path</code> where the default value is the text
after the colon (eg /some/path).</p><div class="co
nfluence-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>Do not use colon in the property
key. The colon is used as a separator token when you are providing a default
value, which is supported from <strong>Camel 2.14.1</strong>
onwards.</p></div></div><h3
id="BookComponentAppendix-PropertyResolver">PropertyResolver</h3><p>Camel
provides a pluggable mechanism which allows 3rd part to provide their own
resolver to lookup properties. Camel provides a default implementation
<code>org.apache.camel.component.properties.DefaultPropertiesResolver</code>
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><code>ref:</code> <strong>Camel
2.4:</strong> to lookup in the <a shape="rect" href="regis
try.html">Registry</a></li><li><code>file:</code> to load the from file
system</li><li><code>classpath:</code> to load from classpath (this is also the
default if no prefix is provided)</li><li><code>blueprint:</code> <strong>Camel
2.7:</strong> to use a specific OSGi blueprint placeholder service</li></ul><h3
id="BookComponentAppendix-Defininglocation">Defining location</h3><p>The
<code>PropertiesResolver</code> 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 class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>Where <strong><code>key</code></strong> is the key for the
property to be looked up.</p><h3
id="BookComponentAppendix-Options.40">Options</h3><div
class="confluenceTableSmall"><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>cache</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>boolean</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Whether or not to cache loaded
properties.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>encoding</code></p></td><td colspan="1"
rowspan="1" c
lass="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.14.3/2.15.1:</strong> To use a specific
charset to load the properties, such as UTF-8. By
default <code>ISO-8859-1</code> (<code>latin1</code>) is
used.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>fallbackToUnaugmentedProperty</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9</strong> If
<strong><code>true</code></strong>, first attempt resolution of property name
augmented with <strong><code>propertyPrefix</code></strong> and
<strong><code>propertySuffix</code></strong> before falling back the plain
property name specified.</p><p>If <strong><code>false</code></st
rong>, only the augmented property name is searched.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>ignoreMissingLocation</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Whether to
silently ignore if a location cannot be located, such as a properties file not
found.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>locations</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A list of locations to load properties. You
can use comma to separate multiple locations. This option will override any
default locations and <strong>only</strong> use the locations fr
om this option.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>prefixToken</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>{{</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9</strong> The token to
indicate the beginning of a property token.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>propertyPrefix</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9</strong>
Optional prefix prepended to property names before
resolution.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>propertySuffix</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></
td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.9</strong> Optional suffix appended to
property names before resolution.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>suffixToken</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>}}<br
clear="none"></code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.9</strong> The token to indicate the
end of a property token.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>systemPropertiesMode</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>int</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>2</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.16</strong> The
mode to use for whether
to resolve and use system
properties:</p><p><strong><code>0</code></strong> = never - JVM system
properties are never used.<br
clear="none"><strong><code>1</code></strong> = fallback - JVM system
properties are only used as fallback if no regular property with the key
exists.<br clear="none"><strong><code>2</code></strong> = override - JVM
system properties are used if exists, otherwise the regular property will be
used.</p><p><strong>Note</strong>: when bridging to Spring's property
placeholder using
<strong><code>org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer</code></strong>
the configuration on
<strong><code>BridgePropertyPlaceholderConfigurer</code></strong> will take
precedence over the configuration on the
<strong><code>PropertiesComponent</code></strong>. </p></td></tr></tbody></table></div></div><div
class="confluence-information-macro confluence-information-macro-tip"><p
class="title">Resolving property from Java code</p><span class="au
i-icon aui-icon-small aui-iconfont-approve
confluence-information-macro-icon"></span><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
have a limitation which prevents 3rd party frameworks to leverage Spring
property placeholders to the fullest.</p><p>For more details see: <a shape="rec
t" 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:</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>u
sing <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 exis
ts, 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 class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[pc.setLocation("com/mycompany/myprop.properties,com/mycompany/other.properties");
]]></script>
-</div></div><h4
id="BookComponentAppendix-Usingsystemandenvironmentvariablesinlocations">Using
system and environment variables in locations</h4><p><strong>Available as of
Camel 2.7</strong></p><p>The location now supports using placeholders for JVM
system properties and OS environments variables.</p><p>For example:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h4
id="BookComponentAppendix-UsingSystemandEnvironmentVariablesinLocations">Using
System and Environment Variables in Locations</h4><p><strong>Available as of
Camel 2.7</strong></p><p>The location now supports using placeholders for JVM
system properties and OS environments variables.</p><p>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"><![CDATA[location=file:${karaf.home}/etc/foo.properties
]]></script>
-</div></div><p>In the location above we defined a location using the file
scheme using the JVM system property with key <code>karaf.home</code>.</p><p>To
use an OS environment variable instead you would have to prefix with
env:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>In the location above we defined a location using the file
scheme using the JVM system property with key
<strong><code>karaf.home</code></strong>.</p><p>To use an OS environment
variable instead you would have to prefix with
<strong><code>env</code></strong>:</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"><![CDATA[location=file:${env:APP_HOME}/etc/foo.properties
]]></script>
-</div></div><p>Where <code>APP_HOME</code> is an OS environment.</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">
+</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 class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[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><code>propertyPrefix</code>, <code>propertySuffix</code>
configuration properties support using placeholders for JVM system properties
and OS environments variables.</p><p>For example.
if <code>PropertiesComponent</code> is configured with the following
properties file:</p><div class="preformatted panel" style="border-width:
1px;"><div class="preformattedContent panelContent">
+</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></div><p>Then with the following 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"><![CDATA[PropertiesComponent pc =
context.getComponent("properties", PropertiesComponent.class);
pc.setPropertyPrefix("${stage}.");
+
// ...
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("direct:start").to("properties:mock:{{endpoint}}");
+ from("direct:start")
+ .to("properties:mock:{{endpoint}}");
}
});]]></script>
-</div></div><p>it is possible to change the target endpoint by changing system
property <code>stage</code> either to <code>dev</code> (the message
will be routed to <code>mock:result1</code>) or <code>test</code>
(the message will be routed to <code>mock:result2</code>).</p><h3
id="BookComponentAppendix-ConfiguringinJavaDSL">Configuring in Java
DSL</h3><p>You have to create and register the <code>PropertiesComponent</code>
under the name <code>properties</code> such as:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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 class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[PropertiesComponent pc = new
PropertiesComponent();
pc.setLocation("classpath:com/mycompany/myprop.properties");
context.addComponent("properties", pc);
]]></script>
-</div></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 <code>PropertiesComponent</code> which resembles the
way done in Java DSL. Or you can use the
<code><propertyPlaceholder></code> tag.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></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"><![CDATA[<bean id="properties"
class="org.apache.camel.component.properties.PropertiesComponent">
<property name="location"
value="classpath:com/mycompany/myprop.properties"/>
</bean>
]]></script>
-</div></div><p>Using the <code><propertyPlaceholder></code> tag makes
the configuration a bit more fresh such as:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Using the
<strong><code><propertyPlaceholder></code></strong> tag makes the
configuration a bit more fresh such as:</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"><![CDATA[<camelContext ...>
<propertyPlaceholder id="properties"
location="com/mycompany/myprop.properties"/>
</camelContext>
]]></script>
-</div></div><div class="confluence-information-macro
confluence-information-macro-tip"><p class="title">Specifying the cache option
inside XML</p><span class="aui-icon aui-icon-small aui-iconfont-approve
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Camel 2.10 onwards supports
specifying a value for the cache option both inside the Spring as well as the
Blueprint XML.</p></div></div><h3
id="BookComponentAppendix-UsingaPropertiesfromthe">Using a Properties from the
<a shape="rect" href="registry.html">Registry</a></h3><p><strong>Available as
of Camel 2.4</strong><br clear="none"> For example in OSGi you may want to
expose a service which returns the properties as a
<code>java.util.Properties</code> object.</p><p>Then you could setup the <a
shape="rect" href="properties.html">Properties</a> component as
follows:</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"><![CDATA[ <propertyPlaceholder
id="properties" location="ref:myProperties"/>
+</div></div><div class="confluence-information-macro
confluence-information-macro-tip"><p class="title">Specifying the cache option
in XML</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>:
Camel supports specifying a value for
the <strong><code>cache</code></strong> option both inside the Spring as
well as the Blueprint XML.</p></div></div><h3
id="BookComponentAppendix-UsingaPropertiesfromthe">Using a Properties from the
<a shape="rect" href="registry.html">Registry</a></h3><p><strong>Available as
of Camel 2.4</strong><br clear="none"> For example in OSGi you may want to
expose a service which returns the properties as a
<strong><code>java.util.Properties</code></strong> object.</p><p>Then you could
setup the <a shape="rect" href="properties.html">Properties</a> component as
follows:</p><div class="code panel pdl" style="border-width: 1px;"><d
iv class="codeContent panelContent pdl">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<propertyPlaceholder
id="properties" location="ref:myProperties"/>
]]></script>
-</div></div><p>Where <code>myProperties</code> is the id to use for lookup in
the OSGi registry. Notice we use the <code>ref:</code> prefix to tell Camel
that it should lookup the properties for the <a shape="rect"
href="registry.html">Registry</a>.</p><h3
id="BookComponentAppendix-Examplesusingpropertiescomponent">Examples using
properties component</h3><p>When using property placeholders in the endpoint
URIs you can either use the <code>properties:</code> component or define the
placeholders directly in the URI. We will show example of both cases, starting
with the former.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>Where <strong><code>myProperties</code></strong> is the id to
use for lookup in the OSGi registry. Notice we use the
<strong><code>ref:</code></strong> prefix to tell Camel that it should lookup
the properties for the <a shape="rect"
href="registry.html">Registry</a>.</p><h3
id="BookComponentAppendix-ExamplesUsingPropertiesComponent">Examples Using
Properties Component</h3><p>When using property placeholders in the endpoint
URIs you can either use the <strong><code>properties:</code></strong> component
or define the placeholders directly in the URI. We will show example of both
cases, starting with the former.</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"><![CDATA[// properties
cool.end=mock:result
// route
-from("direct:start").to("properties:{{cool.end}}");
+from("direct:start")
+ .to("properties:{{cool.end}}");
]]></script>
-</div></div><p>You can also use placeholders as a part of the endpoint
uri:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>You can also use placeholders as a part of the endpoint
URI:</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"><![CDATA[// properties
cool.foo=result
// route
-from("direct:start").to("properties:mock:{{cool.foo}}");
+from("direct:start")
+ .to("properties:mock:{{cool.foo}}");
]]></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 class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[// properties
@@ -7964,17 +7968,20 @@ cool.foo=result
cool.concat=mock:{{cool.foo}}
// route
-from("direct:start").to("properties:mock:{{cool.concat}}");
+from("direct:start")
+ .to("properties:mock:{{cool.concat}}");
]]></script>
-</div></div><p>Notice how <code>cool.concat</code> refer to another
property.</p><p>The <code>properties:</code> component also offers you to
override and provide a location in the given uri using the
<code>locations</code> option:</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"><![CDATA[
from("direct:start").to("properties:bar.end?locations=com/mycompany/bar.properties");
+</div></div><p>Notice how <strong><code>cool.concat</code></strong> refer to
another property.</p><p>The <strong><code>properties:</code></strong> component
also offers you to override and provide a location in the given URI using the
<strong><code>locations</code></strong> option:</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"><![CDATA[from("direct:start")
+ .to("properties:bar.end?locations=com/mycompany/bar.properties");
]]></script>
-</div></div><h3 id="BookComponentAppendix-Examples.12">Examples</h3><p>You can
also use property placeholders directly in the endpoint uris without having to
use <code>properties:</code>.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="BookComponentAppendix-Examples.12">Examples</h3><p>You can
also use property placeholders directly in the endpoint URIs without having to
use <strong><code>properties:</code></strong>.</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"><![CDATA[// properties
cool.foo=result
// route
-from("direct:start").to("mock:{{cool.foo}}");
+from("direct:start")
+ .to("mock:{{cool.foo}}");
]]></script>
</div></div><p>And you can use them in multiple wherever you want
them:</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"><![CDATA[// properties
@@ -8006,7 +8013,7 @@ bar.quote=Beer tastes good
from("direct:start")
.transform().simple("Hi ${body}.
${properties:com/mycompany/bar.properties:bar.quote}.");
]]></script>
-</div></div><h3
id="BookComponentAppendix-AdditionalpropertyplaceholdersupportedinSpringXML">Additional
property placeholder supported in Spring XML</h3><p>The property placeholders
is also supported in many of the Camel Spring XML tags such as
<code><package>, <packageScan>, <contextScan>,
<jmxAgent>, <endpoint>, <routeBuilder>, <proxy></code>
and the others.</p><p>The example below has property placeholder in the
<jmxAgent> tag:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><h3
id="BookComponentAppendix-AdditionalPropertyPlaceholderSupportinSpringXML">Additional
Property Placeholder Support in Spring XML</h3><p>The property placeholders is
also supported in many of the Camel Spring XML tags such as
<code><strong><package></strong>, <strong><packageScan></strong>,
<strong><contextScan></strong>, <strong><jmxAgent></strong>,
<strong><endpoint></strong>, <strong><routeBuilder></strong>,
<strong><proxy></strong></code> and the others.</p><p>The example below
has property placeholder in
the <strong><code><jmxAgent></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"><![CDATA[<camelContext
xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties"
location="org/apache/camel/spring/jmx.properties"/>
@@ -8021,9 +8028,8 @@ from("direct:start")
<from uri="seda:start"/>
<to uri="mock:result"/>
</route>
-
</camelContext>]]></script>
-</div></div><p>You can also define property placeholders in the various
attributes on the <camelContext> tag such as <code>trace</code> as shown
here:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>You can also define property placeholders in the various
attributes on the <strong><code><camelContext></code></strong> tag
such as <strong><code>trace</code></strong> as shown here:</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"><![CDATA[<camelContext
trace="{{foo.trace}}"
xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties"
location="org/apache/camel/spring/processor/myprop.properties"/>
@@ -8037,7 +8043,7 @@ from("direct:start")
<to uri="mock:result"/>
</route>
</camelContext>]]></script>
-</div></div><h3
id="BookComponentAppendix-OverridingapropertysettingusingaJVMSystemProperty">Overriding
a property setting using a JVM System Property</h3><p><strong>Available as of
Camel 2.5</strong><br clear="none"> It is possible to override a property value
at runtime using a JVM System property without the need to restart the
application to pick up the change. This may also be accomplished from the
command line by creating a JVM System property of the same name as the property
it replaces with a new value. An example of this is given below</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h3
id="BookComponentAppendix-OverridingaPropertySettingUsingaJVMSystemProperty">Overriding
a Property Setting Using a JVM System Property</h3><p><strong>Available as of
Camel 2.5</strong><br clear="none"> It is possible to override a property value
at runtime using a JVM System property without the need to restart the
application to pick up the change. This may also be accomplished from the
command line by creating a JVM System property of the same name as the property
it replaces with a new value.</p><p>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"><![CDATA[PropertiesComponent pc =
context.getComponent("properties", PropertiesComponent.class);
pc.setCache(false);
@@ -8063,7 +8069,7 @@ System.clearProperty("cool.result&q
assertMockEndpointsSatisfied();
]]></script>
-</div></div><h3
id="BookComponentAppendix-UsingpropertyplaceholdersforanykindofattributeintheXMLDSL">Using
property placeholders for any kind of attribute in the XML
DSL</h3><p><strong>Available as of Camel 2.7</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>If you use OSGi Blueprint then
this only works from <strong>2.11.1</strong> or <strong>2.10.5</strong>
onwards.</p></div></div><p>Previously it was only the <code>xs:string</code>
type attributes in the XML DSL that support placeholders. For example often a
timeout attribute would be a <code>xs:int</code> type and thus you cannot set a
string value as the placeholder key. This is now possible from Camel 2.7
onwards using a special placeholder namespace.</p><p>In the example below we
use the <code>prop</code> prefix for the namespace <code
><a shape="rect" class="external-link"
>href="http://camel.apache.org/schema/placeholder">http://camel.apache.org/schema/placeholder</a></code>
> by which we can use the <code>prop</code> prefix in the attributes in the
>XML DSLs. Notice how we use that in the <a shape="rect"
>href="multicast.html">Multicast</a> to indicate that the option
><code>stopOnException</code> should be the value of the placeholder with the
>key "stop".</p><div class="code panel pdl" style="border-width: 1px;"><div
>class="codeContent panelContent pdl">
+</div></div><h3
id="BookComponentAppendix-UsingPropertyPlaceholdersforAnyKindofAttributeintheXMLDSL">Using
Property Placeholders for Any Kind of Attribute in the XML
DSL</h3><p><strong>Available as of Camel 2.7</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>If you use OSGi Blueprint then
this only works from <strong>2.11.1</strong> or <strong>2.10.5</strong>
on.</p></div></div><p>Previously it was only the
<strong><code>xs:string</code></strong> type attributes in the XML DSL that
support placeholders. For example often a timeout attribute would be a
<strong><code>xs:int</code></strong> type and thus you cannot set a string
value as the placeholder key. This is now possible from Camel 2.7 on using a
special placeholder namespace.</p><p>In the example below we use the
<code>prop</code> prefix
for the namespace <code><a shape="rect" class="external-link"
href="http://camel.apache.org/schema/placeholder">http://camel.apache.org/schema/placeholder</a></code>
by which we can use the <strong><code>prop</code></strong> prefix in the
attributes in the XML DSLs. Notice how we use that in the <a shape="rect"
href="multicast.html">Multicast</a> to indicate that the option
<strong><code>stopOnException</code></strong> should be the value of the
placeholder with the key <strong><code>stop</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"><![CDATA[<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:prop="http://camel.apache.org/schema/placeholder"
@@ -8094,20 +8100,21 @@ assertMockEndpointsSatisfied();
<to uri="mock:b"/>
</multicast>
</route>
-
</camelContext>
-
</beans>]]></script>
</div></div><p>In our properties file we have the value defined 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"><![CDATA[stop=true
]]></script>
-</div></div><h3
id="BookComponentAppendix-UsingpropertyplaceholderintheJavaDSL">Using property
placeholder in the Java DSL</h3><p><strong>Available as of Camel
2.7</strong></p><p>Likewise we have added support for defining placeholders in
the Java DSL using the new <code>placeholder</code> DSL as shown in the
following equivalent example:</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"><![CDATA[ from("direct:start")
- // use a property placeholder for the option
stopOnException on the Multicast EIP
- // which should have the value of {{stop}} key being
looked up in the properties file
- .multicast().placeholder("stopOnException",
"stop")
- .to("mock:a").throwException(new
IllegalAccessException("Damn")).to("mock:b");]]></script>
-</div></div><h3
id="BookComponentAppendix-UsingBlueprintpropertyplaceholderwithCamelroutes">Using
Blueprint property placeholder with Camel routes</h3><p><strong>Available as
of Camel 2.7</strong></p><p>Camel supports <a shape="rect"
href="using-osgi-blueprint-with-camel.html">Blueprint</a> which also offers a
property placeholder service. Camel supports convention over configuration, so
all you have to do is to define the OSGi Blueprint property placeholder in the
XML file as shown below:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><h3
id="BookComponentAppendix-UsingPropertyPlaceholderintheJavaDSL">Using Property
Placeholder in the Java DSL</h3><p><strong>Available as of Camel
2.7</strong></p><p>Likewise we have added support for defining placeholders in
the Java DSL using the new <strong><code>placeholder</code></strong> DSL as
shown in the following equivalent 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"><![CDATA[from("direct:start")
+ // use a property placeholder for the option stopOnException on the
Multicast EIP
+ // which should have the value of {{stop}} key being looked up in the
properties file
+ .multicast()
+ .placeholder("stopOnException", "stop")
+ .to("mock:a")
+ .throwException(new IllegalAccessException("Damn"))
+ .to("mock:b");]]></script>
+</div></div><h3
id="BookComponentAppendix-UsingBlueprintPropertyPlaceholderwithCamelRoutes">Using
Blueprint Property Placeholder with Camel Routes</h3><p><strong>Available as
of Camel 2.7</strong></p><p>Camel supports <a shape="rect"
href="using-osgi-blueprint-with-camel.html">Blueprint</a> which also offers a
property placeholder service. Camel supports convention over configuration, so
all you have to do is to define the OSGi Blueprint property placeholder in the
XML file 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"><![CDATA[<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
@@ -8132,7 +8139,7 @@ assertMockEndpointsSatisfied();
</route>
</camelContext>
</blueprint>]]></script>
-</div></div><p><span style="line-height: 1.42857;"><br
clear="none"></span></p><p><span style="line-height: 1.42857;">By default Camel
detects and uses OSGi blueprint property placeholder service. You can disable
this by setting the attribute </span><code style="line-height:
1.42857;">useBlueprintPropertyResolver</code><span style="line-height:
1.42857;"> to false on the </span><code style="line-height:
1.42857;"><camelContext></code><span style="line-height: 1.42857;">
definition.</span></p><div class="confluence-information-macro
confluence-information-macro-information"><p class="title">About placeholder
syntaxes</p><span class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Notice how we can use the Camel
syntax for placeholders {{ }} in the Camel route, which will lookup the value
from OSGi blueprint.<br clear="none"> The blueprint syntax for placeholders is
${ }. So outside the <cam
elContext> you must use the ${ } syntax. Where as inside
<camelContext> you must use {{ }} syntax.<br clear="none"> OSGi blueprint
allows you to configure the syntax, so you can actually align those if you
want.</p></div></div><p>You can also explicit refer to a specific OSGi
blueprint property placeholder by its id. For that you need to use the Camel's
<propertyPlaceholder> as shown in the example below:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p><span style="line-height: 1.42857;"><br
clear="none"></span></p><p><span style="line-height: 1.42857;">By default Camel
detects and uses OSGi blueprint property placeholder service. You can disable
this by setting the attribute </span><strong><code style="line-height:
1.42857;">useBlueprintPropertyResolver</code></strong><span style="line-height:
1.42857;"> to false on the </span><strong><code style="line-height:
1.42857;"><camelContext></code></strong><span style="line-height:
1.42857;"> definition.</span></p><div class="confluence-information-macro
confluence-information-macro-information"><p class="title">About placeholder
syntaxes</p><span class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Notice how we can use the Camel
syntax for placeholders <code><strong>{{</strong>
<strong>}}</strong></code> in the Camel route, which will lookup the value from
OSGi blueprint.<
br clear="none"> The blueprint syntax for placeholders is
<strong><code>${}</code></strong>. So outside
the <strong><code><camelContext></code></strong> you must use
the <strong><code>${}</code></strong> syntax. Where as
inside <strong><code><camelContext></code></strong> you must
use <code><strong>{{</strong> <strong>}}</strong></code> syntax. OSGi
blueprint allows you to configure the syntax, so you can actually align those
if you want.</p></div></div><p>You can also explicit refer to a specific OSGi
blueprint property placeholder by its id. For that you need to use the
Camel's <strong><code><propertyPlaceholder></code></strong> as shown
in the example 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"><![CDATA[<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
@@ -8161,10 +8168,10 @@ assertMockEndpointsSatisfied();
</route>
</camelContext>
</blueprint>]]></script>
-</div></div><p> </p><p>Notice how we use the <code>blueprint</code>
scheme to refer to the OSGi blueprint placeholder by its id. This allows you to
mix and match, for example you can also have additional schemes in the
location. For example to load a file from the classpath you can do:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p> </p><p>Notice how we use the
<strong><code>blueprint</code></strong> scheme to refer to the OSGi blueprint
placeholder by its id. This allows you to mix and match, for example you can
also have additional schemes in the location. For example to load a file from
the classpath you can do:</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"><![CDATA[location="blueprint:myblueprint.placeholder,classpath:myproperties.properties"
]]></script>
-</div></div><p>Each location is separated by comma.</p><h4
id="BookComponentAppendix-OverridingBlueprintpropertyplaceholdersoutsideCamelContext">Overriding
Blueprint property placeholders outside CamelContext</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 directly in the XML file
as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>Each location is separated by comma.</p><h4
id="BookComponentAppendix-OverridingBlueprintPropertyPlaceholdersOutsideCamelContext">Overriding
Blueprint Property Placeholders Outside CamelContext</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 directly in the XML file
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"><![CDATA[
<!-- blueprint property placeholders -->
<cm:property-placeholder persistent-id="my-placeholders"
update-strategy="reload">
@@ -8189,7 +8196,7 @@ assertMockEndpointsSatisfied();
</camelContext>
]]></script>
-</div></div>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 {{ }}
notation.<p>Now if you want to override these Blueprint properties from an unit
test, you can do this as shown below:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Notice that we have
a <strong><code><bean></code></strong> which refers to one of the
properties. And in the Camel route we refer to the other using
the <strong><code>{{ }}</code></strong> notation.<p>Now if you want to
override these Blueprint properties from an unit test, you can do this 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"><![CDATA[
@Override
protected String useOverridePropertiesWithConfigAdmin(Dictionary props) {
@@ -8200,7 +8207,7 @@ protected String useOverridePropertiesWi
return "my-placeholders";
}
]]></script>
-</div></div>To do this we override and implement the
<code>useOverridePropertiesWithConfigAdmin</code> method. We can then put the
properties we want to override on the given props parameter. And the return
value <strong>must</strong> be the persistence-id of the
<cm:property-placeholder> tag, which you define in the blueprint XML
file.<h4
id="BookComponentAppendix-Using.cfgor.propertiesfileforBlueprintpropertyplaceholders">Using
.cfg or .properties 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 .cfg 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 etc/pid.cfg, where pid is the
persistence-id.</p><p>For example in the blueprint XML file we have the
persistence-id="stuff", which mean it will load the c
onfiguration file as etc/stuff.cfg.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>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.<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></strong>, w
here <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"><![CDATA[
<!-- blueprint property placeholders, that will use etc/stuff.cfg as the
properties file -->
<cm:property-placeholder persistent-id="stuff"
update-strategy="reload"/>
@@ -8220,7 +8227,7 @@ protected String useOverridePropertiesWi
</camelContext>
]]></script>
-</div></div>Now if you want to unit test this blueprint XML file, then you can
override the <code>loadConfigAdminConfigurationFile</code> and tell Camel which
file to load as shown below:<div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div>Now if you want to unit test this blueprint XML file, then you can
override the <strong><code>loadConfigAdminConfigurationFile</code></strong> and
tell Camel which file to load as shown below:<div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
@Override
protected String[] loadConfigAdminConfigurationFile() {
@@ -8229,11 +8236,11 @@ protected String[] loadConfigAdminConfig
return new String[]{"src/test/resources/etc/stuff.cfg",
"stuff"};
}
]]></script>
-</div></div>Notice that this method requires to return a String[] with 2
values. The 1st value is the path for the configuration file to load.<br
clear="none"> The 2nd value is the persistence-id of the
<cm:property-placeholder> tag.<p>The stuff.cfg 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">
+</div></div>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>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"><![CDATA[## this is a comment
greeting=Bye
]]></script>
-</div></div><h4
id="BookComponentAppendix-Using.cfgfileandoverridingpropertiesforBlueprintpropertyplaceholders">Using
.cfg file and overriding properties for Blueprint property
placeholders</h4><p>You can do both as well. Here is a complete example. First
we have the Blueprint XML file:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h4
id="BookComponentAppendix-Usinga.cfgfileandOverridingPropertiesforBlueprintPropertyPlaceholders">Using
a <code>.cfg</code> file and Overriding Properties for Blueprint Property
Placeholders</h4><p>You can do both as well. Here is a complete example. First
we have the Blueprint XML file:</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"><![CDATA[
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -8316,12 +8323,12 @@ public class ConfigAdminLoadConfiguratio
}
]]></script>
-</div></div>And the <code>etc/stuff.cfg</code> configuration file contains<div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div>And the <strong><code>etc/stuff.cfg</code></strong> configuration
file contains:<div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[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
<code>org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer</code>,
which is a Spring
<code>org.springframework.beans.factory.config.PropertyPlaceholderConfigurer</code>
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></div><div
class="codeContent panelContent pdl">
+</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:</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></div><div
class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<!-- bridge spring property placeholder with Camel -->
@@ -8331,7 +8338,7 @@ destination=mock:result
</bean>
]]></script>
-</div></div>You <strong>must not</strong> use the spring
<context:property-placeholder> namespace at the same time; this is not
possible.<p>After declaring this bean, you can define property placeholders
using both the Spring style, and the Camel style within the
<camelContext> tag as shown below:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Using bridge property
placeholders</b></div><div class="codeContent panelContent pdl">
+</div></div>You <strong>must not</strong> use the
spring <strong><code><context:property-placeholder></code></strong>
namespace at the same time; this is not possible.<p>After declaring this bean,
you can define property placeholders using both the Spring style, and the Camel
style within the <strong><code><camelContext></code></strong> tag as
shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Using
bridge property placeholders</b></div><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<!-- a bean that uses Spring property placeholder -->
@@ -8350,17 +8357,17 @@ destination=mock:result
</camelContext>
]]></script>
-</div></div>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 {{ }}.<h4
id="BookComponentAppendix-ClashingSpringpropertyplaceholderswithCamelslanguage">Clashing
Spring property placeholders with Camels <a shape="rect"
href="simple.html">Simple</a> language</h4><p>Take notice when using Spring
bridging placeholder then the spring ${ } syntax clashes with the <a
shape="rect" href="simple.html">Simple</a> in Camel, and therefore take care.
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"><![CDATA[<setHeader
headerName="Exchange.FILE_NAME">
+</div></div>Notice how the hello bean is using pure Spring property
placeholders using the <strong><code>${}</code></strong> notation. And in
the Camel routes we use the Camel placeholder notation with <strong><code>{{
}}</code></strong>.<h4
id="BookComponentAppendix-ClashingSpringPropertyPlaceholderswithCamelsLanguage">Clashing
Spring Property Placeholders with Camels <a shape="rect"
href="simple.html">Simple</a> Language</h4><p>Take notice when using Spring
bridging placeholder then the spring <strong><code>${}</code></strong>
syntax clashes with the <a shape="rect" href="simple.html">Simple</a> in Camel,
and therefore take care.</p><p>Example:</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"><![CDATA[<setHeader
headerName="Exchange.FILE_NAME">
<simple>{{file.rootdir}}/${in.header.CamelFileName}</simple>
</setHeader>
]]></script>
-</div></div><p>clashes with Spring property placeholders, and you should use
$simple{ } to indicate using the <a shape="rect" href="simple.html">Simple</a>
language in Camel.</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"><![CDATA[<setHeader
headerName="Exchange.FILE_NAME">
+</div></div><p>clashes with Spring property placeholders, and you should
use <strong><code>$simple{}</code></strong> to indicate using the <a
shape="rect" href="simple.html">Simple</a> language in Camel.</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"><![CDATA[<setHeader
headerName="Exchange.FILE_NAME">
<simple>{{file.rootdir}}/$simple{in.header.CamelFileName}</simple>
</setHeader>
]]></script>
-</div></div><p>An alternative is to configure the
<code>PropertyPlaceholderConfigurer</code> with
<code>ignoreUnresolvablePlaceholders</code> option to <code>true</code>.</p><h3
id="BookComponentAppendix-OverridingpropertiesfromCameltestkit">Overriding
properties from Camel test kit</h3><p><strong>Available as of Camel
2.10</strong></p><p>When <a shape="rect" href="testing.html">Testing</a> with
Camel and using the <a shape="rect" href="properties.html">Properties</a>
component, you may want to be able to provide the properties to be used from
directly within the unit test source code.<br clear="none"> This is now
possible from Camel 2.10 onwards, as the Camel test kits, eg
<code>CamelTestSupport</code> class offers the following methods</p><ul
class="alternate"><li>useOverridePropertiesWithPropertiesComponent</li><li>ignoreMissingLocationWithPropertiesComponent</li></ul><p>So
for example in your unit test classes, you can override the
<code>useOverridePropertiesWithPropertiesCompon
ent</code> method and return a <code>java.util.Properties</code> that contains
the properties which should be preferred to be used.</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Providing properties from within unit test
source</b></div><div class="codeContent panelContent pdl">
+</div></div><p>An alternative is to configure the
<strong><code>PropertyPlaceholderConfigurer</code></strong> with
<strong><code>ignoreUnresolvablePlaceholders</code></strong> option to
<strong><code>true</code></strong>.</p><h3
id="BookComponentAppendix-OverridingPropertiesfromCamelTestKit">Overriding
Properties from Camel Test Kit</h3><p><strong>Available as of Camel
2.10</strong></p><p>When <a shape="rect" href="testing.html">Testing</a> with
Camel and using the <a shape="rect" href="properties.html">Properties</a>
component, you may want to be able to provide the properties to be used from
directly within the unit test source code. This is now possible from Camel
2.10, as the Camel test kits, e.g.,
<strong><code>CamelTestSupport</code></strong> class offers the following
methods</p><ul
class="alternate"><li><strong><code>useOverridePropertiesWithPropertiesComponent</code></strong></li><li><strong><code>ignoreMissingLocationWithPropertiesComponent</code></strong></li></ul><p>So
f
or example in your unit test classes, you can override the
<strong><code>useOverridePropertiesWithPropertiesComponent</code></strong>
method and return a <strong><code>java.util.Properties</code></strong> that
contains the properties which should be preferred to be used.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Providing properties from
within unit test source</b></div><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
// override this method to provide our custom properties we use in this unit
test
@Override
@@ -8371,7 +8378,7 @@ protected Properties useOverrideProperti
return extra;
}
]]></script>
-</div></div>This can be done from any of the Camel Test kits, such as
camel-test, camel-test-spring, and camel-test-blueprint.<p>The
<code>ignoreMissingLocationWithPropertiesComponent</code> 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
@PropertyInject</h3><p><strong>Available as of Camel 2.12</strong></p><p>Camel
allows to inject property placeholders in POJOs using the @PropertyInject
annotation which can be set on fields and setter methods.<br clear="none"> For
example you can use that with <code>RouteBuilder</code> classes, such as shown
below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div>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>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"><![CDATA[public class MyRouteBuilder extends
RouteBuilder {
@PropertyInject("hello")
@@ -8383,89 +8390,79 @@ protected Properties useOverrideProperti
.transform().constant(greeting)
.to("{{result}}");
}
-
}
]]></script>
-</div></div><p>Notice we have annotated the greeting field with
@PropertyInject and define it to use the key "hello". Camel will then lookup
the property with this key and inject its value, converted to a String
type.</p><p>You can also use multiple placeholders and text in the key, for
example we can do:</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"><![CDATA[ @PropertyInject("Hello {{name}} how
are you?")
- private String greeting;
-]]></script>
-</div></div><p>This will lookup the placeholder with they key
"name".</p><p>You can also add a default value if the key does not exists, 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"><![CDATA[ @PropertyInject(value =
"myTimeout", defaultValue = "5000")
- private int timeout;
+</div></div><p>Notice we have annotated the greeting field
with <strong><code>@PropertyInject</code></strong> and define it to use
the key <strong><code>hello</code></strong>. Camel will then lookup the
property with this key and inject its value, converted to a String
type.</p><p>You can also use multiple placeholders and text in the key, for
example we can do:</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"><![CDATA[@PropertyInject("Hello {{name}} how are
you?")
+private String greeting;
+]]></script>
+</div></div><p>This will lookup the placeholder with they key
<strong><code>name</code></strong>.</p><p>You can also add a default value if
the key does not exists, 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"><![CDATA[@PropertyInject(value =
"myTimeout", defaultValue = "5000")
+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>env - A function to lookup the property
from OS environment variables</li><li>sys - A function to lookup the property
from Java JVM system properties</li><li>service - A function to lookup the
property from OS environment variables using the service naming
idiom</li><li>service.host - <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>service.port -
<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 intende
d 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: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[ <camelContext
xmlns="http://camel.apache.org/schema/blueprint">
-
- <route>
- <from uri="direct:start"/>
- <to uri="{{env:SOMENAME}}"/>
- <to uri="{{sys:MyJvmPropertyName}}"/>
- </route>
- </camelContext>]]></script>
-</div></div><p>You can use default values as well, so if the property does not
exists, you can define a default value as shown below, where the default value
is a log:foo and log:bar value.</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"><![CDATA[ <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>]]></script>
-</div></div><p> </p><p>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</p><ul><li><em>NAME</em><strong>_SERVICE_HOST</strong></li><li><em>NAME</em><strong>_SERVICE_PORT</strong></li></ul><p>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</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</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><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<camelContext
xmlns="http://camel.apache.org/schema/blueprint">
+ <route>
+ <from uri="direct:start"/>
+ <to uri="{{env:SOMENAME}}"/>
+ <to uri="{{sys:MyJvmPropertyName}}"/>
+ </route>
+</camelContext>]]></script>
+</div></div><p>You can use default values as well, so if the property does not
exists, you can define a default value as shown below, where the default value
is a <strong><code>log:foo</code></strong>
and <strong><code>log:bar</code></strong> value.</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"><![CDATA[<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>]]></script>
+</div></div><p> </p><p>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 <strong><code>hostname :
port</code></strong></p><ul><li><em><code>NAME</code></em><strong><code>_SERVICE_HOST</code></strong></li><li><em><code>NAME</code></em><strong><code>_SERVICE_PORT</code></strong></li></ul><p>in
other words the service uses <strong><code>_SERVICE_HOST</code></strong>
and <strong><code>_SERVICE_PORT</code></strong> as prefix. So if the
service is named <strong><code>FOO</code></strong>, then the OS environment
variables should be set 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"><![CDATA[export $FOO_SERVICE_HOST=myserver
export $FOO_SERVICE_PORT=8888]]></script>
-</div></div><p> </p><p>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 <a shape="rect" href="http.html">HTTP</a> component to make the
HTTP call:</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"><![CDATA[ <camelContext
xmlns="http://camel.apache.org/schema/blueprint">
-
- <route>
- <from uri="direct:start"/>
- <to uri="http://{{service:FOO}}/myapp"/>
- </route>
- </camelContext>]]></script>
-</div></div><p> </p><p>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</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"><![CDATA[ <camelContext
xmlns="http://camel.apache.org/schema/blueprint">
-
- <route>
- <from uri="direct:start"/>
- <to uri="http://{{service:FOO:localhost:8080}}/myapp"/>
- </route>
- </camelContext>]]></script>
[... 80 lines stripped ...]