You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2016/08/02 18:19:51 UTC

svn commit: r994305 [2/2] - in /websites/production/camel/content: book-component-appendix.html book-in-one-page.html cache/main.pageCache jms.html properties.html using-propertyplaceholder.html

Modified: websites/production/camel/content/using-propertyplaceholder.html
==============================================================================
--- websites/production/camel/content/using-propertyplaceholder.html (original)
+++ websites/production/camel/content/using-propertyplaceholder.html Tue Aug  2 18:19:51 2016
@@ -292,7 +292,61 @@ assertMockEndpointsSatisfied();
                     // which should have the value of {{stop}} key being looked up in the properties file
                     .multicast().placeholder("stopOnException", "stop")
                         .to(&quot;mock:a&quot;).throwException(new IllegalAccessException(&quot;Damn&quot;)).to(&quot;mock:b&quot;);]]></script>
-</div></div><h3 id="UsingPropertyPlaceholder-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="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>By default Camel detects and uses OSGi blueprint property placeholder service. You can disable this by setting the attribute <code>useBlueprintPropertyResolver</code> to false on the <code>&lt;camelContext&gt;</code> definition.<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 &lt;camelContext&gt; you must use the ${ } syntax. Where as inside &lt;camelContext&gt; 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 &lt;propertyPlaceholder&gt; as shown in the example below:</p><div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>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:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="UsingPropertyPlaceholder-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[&lt;blueprint xmlns=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot;
+           xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+           xmlns:cm=&quot;http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0&quot;
+           xsi:schemaLocation=&quot;
+           http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd&quot;&gt;
+
+    &lt;!-- OSGI blueprint property placeholder --&gt;
+    &lt;cm:property-placeholder id=&quot;myblueprint.placeholder&quot; persistent-id=&quot;camel.blueprint&quot;&gt;
+        &lt;!-- list some properties as needed --&gt;
+        &lt;cm:default-properties&gt;
+            &lt;cm:property name=&quot;result&quot; value=&quot;mock:result&quot;/&gt;
+        &lt;/cm:default-properties&gt;
+    &lt;/cm:property-placeholder&gt;
+
+    &lt;camelContext xmlns=&quot;http://camel.apache.org/schema/blueprint&quot;&gt;
+        &lt;!-- in the route we can use {{ }} placeholders which will lookup in blueprint
+             as Camel will auto detect the OSGi blueprint property placeholder and use it --&gt;
+        &lt;route&gt;
+            &lt;from uri=&quot;direct:start&quot;/&gt;
+            &lt;to uri=&quot;mock:foo&quot;/&gt;
+            &lt;to uri=&quot;{{result}}&quot;/&gt;
+        &lt;/route&gt;
+    &lt;/camelContext&gt;
+&lt;/blueprint&gt;]]></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;">&lt;camelContext&gt;</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 &lt;cam
 elContext&gt; you must use the ${ } syntax. Where as inside &lt;camelContext&gt; 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 &lt;propertyPlaceholder&gt; 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[&lt;blueprint xmlns=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot;
+           xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+           xmlns:cm=&quot;http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0&quot;
+           xsi:schemaLocation=&quot;
+           http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd&quot;&gt;
+
+    &lt;!-- OSGI blueprint property placeholder --&gt;
+    &lt;cm:property-placeholder id=&quot;myblueprint.placeholder&quot; persistent-id=&quot;camel.blueprint&quot;&gt;
+        &lt;!-- list some properties as needed --&gt;
+        &lt;cm:default-properties&gt;
+            &lt;cm:property name=&quot;prefix.result&quot; value=&quot;mock:result&quot;/&gt;
+        &lt;/cm:default-properties&gt;
+    &lt;/cm:property-placeholder&gt;
+
+    &lt;camelContext xmlns=&quot;http://camel.apache.org/schema/blueprint&quot;&gt;
+        &lt;!-- using Camel properties component and refer to the blueprint property placeholder by its id --&gt;
+        &lt;propertyPlaceholder id=&quot;properties&quot; location=&quot;blueprint:myblueprint.placeholder&quot;
+                             prefixToken=&quot;[[&quot; suffixToken=&quot;]]&quot;
+                             propertyPrefix=&quot;prefix.&quot;/&gt;
+
+        &lt;!-- in the route we can use {{ }} placeholders which will lookup in blueprint --&gt;
+        &lt;route&gt;
+            &lt;from uri=&quot;direct:start&quot;/&gt;
+            &lt;to uri=&quot;mock:foo&quot;/&gt;
+            &lt;to uri=&quot;[[result]]&quot;/&gt;
+        &lt;/route&gt;
+    &lt;/camelContext&gt;
+&lt;/blueprint&gt;]]></script>
+</div></div><p>&#160;</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">
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[location=&quot;blueprint:myblueprint.placeholder,classpath:myproperties.properties&quot;
 ]]></script>
 </div></div><p>Each location is separated by comma.</p><h4 id="UsingPropertyPlaceholder-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">