Author: buildbot
Date: Mon Feb 13 20:18:39 2017
New Revision: 1006709

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/advicewith.html
    websites/production/camel/content/cache/main.pageCache

Modified: websites/production/camel/content/advicewith.html
==============================================================================
--- websites/production/camel/content/advicewith.html (original)
+++ websites/production/camel/content/advicewith.html Mon Feb 13 20:18:39 2017
@@ -86,7 +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 
<strong><code>adviceWith</code></strong> allows is to changes some factors on 
the route before the test is being run. At the 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 <strong><code>mock:foo</code></strong> endpoint and 
detour the message.</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 void testAdvised() throws Exception {
     // advice the first route using the inlined route builder
@@ -110,10 +110,10 @@ public void testAdvised() throws Excepti
     assertMockEndpointsSatisfied();
 }
 ]]></script>
-</div></div><div class="confluence-information-macro 
confluence-information-macro-warning"><p class="title">Recommendation</p><span 
class="aui-icon aui-icon-small aui-iconfont-error 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><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="confluence-information-macro 
confluence-information-macro-warning"><p class="title">Recommendation</p><span 
class="aui-icon aui-icon-small aui-iconfont-error 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>It's recommended to only advice 
routes which are not started already.<br clear="n
 one"> If you advice already started routes, then it may not work as 
expected.</p></div></div><div class="confluence-information-macro 
confluence-information-macro-tip"><p class="title">Telling Camel you are using 
adviceWith</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.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 speci
 fy 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 th
 e 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" cl
 ass="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>wea
 veById("(foo|bar)")</code> which will match both <code>"foo"</code> and 
<code>"bar"</code>.</p><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>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">
+</div></div><div class="confluence-information-macro 
confluence-information-macro-warning"><p class="title">Recommendation</p><span 
class="aui-icon aui-icon-small aui-iconfont-error 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><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 
<strong>Camel 3.0</strong> to support this as internal refactorings in the 
routing engine is needed to support this properly.</p></div></div><div 
class="confluence-information-macro confluence-information-macro-warning"><p 
class="title">Recommendation</p><span class="aui-icon aui-icon-small 
aui-iconfont-error confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>It's recommended to only advice 
routes which are not started alr
 eady. If you advice already started routes, then it may not work as 
expected.</p></div></div><div class="confluence-information-macro 
confluence-information-macro-tip"><p class="title">Telling Camel you are using 
adviceWith</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.9</strong>: 
it's recommended to override the 
<strong><code>isUseAdviceWith()</code></strong> method and return true to tell 
Camel you are using advice with in your unit tests. Then after you have done 
the <strong><code>adviceWith()</code></strong>, then you must start 
<strong><code>CamelContext</code></strong> manually. See further below for an 
example.</p></div></div><h3 
id="AdviceWith-UsingAdviceWithRouteBuilder">Using&#160;<code>AdviceWithRouteBuilder</code></h3><p><strong>Available
 as of Camel 2.7</strong></p><p>The 
<strong><code>AdviceWithRouteBuilder</code></strong> is a specialized <st
 rong><code>RouteBuilder</code></strong> 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 
<strong><code>AdviceWithRouteBuilder</code></strong> 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 deta
 ils 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" ro
 wspan="1" class="confluenceTd"><p>Is used to select nodes(s) matching by their 
<strong><code>toString</code></strong> 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&#160;<strong><code>org.apache.camel.model</code></strong> 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 
<strong><code>pattern</code></strong> 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&#160;<strong><code>weaveById("foo")</code></strong> which 
will match only the id in the route which has the value: 
<strong><code>foo</code></strong>. The wildcard is when the pattern ends with 
a&#160;<strong><code>*</code></strong> character, such 
 as:&#160;<strong><code>weaveById("foo*")</code></strong> which will match any 
id's starting with <strong><code>foo</code></strong>, such as: 
<strong><code>foo</code>, 
<code>foobar</code></strong>,&#160;<strong><code>foobie</code></strong> and so 
forth. The regular expression is more advanced and allows you to match multiple 
ids, such as&#160;<strong><code>weaveById("(foo|bar)")</code></strong> which 
will match both&#160;<strong><code>foo</code></strong> and 
<strong><code>bar</code></strong>.</p><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>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.</p><p>For 
example:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelConte
 nt pdl">
 <script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[mockEndpointsAndSkip(&quot;activemq:queue:foo?*&quot;)
 ]]></script>
-</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 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">
+</div></div><p>To match the&#160;<strong><code>foo</code></strong> queue and 
disregard any options.</p></div></div><h3 
id="AdviceWith-UsingweaveById">Using&#160;<code>weaveById</code></h3><p>The 
<strong><code>weaveById</code></strong> allows you to manipulate the route, for 
example by replacing a node with other nodes.</p><p>The following methods are 
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" cla
 ss="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 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="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
     .to(&quot;mock:foo&quot;)
     .to(&quot;mock:bar&quot;).id(&quot;bar&quot;)
@@ -130,7 +130,7 @@ context.getRouteDefinitions().get(0).adv
     }
 });
 ]]></script>
-</div></div>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.<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>In this example we replace the 
<strong><code>.to("mock:bar").id("bar")</code></strong> with the 
<strong><code>.multicast().to("mock:a").to("mock:b")</code></strong>.<br 
clear="none"> That means instead of sending the message to a 
<code><strong>mock:bar</strong></code> endpoint, we do a <a shape="rect" 
href="multicast.html">Multicast</a> to <code><strong>mock:a</strong></code> and 
<code><strong>mock:b</strong></code> endpoints instead.<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="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 context.getRouteDefinitions().get(0).adviceWith(context, new 
AdviceWithRouteBuilder() {
     @Override
@@ -140,7 +140,7 @@ context.getRouteDefinitions().get(0).adv
     }
 });
 ]]></script>
-</div></div>In the example above, we simply just remove the 
<code>.to("mock:bar").id("bar")</code>.<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>In the example above, we simply just remove the 
<strong><code>.to("mock:bar").id("bar")</code></strong>.<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="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 context.getRouteDefinitions().get(0).adviceWith(context, new 
AdviceWithRouteBuilder() {
     @Override
@@ -151,7 +151,7 @@ context.getRouteDefinitions().get(0).adv
     }
 });
 ]]></script>
-</div></div>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".<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>In the example above, we add the following nodes 
<strong><code>to("mock:a").transform(constant("Bye World"))</code> 
before</strong> the node with the id <strong><code>bar</code></strong>.<br 
clear="none"> That means the message being send to 
<strong><code>mock:bar</code></strong> would have been transformed to a 
constant message "<strong><code>Bye World</code></strong>".<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="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 context.getRouteDefinitions().get(0).adviceWith(context, new 
AdviceWithRouteBuilder() {
     @Override
@@ -162,7 +162,7 @@ context.getRouteDefinitions().get(0).adv
     }
 });
 ]]></script>
-</div></div>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>.<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 [ ] ( ) -&gt; 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 repl
 ace 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>In the example above, we add the following nodes 
<strong><code>to("mock:a").transform(constant("Bye World"))</code> 
after</strong> the node with the id&#160;<code><strong>bar</strong></code>.<h3 
id="AdviceWith-UsingweaveByToString">Using&#160;<code>weaveByToString</code></h3><p>The
 <strong><code>weaveByToString</code></strong> also allows you to manipulate 
the route, for example by replacing a node with other nodes. As opposed to 
<strong><code>weaveById</code></strong>, this method uses the 
<strong><code>toString</code></strong> 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. You have to be a bit 
more careful when using this as the <strong><code>toString</code></strong> 
representation can be verbose and contain characters such as <strong>[ ] ( 
)-&gt;</strong> and so forth. That is why using the regular expression matching 
is the must usable.</p><p>Th
 e <strong><code>weaveByToString</code></strong> has the same methods as 
<strong><code>weaveById</code></strong>.</p><p>For example to replace any nodes 
which has <code>"<strong>foo</strong>"</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="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 context.getRouteDefinitions().get(0).adviceWith(context, new 
AdviceWithRouteBuilder() {
     @Override
@@ -173,7 +173,7 @@ context.getRouteDefinitions().get(0).adv
     }
 });
 ]]></script>
-</div></div>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.<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>Notice that we have to use <code>".<strong>foo.</strong>"</code> 
in the pattern to match that <code>"<strong>foo</strong>"</code> is present 
anywhere in the string.<h3 
id="AdviceWith-UsingweaveByType">Using&#160;<code>weaveByType</code></h3><p><strong>Available
 as of Camel 2.8</strong></p><p>The <strong><code>weaveByToType</code></strong> 
also allows you to manipulate the route, for example by replacing a node with 
other nodes. As opposed to <strong><code>weaveById</code>, and 
</strong><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 
<strong><code>weaveByToType</code></strong> has the same methods as 
<strong><code>weaceById</code></strong> and 
<strong><code>weaveByToString</code></strong>.</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 p
 anelHeader pdl" style="border-bottom-width: 1px;"><b>Route</b></div><div 
class="codeContent panelContent pdl">
 <script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;)
     .transform(simple(&quot;Hello ${body}&quot;))
@@ -190,7 +190,7 @@ 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" 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">
+</div></div><h3 id="AdviceWith-UsingSelectors">Using 
Selectors</h3><p><strong>Available os of Camel 2.8</strong></p><p>The following 
methods <strong><code>weaveById(pattern)</code></strong>, 
<strong><code>weaveByToString(pattern)</code></strong> and 
<strong><code>weaveByType(Class)</code></strong> each match N+ nodes. By using 
optional selectors you can narrow down the nodes being used. For example if 
<strong><code>weaveByType(Class)</code></strong> 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>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 
<strong><code>.to</code></strong> 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="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context,
 new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
@@ -199,7 +199,7 @@ 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">
+</div></div><h3 
id="AdviceWith-UsingweaveAddFirst/weaveAddLast">Using&#160;<code>weaveAddFirst</code>
 /&#160;<code>weaveAddLast</code></h3><p><strong>Available as of Camel 
2.8</strong></p><p>The <strong><code>weaveAddFirst</code></strong> and 
<strong><code>weaveAddLast</code></strong> 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 <strong><code>mock:input</code></strong> endpoint you can do as 
follows:</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[context.getRouteDefinitions().get(0).adviceWith(context,
 new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
@@ -226,7 +226,7 @@ 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">
+</div></div><h3 
id="AdviceWith-ReplacefromWithAnotherEndpoint">Replace&#160;<code>from</code> 
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&#160;<strong><code>seda:foo</code></strong> 
endpoint:</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[context.getRouteDefinitions().get(0).adviceWith(context,
 new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
@@ -234,7 +234,7 @@ context.getRouteDefinitions().get(0).adv
     }
 });
 ]]></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> 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="error"><span 
class="error">Error formatting macro: snippet: 
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div></div>
+</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 
see: <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&#160;<code>isUseAdviceWith()</code></h3><p><strong>Available
 as of Camel 2.9</strong><br clear="none"> It is recommended to override the 
method <strong><code>isUseAdviceWith</code></strong> and return 
<strong><code>true</code></strong> to instruct Camel that you are using 
<strong><code>adviceWith</code></strong> in the unit tests. Then in your unit 
test methods, after you have 
 done the <strong><code>adviceWith</code></strong> you <strong>must</strong> 
start <strong><code>CamelContext</code></strong> by invoke the 
<strong><code>start</code></strong> 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="error"><span 
class="error">Error formatting macro: snippet: 
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.


Reply via email to