Author: buildbot Date: Wed Feb 18 08:18:09 2015 New Revision: 940559 Log: Production update by buildbot for camel
Added: websites/production/camel/content/eclipse-kura-component.html Modified: websites/production/camel/content/advicewith.html websites/production/camel/content/cache/main.pageCache websites/production/camel/content/spring-boot.html Modified: websites/production/camel/content/advicewith.html ============================================================================== --- websites/production/camel/content/advicewith.html (original) +++ websites/production/camel/content/advicewith.html Wed Feb 18 08:18:09 2015 @@ -86,16 +86,7 @@ <tbody> <tr> <td valign="top" width="100%"> -<div class="wiki-content maincontent"><h2 id="AdviceWith-AdviceWith">AdviceWith</h2> - -<p><strong>Available as of Camel 2.1</strong></p> - -<p>AdviceWith is used for testing Camel routes where you can <em>advice</em> an existing route before its being tested. What <code>adviceWith</code> allows is to changes some factors on the route before the test is being run.</p> - -<p>At current time you can <em>advice</em> an existing route by adding <a shape="rect" href="intercept.html">Intercept</a>, <a shape="rect" href="exception-clause.html">Exception Clause</a> etc. which then will apply for the route being advice.</p> - -<p>For example in the route below we intercept sending a message to the <code>mock:foo</code> endpoint and detour the message.</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<div class="wiki-content maincontent"><h2 id="AdviceWith-AdviceWith">AdviceWith</h2><p><strong>Available as of Camel 2.1</strong></p><p>AdviceWith is used for testing Camel routes where you can <em>advice</em> an existing route before its being tested. What <code>adviceWith</code> allows is to changes some factors on the route before the test is being run.</p><p>At current time you can <em>advice</em> an existing route by adding <a shape="rect" href="intercept.html">Intercept</a>, <a shape="rect" href="exception-clause.html">Exception Clause</a> etc. which then will apply for the route being advice.</p><p>For example in the route below we intercept sending a message to the <code>mock:foo</code> endpoint and detour the message.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ public void testAdvised() throws Exception { // advice the first route using the inlined route builder @@ -119,82 +110,36 @@ public void testAdvised() throws Excepti assertMockEndpointsSatisfied(); } ]]></script> -</div></div> - - <div class="aui-message problem shadowed information-macro"> +</div></div> <div class="aui-message problem shadowed information-macro"> <p class="title">Recommendation</p> <span class="aui-icon icon-problem">Icon</span> <div class="message-content"> - -<p>It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved.<br clear="none"> -The Camel team plan for Camel 3.0 to support this as internal refactorings in the routing engine is needed to support this properly.</p> + <p>It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved.<br clear="none"> The Camel team plan for Camel 3.0 to support this as internal refactorings in the routing engine is needed to support this properly.</p> </div> </div> - - <div class="aui-message success shadowed information-macro"> <p class="title">Telling Camel you are using adviceWith</p> <span class="aui-icon icon-success">Icon</span> <div class="message-content"> - -<p>From <strong>Camel 2.9</strong> onwards its recommended to override the <code>isUseAdviceWith</code> method and return true to tell Camel you are using advice with in your unit tests. Then after you have done the adviceWith, then you must start <code>CamelContext</code> manually. See further below for an example.</p> + <p>From <strong>Camel 2.9</strong> onwards its recommended to override the <code>isUseAdviceWith</code> method and return true to tell Camel you are using advice with in your unit tests. Then after you have done the adviceWith, then you must start <code>CamelContext</code> manually. See further below for an example.</p> </div> </div> - - -<h3 id="AdviceWith-UsingAdviceWithRouteBuilder">Using AdviceWithRouteBuilder</h3> - -<p><strong>Available as of Camel 2.7</strong></p> - -<p>The <code>AdviceWithRouteBuilder</code> is a specialized <code>RouteBuilder</code> which has additional methods for advising routes. For example this allows you to manipulate the advised route, such as replacing a node with some other nodes.</p> - -<p>The <code>AdviceWithRouteBuilder</code> offers the following extra methods</p> - -<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Method </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>mockEndpoints</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Is used to easily mock all endpoints. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>mockEndpoints(patterns)</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Is used to easily mock endpoints using a pattern. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. From Camel 2.10 onwards you can specify multiple patterns. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>mockEndpointsAndSkip(patterns)</code> </p></td><td colspan= "1" rowspan="1" class="confluenceTd"><p> Is used to easily mock endpoints using a pattern, and <strong>skip</strong> sending to the original endpoint. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. You can specify multiple patterns. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>weaveById(pattern)</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Is used to select node(s) matching by id's, and weave in the following nodes. See below for pattern matching and examples. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>weaveByToString(pattern)</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Is used to select nodes(s) matching by their <code>toString</code> representation, and weave in the following nodes. See below for pattern matching and examples. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>weave ByType(Class)</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.8:</strong> Is used to select node(s) matching by their class type (the classes from the org.apache.camel.model package), and weave in the following nodes. See below for examples. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>weaveAddFirst</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the start of the route. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>weaveAddLast</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the end of the route. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>replaceFromWith(uri)</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.9:</strong> To replace the route input with a new endpoint uri. </p></td></tr></tbody></table></div> - - -<p>The <code>pattern</code> option is used for matching. It uses the same rules as the <a shape="rect" href="intercept.html">Intercept</a>, which is applied in the following order:</p> -<ul><li>match exact</li><li>match by wildcard</li><li>match by regular expression</li></ul> - - -<p>For example to match exact you can use <code>weaveById("foo")</code> which will match only the id in the route which has the value <code>"foo"</code>.<br clear="none"> -The wildcard is when the pattern ends with a * char, such as: <code>weaveById("foo*")</code> which will match any id's starting with <code>"foo"</code>, such as <code>foo, foobar, foobie</code> and so forth.<br clear="none"> -The regular expression is more advanced and allows you to match multiple ids, such as <code>weaveById("(foo|bar)")</code> which will match both <code>"foo"</code> and <code>"bar"</code>.</p> - - <div class="aui-message success shadowed information-macro"> +<h3 id="AdviceWith-UsingAdviceWithRouteBuilder">Using AdviceWithRouteBuilder</h3><p><strong>Available as of Camel 2.7</strong></p><p>The <code>AdviceWithRouteBuilder</code> is a specialized <code>RouteBuilder</code> which has additional methods for advising routes. For example this allows you to manipulate the advised route, such as replacing a node with some other nodes.</p><p>The <code>AdviceWithRouteBuilder</code> offers the following extra methods</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpoints</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock all endpoints. See more details and examples at <a shape="rect" href="mock.html">Mock</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><c ode>mockEndpoints(patterns)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock endpoints using a pattern. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. From Camel 2.10 onwards you can specify multiple patterns.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpointsAndSkip(patterns)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock endpoints using a pattern, and <strong>skip</strong> sending to the original endpoint. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. You can specify multiple patterns.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveById(pattern)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to select node(s) matching by id's, and weave in the following nodes. See below for patter n matching and examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveByToString(pattern)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to select nodes(s) matching by their <code>toString</code> representation, and weave in the following nodes. See below for pattern matching and examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveByType(Class)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is used to select node(s) matching by their class type (the classes from the org.apache.camel.model package), and weave in the following nodes. See below for examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveAddFirst</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the start of the route.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveAddLast</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the end of the route.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>replaceFromWith(uri)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> To replace the route input with a new endpoint uri.</p></td></tr></tbody></table></div><p>The <code>pattern</code> option is used for matching. It uses the same rules as the <a shape="rect" href="intercept.html">Intercept</a>, which is applied in the following order:</p><ul><li>match exact</li><li>match by wildcard</li><li>match by regular expression</li></ul><p>For example to match exact you can use <code>weaveById("foo")</code> which will match only the id in the route which has the value <code>"foo"</code>.<br clear="none"> The wildcard is when the patte rn ends with a * char, such as: <code>weaveById("foo*")</code> which will match any id's starting with <code>"foo"</code>, such as <code>foo, foobar, foobie</code> and so forth.<br clear="none"> The regular expression is more advanced and allows you to match multiple ids, such as <code>weaveById("(foo|bar)")</code> which will match both <code>"foo"</code> and <code>"bar"</code>.</p> <div class="aui-message success shadowed information-macro"> <span class="aui-icon icon-success">Icon</span> <div class="message-content"> - -<p>If you try to match a <code>pattern</code> on an exact endpoint uri, then mind that URI options ordering may influence, and hence its best to match by wildcard. For example:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -mockEndpointsAndSkip("activemq:queue:foo?*") + <p>If you try to match a <code>pattern</code> on an exact endpoint uri, then mind that URI options ordering may influence, and hence its best to match by wildcard. For example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[mockEndpointsAndSkip("activemq:queue:foo?*") ]]></script> -</div></div> -<p>To match the foo queue and disregard any options.</p> +</div></div><p>To match the foo queue and disregard any options.</p> </div> </div> - - -<h3 id="AdviceWith-UsingweaveById">Using weaveById</h3> - -<p>The <code>weaveById</code> allows you to manipulate the route, for example by replacing a node with other nodes. The following methods is available:</p> - -<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Method </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>remove</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Removes the selected node(s). </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>replace</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Replaces the selected node(s) with the following nodes. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>before</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Before the selected node(s), the following nodes is added. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>after</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> After the selected node(s), the followin g nodes is added. </p></td></tr></tbody></table></div> - - -<p>For example given the following route:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Route</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +<h3 id="AdviceWith-UsingweaveById">Using weaveById</h3><p>The <code>weaveById</code> allows you to manipulate the route, for example by replacing a node with other nodes. The following methods is available:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>remove</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Removes the selected node(s).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>replace</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Replaces the selected node(s) with the following nodes.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>before</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Before the selected node(s), the following nodes is adde d.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>after</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>After the selected node(s), the following nodes is added.</p></td></tr></tbody></table></div><p>For example given the following route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Route</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("direct:start") .to("mock:foo") .to("mock:bar").id("bar") .to("mock:result"); ]]></script> -</div></div> - -<p>Then let's go over the four methods to see how you can use them in unit tests:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Replace</b></div><div class="codeContent panelContent pdl"> +</div></div><p>Then let's go over the four methods to see how you can use them in unit tests:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Replace</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override @@ -205,12 +150,7 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> - -<p>In this example we replace the <code>.to("mock:bar").id("bar")</code> with the <code>.multicast().to("mock:a").to("mock:b")</code>.<br clear="none"> -That means instead of sending the message to a <code>"mock:bar"</code> endpoint, we do a <a shape="rect" href="multicast.html">Multicast</a> to <code>"mock:a"</code> and <code>"mock:b"</code> endpoints instead.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Remove</b></div><div class="codeContent panelContent pdl"> +</div></div><p>In this example we replace the <code>.to("mock:bar").id("bar")</code> with the <code>.multicast().to("mock:a").to("mock:b")</code>.<br clear="none"> That means instead of sending the message to a <code>"mock:bar"</code> endpoint, we do a <a shape="rect" href="multicast.html">Multicast</a> to <code>"mock:a"</code> and <code>"mock:b"</code> endpoints instead.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Remove</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override @@ -220,10 +160,7 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> -<p>In the example above, we simply just remove the <code>.to("mock:bar").id("bar")</code>.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Before</b></div><div class="codeContent panelContent pdl"> +</div></div><p>In the example above, we simply just remove the <code>.to("mock:bar").id("bar")</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Before</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override @@ -234,11 +171,7 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> -<p>In the example above, we add the following nodes <code>to("mock:a").transform(constant("Bye World"))</code> <strong>before</strong> the node with the id <code>"bar"</code>.<br clear="none"> -That means the message being send to <code>"mock:bar"</code> would have been transformed to a constant message "Bye World".</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>After</b></div><div class="codeContent panelContent pdl"> +</div></div><p>In the example above, we add the following nodes <code>to("mock:a").transform(constant("Bye World"))</code> <strong>before</strong> the node with the id <code>"bar"</code>.<br clear="none"> That means the message being send to <code>"mock:bar"</code> would have been transformed to a constant message "Bye World".</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>After</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override @@ -249,18 +182,7 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> -<p>In the example above, we add the following nodes <code>to("mock:a").transform(constant("Bye World"))</code> <strong>after</strong> the node with the id <code>"bar"</code>.</p> - -<h3 id="AdviceWith-UsingweaveByToString">Using weaveByToString</h3> - -<p>The <code>weaveByToString</code> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <code>weaveById</code>, this method uses the <code>toString</code> representation of the node(s) when matching. This allows you to match nodes, which may not have assigned ids, or to match <a shape="rect" href="eip.html">EIP</a> pattern.<br clear="none"> -You have to be a bit more careful when using this as the <code>toString</code> representation can be verbose and contain characters such as [ ] ( ) -> and so forth. That is why using the regular expression matching is the must useable.</p> - -<p>The <code>weaveByToString</code> has the same methods as <code>weaceById</code>.</p> - -<p>For example to replace any nodes which has <code>"foo"</code> you can do</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Replace</b></div><div class="codeContent panelContent pdl"> +</div></div><p>In the example above, we add the following nodes <code>to("mock:a").transform(constant("Bye World"))</code> <strong>after</strong> the node with the id <code>"bar"</code>.</p><h3 id="AdviceWith-UsingweaveByToString">Using weaveByToString</h3><p>The <code>weaveByToString</code> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <code>weaveById</code>, this method uses the <code>toString</code> representation of the node(s) when matching. This allows you to match nodes, which may not have assigned ids, or to match <a shape="rect" href="eip.html">EIP</a> pattern.<br clear="none"> You have to be a bit more careful when using this as the <code>toString</code> representation can be verbose and contain characters such as [ ] ( ) -> and so forth. That is why using the regular expression matching is the must useable.</p><p>The <code>weaveByToString</code> has the same methods as <code>weaceById</code>.</p><p>For example to replace any nodes which has <code>"foo"</code> you can do</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Replace</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override @@ -271,31 +193,14 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> - -<p>Notice that we have to use <code>".<strong>foo.</strong>"</code> in the pattern to match that <code>"foo"</code> is present anywhere in the string.</p> - - -<h3 id="AdviceWith-UsingweaveByType">Using weaveByType</h3> - -<p><strong>Available as of Camel 2.8</strong></p> - -<p>The <code>weaveByToType</code> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <code>weaveById</code>, and <code>weaveByToString</code> this method uses the class type of the node(s) when matching. This allows you to match <a shape="rect" href="eip.html">EIP</a> pattern by its type.</p> - -<p>The <code>weaveByToType</code> has the same methods as <code>weaceById</code> and <code>weaveByToString</code>.</p> - -<p>For example to remove a transform from the following route:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Route</b></div><div class="codeContent panelContent pdl"> +</div></div><p>Notice that we have to use <code>".<strong>foo.</strong>"</code> in the pattern to match that <code>"foo"</code> is present anywhere in the string.</p><h3 id="AdviceWith-UsingweaveByType">Using weaveByType</h3><p><strong>Available as of Camel 2.8</strong></p><p>The <code>weaveByToType</code> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <code>weaveById</code>, and <code>weaveByToString</code> this method uses the class type of the node(s) when matching. This allows you to match <a shape="rect" href="eip.html">EIP</a> pattern by its type.</p><p>The <code>weaveByToType</code> has the same methods as <code>weaceById</code> and <code>weaveByToString</code>.</p><p>For example to remove a transform from the following route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Route</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ from("direct:start") .transform(simple("Hello ${body}")) .log("Got ${body}") .to("mock:result"); ]]></script> -</div></div> - -<p>You can do:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Remove</b></div><div class="codeContent panelContent pdl"> +</div></div><p>You can do:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Remove</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override @@ -305,22 +210,8 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> - - -<h3 id="AdviceWith-Usingselectors">Using selectors</h3> - -<p><strong>Available os of Camel 2.8</strong></p> - -<p>The following methods <code>weaveById(pattern)</code>, <code>weaveByToString(pattern)</code> and <code>weaveByType(Class)</code> each match N+ nodes. By using optional selectors you can narrow down the nodes being used. For example if <code>weaveByType(Class)</code> returns 2 nodes. Then you can use a selector to indicate it should only select the first node.</p> - -<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Selector </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>selectFirst</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Will only select the first matched node. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>selectLast</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Will only select the last matched node. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>selectIndex(index)</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Will only select the n'th matched node. The index is zero-based. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>selectRange(from, to)</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> W ill only select the matches node within the given range by index (both inclusive). The index is zero-based. </p></td></tr></tbody></table></div> - - -<p>For example to remove the first <code>.to</code> node in route you can do as follows:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { +</div></div><h3 id="AdviceWith-Usingselectors">Using selectors</h3><p><strong>Available os of Camel 2.8</strong></p><p>The following methods <code>weaveById(pattern)</code>, <code>weaveByToString(pattern)</code> and <code>weaveByType(Class)</code> each match N+ nodes. By using optional selectors you can narrow down the nodes being used. For example if <code>weaveByType(Class)</code> returns 2 nodes. Then you can use a selector to indicate it should only select the first node.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Selector</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectFirst</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the first matched node.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectLast</code></p></td><td colspan="1" ro wspan="1" class="confluenceTd"><p>Will only select the last matched node.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectIndex(index)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the n'th matched node. The index is zero-based.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectRange(from, to)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the matches node within the given range by index (both inclusive). The index is zero-based.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>maxDeep(to)</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.14.2/2.15:</strong> To limit the selection to at most N level deep in the Camel route tree. The first level is starting from number 1. So number 2 is the children of the 1st level nodes.</td></tr></tbody></table></div><p>For example to remove the first <code>.to</ code> node in route you can do as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { // only remove the first to node in the route @@ -328,19 +219,8 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> - - -<h3 id="AdviceWith-UsingweaveAddFirst/weaveAddLast">Using weaveAddFirst / weaveAddLast</h3> - -<p><strong>Available os of Camel 2.8</strong></p> - -<p>The <code>weaveAddFirst</code> and <code>weaveAddLast</code> is a shorthand to easily add nodes to the route. These methods can only <strong>add</strong> to an existing routes. If you want to manipulate the route, then there are plenty of methods as already shown on this page.</p> - -<p>For example if you want to send a message to a <code>mock:input</code> endpoint you can do as follows:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { +</div></div><h3 id="AdviceWith-UsingweaveAddFirst/weaveAddLast">Using weaveAddFirst / weaveAddLast</h3><p><strong>Available os of Camel 2.8</strong></p><p>The <code>weaveAddFirst</code> and <code>weaveAddLast</code> is a shorthand to easily add nodes to the route. These methods can only <strong>add</strong> to an existing routes. If you want to manipulate the route, then there are plenty of methods as already shown on this page.</p><p>For example if you want to send a message to a <code>mock:input</code> endpoint you can do as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { // send the incoming message to mock:input @@ -348,12 +228,8 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> - -<p>Likewise if you want to easily send a message to a <code>mock:output</code> endpoint you can do as follows:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { +</div></div><p>Likewise if you want to easily send a message to a <code>mock:output</code> endpoint you can do as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { // send the outgoing message to mock:output @@ -361,12 +237,8 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> - -<p>You can of course combine those in the same advice with:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { +</div></div><p>You can of course combine those in the same advice with:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { weaveAddFirst().to("mock:input"); @@ -374,36 +246,15 @@ context.getRouteDefinitions().get(0).adv } }); ]]></script> -</div></div> - -<h3 id="AdviceWith-Replacefromwithanotherendpoint">Replace from with another endpoint</h3> - -<p><strong>Available as of Camel 2.9</strong></p> - -<p>You may have routes which consumes messages from endpoints which you want to substitute with another endpoint for easier unit testing. For example a <a shape="rect" href="jms.html">JMS</a> endpoint could be replaced with a <a shape="rect" href="seda.html">SEDA</a> or <a shape="rect" href="direct.html">Direct</a> for unit testing a route, as shown below where we replace the input of the route to a "seda:foo" endpoint:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { +</div></div><h3 id="AdviceWith-Replacefromwithanotherendpoint">Replace from with another endpoint</h3><p><strong>Available as of Camel 2.9</strong></p><p>You may have routes which consumes messages from endpoints which you want to substitute with another endpoint for easier unit testing. For example a <a shape="rect" href="jms.html">JMS</a> endpoint could be replaced with a <a shape="rect" href="seda.html">SEDA</a> or <a shape="rect" href="direct.html">Direct</a> for unit testing a route, as shown below where we replace the input of the route to a "seda:foo" endpoint:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { replaceFromWith("seda:foo"); } }); ]]></script> -</div></div> - -<h3 id="AdviceWith-Usingmockendpoints">Using mock endpoints</h3> - -<p>While routing messages, you may want to easily know how the messages was routed. For example you can let Camel mock all endpoints, which mean that when a message is sent to any endpoint, its first send to a mock endpoint, and then afterwards to the original endpoint. Then from your unit tests, you can setup expectations on the mock endpoints.</p> - -<p>See more details at the section <em>Mocking existing endpoints using the camel-test component</em> at <a shape="rect" href="mock.html">Mock</a>.</p> - -<h3 id="AdviceWith-UsingisUseAdviceWith">Using isUseAdviceWith</h3> - -<p><strong>Available as of Camel 2.9</strong><br clear="none"> -It is recommended to override the method <code>isUseAdviceWith</code> and return <code>true</code> to instruct Camel that you are using <code>adviceWith</code> in the unit tests. Then in your unit test methods, after you have done the <code>adviceWith</code> you <strong>must</strong> start <code>CamelContext</code> by invoke the <code>start</code> method on the <code>context</code> instance. In the following we have an example. The route is using <a shape="rect" href="activemq.html">ActiveMQ</a> to route messages. What we would like to do in a unit test is to test the route, but without having to set and use <a shape="rect" href="activemq.html">ActiveMQ</a>. We do not have <a shape="rect" href="activemq.html">ActiveMQ</a> on the classpath. So for that we need to advice the route and replace <a shape="rect" href="activemq.html">ActiveMQ</a> with for example a <a shape="rect" href="seda.html">SEDA</a> endpoint instead.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>isUseAdviceWith</b></div><div class="codeContent panelContent pdl"> +</div></div><h3 id="AdviceWith-Usingmockendpoints">Using mock endpoints</h3><p>While routing messages, you may want to easily know how the messages was routed. For example you can let Camel mock all endpoints, which mean that when a message is sent to any endpoint, its first send to a mock endpoint, and then afterwards to the original endpoint. Then from your unit tests, you can setup expectations on the mock endpoints.</p><p>See more details at the section <em>Mocking existing endpoints using the camel-test component</em> at <a shape="rect" href="mock.html">Mock</a>.</p><h3 id="AdviceWith-UsingisUseAdviceWith">Using isUseAdviceWith</h3><p><strong>Available as of Camel 2.9</strong><br clear="none"> It is recommended to override the method <code>isUseAdviceWith</code> and return <code>true</code> to instruct Camel that you are using <code>adviceWith</code> in the unit tests. Then in your unit test methods, after you have done the <code>adviceWith</code> you <strong>must</strong> star t <code>CamelContext</code> by invoke the <code>start</code> method on the <code>context</code> instance. In the following we have an example. The route is using <a shape="rect" href="activemq.html">ActiveMQ</a> to route messages. What we would like to do in a unit test is to test the route, but without having to set and use <a shape="rect" href="activemq.html">ActiveMQ</a>. We do not have <a shape="rect" href="activemq.html">ActiveMQ</a> on the classpath. So for that we need to advice the route and replace <a shape="rect" href="activemq.html">ActiveMQ</a> with for example a <a shape="rect" href="seda.html">SEDA</a> endpoint instead.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>isUseAdviceWith</b></div><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ public class IsUseAdviceWithJUnit4Test extends org.apache.camel.test.junit4.CamelTestSupport { Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Added: websites/production/camel/content/eclipse-kura-component.html ============================================================================== --- websites/production/camel/content/eclipse-kura-component.html (added) +++ websites/production/camel/content/eclipse-kura-component.html Wed Feb 18 08:18:09 2015 @@ -0,0 +1,300 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<html> +<head> + <link href="//camel.apache.org/styles/site.css" rel="stylesheet" type="text/css"> + <link href="//camel.apache.org/styles/type-settings.css" rel="stylesheet" type="text/css"> + <script src="//camel.apache.org/styles/prototype.js" type="text/javascript"></script> + <script src="//camel.apache.org/styles/rico.js" type="text/javascript"></script> + <script src="//camel.apache.org/styles/site.js" type="text/javascript"></script> + + <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> + + <style type="text/css"> + .maincontent { overflow:hidden; } + </style> + <!--[if IE]> + <style type="text/css"> + .maincontent { width:100%; } + </style> + <![endif]--> + + + <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' rel='stylesheet' type='text/css' /> + <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' rel='stylesheet' type='text/css' /> + <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' type='text/javascript'></script> + <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' type='text/javascript'></script> + <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' type='text/javascript'></script> + + <script type="text/javascript"> + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.all(); + </script> + + <title> + Apache Camel: Eclipse Kura component + </title> +</head> +<body> +<div class="white_box"> +<div class="header"> + <div class="header_l"> + <div class="header_r"> + </div> + </div> +</div> +<div class="content"> + <div class="content_l"> + <div class="content_r"> + <div> + <!-- Banner --> +<div id="banner-content"><div id="asf_logo"> + <div id="activemq_logo" style="height:108px; background:transparent url(banner.data/apache-camel-7.png) no-repeat scroll left top;"> + <a shape="rect" style="float:left; width:310px;display:block;text-indent:-5000px;text-decoration:none;line-height:140px; margin-top:20px; margin-left:18px;" href="http://camel.apache.org/">Camel</a> + <a shape="rect" style="float:right; width:180px;display:block;text-indent:-5000px;text-decoration:none;line-height:80px; margin-top:45px; margin-right:10px;" href="http://www.apache.org">Apache</a> + </div> +</div></div> + <!-- Banner --> + <div class="top_red_bar"> + <div id="site-breadcrumbs"> + <!-- Breadcrumbs --> +<a href="index.html">Apache Camel</a> > <a href="documentation.html">Documentation</a> > <a href="components.html">Components</a> > <a href="eclipse-kura-component.html">Eclipse Kura component</a> + </div> + <!-- Quicklinks --> +<div id="site-quicklinks"><p><a shape="rect" href="download.html">Download</a> | <a shape="rect" href="javadoc.html">JavaDoc</a> | <a shape="rect" href="source.html">Source</a> | <a shape="rect" href="discussion-forums.html">Forums</a> | <a shape="rect" href="support.html">Support</a></p></div> + <!-- Quicklinks --> + </div> + + <table border="0"> + <tbody> + <tr> + <td valign="top" width="100%"> +<div class="wiki-content maincontent"><h2 id="EclipseKuracomponent-EclipseKuracomponent">Eclipse Kura component</h2><h2 id="EclipseKuracomponent-ThisdocumentationpagecoverstheintegrationoptionsofCamelwiththeEclipseKuraM2Mgateway."><span style="line-height: 1.5625;font-size: 16.0px;">This documentation page covers the integration options of Camel with the <a shape="rect" class="external-link" href="https://eclipse.org/kura/" rel="nofollow">Eclipse Kura</a> M2M gateway.</span></h2><h3 id="EclipseKuracomponent-KuraRouteractivator"><span style="line-height: 1.5625;font-size: 16.0px;">KuraRouter activator</span></h3><p>The easiest way to deploy Apache Camel routes into the Kura is to create an OSGi bundle containing the class extending <code>org.apache.camel.kura.KuraRouter</code> class:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[public class MyKuraRouter extends KuraRouter { + + @Override + public void configure() throws Exception { + from("timer:trigger"). + to("netty-http:http://app.mydatacenter.com/api"); + } + +}]]></script> +</div></div><p>Kura router starts its own OSGi-aware <code>CamelContext</code>. It means that for every class extending <code>KuraRouter</code>, there will be a dedicated <code>CamelContext</code> instance. Ideally we recommend to deploy one <code>KuraRouter</code> per OSGi bundle.</p><h3 id="EclipseKuracomponent-Camelproperties"><span style="line-height: 1.5625;">Camel properties</span></h3><p>Spring Boot auto-configuration automatically connect <a shape="rect" class="external-link" href="http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config" rel="nofollow">Spring Boot external configuration</a> (like properties placeholders, <span>OS environment variables or system properties) with the <a shape="rect" href="properties.html">Camel properties support</a>.</span> It basically means that any property defined in <code>application.properties</code> file:  </p><div class="code panel pdl" style="b order-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[route.from = jms:invoices]]></script> +</div></div><p>...or set via system property...</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[java -Droute.to=jms:processed.invoices -jar mySpringApp.jar]]></script> +</div></div><p>...can be used as placeholders in Camel route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Component +public class MyRouter extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("{{route.from}}").to("{{route.to}}"); + } + +}]]></script> +</div></div><p> </p><h3 id="EclipseKuracomponent-CustomCamelcontextconfiguration">Custom Camel context configuration</h3><p>If you would like to perform some operations on <code>CamelContext</code> bean created by Camel auto-configuration, register <code>CamelContextConfiguration</code> instance in your Spring context:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Configuration +public class MyAppConfig { + + ... + + @Bean + CamelContextConfiguration contextConfiguration() { + return new CamelContextConfiguration() { + @Override + void beforeApplicationStart(CamelContext context) { + // your custom configuration goes here + } + }; + } + +}]]></script> +</div></div><p>Method <span>C<code>amelContextConfiguration#</code></span><code><span style="line-height: 1.4285715;">beforeApplicationStart(CamelContext)</span></code><span style="line-height: 1.4285715;"> will be called just before the Spring context is started, so the <span><code>CamelContext</code> instance passed to this callback is fully</span> auto-configured. You can add many instances of C<code>amelContextConfiguration</code> into your Spring context - all of them will be executed.</span></p><h3 id="EclipseKuracomponent-DisablingJMX">Disabling JMX</h3><p>To disable JMX of the auto-configured <code>CamelContext</code> use <code>camel.springboot.jmxEnabled</code> property (JMX is enabled by default). For example you could add the following property to your <code>application.properties</code> file:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[camel.springboot.jmxEnabled = false]]></script> +</div></div><h3 id="EclipseKuracomponent-Auto-configuredconsumerandproducertemplates">Auto-configured consumer and producer templates</h3><p>Camel auto-configuration provides a pre-configured <code>ConsumerTemplate</code> and <code>ProducerTemplate</code> instances. You can simply inject them into your Spring-managed beans:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Component +public class InvoiceProcessor { + + @Autowired + private ProducerTemplate producerTemplate; + + @Autowired + private ConsumerTemplate consumerTemplate; + public void processNextInvoice() { + Invoice invoice = consumerTemplate.receiveBody("jms:invoices", Invoice.class); + ... + producerTemplate.sendBody("netty-http:http://invoicing.com/received/" + invoice.id()); + } + +}]]></script> +</div></div><p>By default consumer and producer templates comes with the endpoint cache sizes equal to 1000. You can change that values via the following Spring properties:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[camel.springboot.consumerTemplateCacheSize = 100 +camel.springboot.producerTemplateCacheSize = 200]]></script> +</div></div><h3 id="EclipseKuracomponent-Auto-configuredTypeConverter">Auto-configured TypeConverter</h3><p>Camel auto-configuration registers <code>TypeConverter</code> instance named <code>typeConverter</code> in the Spring context.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Component +public class InvoiceProcessor { + + @Autowired + private TypeConverter typeConverter; + + public long parseInvoiceValue(Invoice invoice) { + String invoiceValue = invoice.grossValue(); + return typeConverter.convertTo(Long.class, invoiceValue); + } + +}]]></script> +</div></div><h3 id="EclipseKuracomponent-SpringtypeconversionAPIbridge">Spring type conversion API bridge</h3><p>Spring comes with the powerful <a shape="rect" class="external-link" href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#core-convert" rel="nofollow">type conversion API</a>. Spring API happens not to be much different from the Camel <a shape="rect" href="type-converter.html">type converter API</a>. As those APIs are so similar, Camel Spring Boot automatically registers bridge converter (<code>SpringTypeConverter</code>) that delegates to the Spring conversion API. It basically means that out-of-the-box Camel will threat Spring Converters as Camel ones. With this approach you can enjoy both Camel and Spring converters accessed via Camel <code>TypeConverter</code> API:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Component +public class InvoiceProcessor { + + @Autowired + private TypeConverter typeConverter; + + public UUID parseInvoiceId(Invoice invoice) { + // Using Spring's StringToUUIDConverter + UUID id = invoice.typeConverter.convertTo(UUID.class, invoice.getId()); + } + +}]]></script> +</div></div><p> </p><p>Under the hood Camel Spring Boot delegates conversion to the Spring's <code><a shape="rect" class="external-link" href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/convert/ConversionService.html" rel="nofollow">ConversionService</a></code> instances available in the application context. If no <code>ConversionService</code> instance is available, Camel Spring Boot auto-configuration will create one for you.</p><h3 id="EclipseKuracomponent-Disablingtypeconversionsfeatures">Disabling type conversions features</h3><p>If you don't want Camel Spring Boot to register type-conversions related features (like <code>TypeConverter</code> instance or Spring bridge) set the <code>camel.springboot.typeConversion</code> property to <code>false</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[camel.springboot.typeConversion = false]]></script> +</div></div><h3 id="EclipseKuracomponent-Fatjarsandfatwars">Fat jars and fat wars</h3><p>The easiest way to create Camel-aware Spring Boot fat jar/war is to extend the <code><span style="line-height: 1.4285715;">org</span><span style="line-height: 1.4285715;">.apache.camel.spring.boot.F</span><code style="line-height: 1.4285715;">atJarRouter</code></code><span style="line-height: 1.4285715;"> class...</span></p><p> </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example; +Â +... // imports +Â +@SpringBootApplication +public class MyFatJarRouter extends FatJarRouter { + + @Override + public void configure() throws Exception { + from("netty-http:http://0.0.0.0:18080"). + setBody().simple("ref:helloWorld"); + } + + @Bean + String helloWorld() { + return "helloWorld"; + } + +}]]></script> +</div></div><p> </p><p>...and add the following property to your <code>application.properties</code> file:</p><p> </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[spring.main.sources = com.example.MyFatJarRouter]]></script> +</div></div><p>It is also recommended to define your main class explicitly in the Spring Boot Maven plugin configuration: </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring-boot.version}</version> + <configuration> + <mainClass>com.example.MyFatJarRouter</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> +</plugin>]]></script> +</div></div><p>In order to turn your fat jar into fat war, add the following class extending  <code><span>org</span><span>.apache.camel.spring.boot.F</span><code>atWarInitializer</code></code><span> </span>to your project:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example; +Â +... // imports + +public class MyFatWarInitializer extends FatWarInitializer { + + + @Override + protected Class<? extends FatJarRouter> routerClass() { + return MyFatJarRouter.class; + } + +}]]></script> +</div></div><p><br clear="none"></p><h3 id="EclipseKuracomponent-SeeAlso">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></div> + </td> + <td valign="top"> + <div class="navigation"> + <div class="navigation_top"> + <!-- NavigationBar --> +<div class="navigation_bottom" id="navigation_bottom"><h3 id="Navigation-Overview"><a shape="rect" href="overview.html">Overview</a></h3><ul class="alternate"><li><a shape="rect" href="index.html">Home</a></li><li><a shape="rect" href="download.html">Download</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li><li><a shape="rect" href="faq.html">FAQ</a></li></ul><h3 id="Navigation-Documentation"><a shape="rect" href="documentation.html">Documentation</a></h3><ul class="alternate"><li><a shape="rect" href="user-guide.html">User Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a shape="rect" href="books.html">Books</a></li><li><a shape="rect" href="tutorials.html">Tutorials</a></li><li><a shape="rect" href="examples.html">Examples</a></li><li><a shape="rect" href="cookbook.html">Cookbook</a></li><li><a shape="rect" href="architecture.html">Architecture</a></li><li><a shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a></li><li><a shape="rect" href="dsl.html">DSL</a></li><li><a shape="rect" href="components.html">Components</a></li><li><a shape="rect" href="data-format.html">Data Format</a></li><li><a shape="rect" href="languages.html">Languages</a></li><li><a shape="rect" href="security.html">Security</a></li><li><a shape="rect" href="security-advisories.html">Security Advisories</a></li></ul><h3 id="Navigation-Search">Search</h3><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse"> + <div> + <input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq"> + <input type="hidden" name="ie" value="UTF-8"> + <input type="text" name="q" size="21"> + <input type="submit" name="sa" value="Search"> + </div> +</form> +<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3 id="Navigation-Community"><a shape="rect" href="community.html">Community</a></h3><ul class="alternate"><li><a shape="rect" href="support.html">Support</a></li><li><a shape="rect" href="contributing.html">Contributing</a></li><li><a shape="rect" href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect" href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect" href="user-stories.html">User Stories</a></li><li><a shape="rect" href="news.html">News</a></li><li><a shape="rect" href="articles.html">Articles</a></li><li><a shape="rect" href="site.html">Site</a></li><li><a shape="rect" href="team.html">Team</a></li><li><a shape="rect" class="external-link" href="http://camel-extra.googlecode.com/" rel="nofollow">Camel Extra</a></li></ul><h3 id="Navigation-Developers"><a shape="rect" href="developers.html">Developers</a></h3><ul class="alternate" ><li><a shape="rect" href="developers.html">Developer Guide</a></li><li><a >shape="rect" href="source.html">Source</a></li><li><a shape="rect" >href="building.html">Building</a></li><li><a shape="rect" >href="javadoc.html">JavaDoc</a></li><li><a shape="rect" >href="irc-room.html">IRC Room</a></li></ul><h3 >id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul >class="alternate"><li><a shape="rect" class="external-link" >href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect" >class="external-link" >href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a > shape="rect" class="external-link" >href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a >shape="rect" class="external-link" >href="http://www.apache.org/security/">Security</a></li></ul></div> + <!-- NavigationBar --> + </div> + </div> + </td> + </tr> + </tbody> + </table> + + + <div class="bottom_red_bar"></div> + </div> + </div> + </div> +</div> +<div class="black_box"> +<div class="footer"> + <div class="footer_l"> + <div class="footer_r"> + <div> + <a href="$base/privacy-policy.html">Privacy Policy</a> - + (<a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=51811447">edit page</a>) + (<a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=51811447&showComments=true&showCommentArea=true#addcomment">add comment</a>) + </div> + </div> + </div> +</div> +</div> +</div> +<div class="design_attribution"> +© 2004-2014 The Apache Software Foundation. +<br> +Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. +<br> +<a href="http://hiramchirino.com">Graphic Design By Hiram</a> +</div> + +<!-- Camel committers that would like access to the Analytics, send a note to priv...@camel.apache.org --> +<script type="text/javascript"> + + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-25976253-1']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + +</script> + +</body> +</html> + + Modified: websites/production/camel/content/spring-boot.html ============================================================================== --- websites/production/camel/content/spring-boot.html (original) +++ websites/production/camel/content/spring-boot.html Wed Feb 18 08:18:09 2015 @@ -212,6 +212,58 @@ public class InvoiceProcessor { }]]></script> </div></div><p> </p><p>Under the hood Camel Spring Boot delegates conversion to the Spring's <code><a shape="rect" class="external-link" href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/convert/ConversionService.html" rel="nofollow">ConversionService</a></code> instances available in the application context. If no <code>ConversionService</code> instance is available, Camel Spring Boot auto-configuration will create one for you.</p><h3 id="SpringBoot-Disablingtypeconversionsfeatures">Disabling type conversions features</h3><p>If you don't want Camel Spring Boot to register type-conversions related features (like <code>TypeConverter</code> instance or Spring bridge) set the <code>camel.springboot.typeConversion</code> property to <code>false</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[camel.springboot.typeConversion = false]]></script> +</div></div><h3 id="SpringBoot-Fatjarsandfatwars">Fat jars and fat wars</h3><p>The easiest way to create Camel-aware Spring Boot fat jar/war is to extend the <code><span style="line-height: 1.4285715;">org</span><span style="line-height: 1.4285715;">.apache.camel.spring.boot.F</span><code style="line-height: 1.4285715;">atJarRouter</code></code><span style="line-height: 1.4285715;"> class...</span></p><p> </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example; +Â +... // imports +Â +@SpringBootApplication +public class MyFatJarRouter extends FatJarRouter { + + @Override + public void configure() throws Exception { + from("netty-http:http://0.0.0.0:18080"). + setBody().simple("ref:helloWorld"); + } + + @Bean + String helloWorld() { + return "helloWorld"; + } + +}]]></script> +</div></div><p> </p><p>...and add the following property to your <code>application.properties</code> file:</p><p> </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[spring.main.sources = com.example.MyFatJarRouter]]></script> +</div></div><p>It is also recommended to define your main class explicitly in the Spring Boot Maven plugin configuration: </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring-boot.version}</version> + <configuration> + <mainClass>com.example.MyFatJarRouter</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> +</plugin>]]></script> +</div></div><p>In order to turn your fat jar into fat war, add the following class extending  <code><span>org</span><span>.apache.camel.spring.boot.F</span><code>atWarInitializer</code></code><span> </span>to your project:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example; +Â +... // imports + +public class MyFatWarInitializer extends FatWarInitializer { + + + @Override + protected Class<? extends FatJarRouter> routerClass() { + return MyFatJarRouter.class; + } + +}]]></script> </div></div><p><br clear="none"></p><h3 id="SpringBoot-SeeAlso">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></div> </td>