Author: buildbot
Date: Thu Mar 28 07:18:54 2013
New Revision: 856260

Log:
Production update by buildbot for camel

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

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

Modified: websites/production/camel/content/spring.html
==============================================================================
--- websites/production/camel/content/spring.html (original)
+++ websites/production/camel/content/spring.html Thu Mar 28 07:18:54 2013
@@ -247,6 +247,70 @@ xmlns:camel=<span class="code-quote">"ht
 <p>You can also use the ANT style for inclusion and exclusion, as mentioned 
above in the <tt>&lt;packageScan&gt;</tt> documentation.</p>
 
 
+<h2><a shape="rect" name="Spring-HowdoIimportroutesfromotherXMLfiles"></a>How 
do I import routes from other XML files</h2>
+<p><b>Available as of Camel 2.3</b></p>
+
+<p>When defining routes in Camel using <a shape="rect" 
href="xml-configuration.html" title="Xml Configuration">Xml Configuration</a> 
you may want to define some routes in other XML files. For example you may have 
many routes and it may help to maintain the application if some of the routes 
are in separate XML files. You may also want to store common and reusable 
routes in other XML files, which you can simply import when needed.</p>
+
+<p>In <b>Camel 2.3</b> it is now possible to define routes outside 
<tt>&lt;camelContext/&gt;</tt> which you do in a new 
<tt>&lt;routeContext/&gt;</tt> tag.</p>
+
+<p>For example we could have a file named <tt>myCoolRoutes.xml</tt> which 
contains a couple of routes as shown:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeHeader 
panelHeader" style="border-bottom-width: 
1px;"><b>myCoolRoutes.xml</b></div><div class="codeContent panelContent">
+<pre class="code-xml">&lt;beans xmlns=<span 
class="code-quote">"http://www.springframework.org/schema/beans";</span>
+       <span class="code-keyword">xmlns:xsi</span>=<span 
class="code-quote">"http://www.w3.org/2001/XMLSchema-instance";</span>
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    "&gt;
+
+    <span class="code-tag"><span class="code-comment">&lt;!-- this is an 
included XML file where we only the the routeContext --&gt;</span></span>
+    <span class="code-tag">&lt;routeContext id=<span 
class="code-quote">"myCoolRoutes"</span> xmlns=<span 
class="code-quote">"http://camel.apache.org/schema/spring";</span>&gt;</span>
+        <span class="code-tag"><span class="code-comment">&lt;!-- we can have 
a route --&gt;</span></span>
+        <span class="code-tag">&lt;route id=<span 
class="code-quote">"cool"</span>&gt;</span>
+            <span class="code-tag">&lt;from uri=<span 
class="code-quote">"direct:start"</span>/&gt;</span>
+            <span class="code-tag">&lt;to uri=<span 
class="code-quote">"mock:result"</span>/&gt;</span>
+        <span class="code-tag">&lt;/route&gt;</span>
+        <span class="code-tag"><span class="code-comment">&lt;!-- and another 
route, you can have as many your like --&gt;</span></span>
+        <span class="code-tag">&lt;route id=<span 
class="code-quote">"bar"</span>&gt;</span>
+            <span class="code-tag">&lt;from uri=<span 
class="code-quote">"direct:bar"</span>/&gt;</span>
+            <span class="code-tag">&lt;to uri=<span 
class="code-quote">"mock:bar"</span>/&gt;</span>
+        <span class="code-tag">&lt;/route&gt;</span>
+    <span class="code-tag">&lt;/routeContext&gt;</span>
+
+<span class="code-tag">&lt;/beans&gt;</span>
+</pre>
+</div></div>
+
+
+<p>Then in your XML file which contains the CamelContext you can use Spring to 
import the <tt>myCoolRoute.xml</tt> file.<br clear="none">
+And then inside <tt>&lt;camelContext/&gt;</tt> you can refer to the 
<tt>&lt;routeContext/&gt;</tt> by its id as shown below:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<pre class="code-xml"><span class="code-tag"><span 
class="code-comment">&lt;!-- import the routes from another XML file 
--&gt;</span></span>
+<span class="code-tag">&lt;import resource=<span 
class="code-quote">"myCoolRoutes.xml"</span>/&gt;</span>
+
+<span class="code-tag">&lt;camelContext xmlns=<span 
class="code-quote">"http://camel.apache.org/schema/spring";</span>&gt;</span>
+
+    <span class="code-tag"><span class="code-comment">&lt;!-- refer to a given 
route to be used --&gt;</span></span>
+    <span class="code-tag">&lt;routeContextRef ref=<span 
class="code-quote">"myCoolRoutes"</span>/&gt;</span>
+
+    <span class="code-tag"><span class="code-comment">&lt;!-- we can of course 
still use routes inside camelContext --&gt;</span></span>
+    <span class="code-tag">&lt;route id=<span 
class="code-quote">"inside"</span>&gt;</span>
+        <span class="code-tag">&lt;from uri=<span 
class="code-quote">"direct:inside"</span>/&gt;</span>
+        <span class="code-tag">&lt;to uri=<span 
class="code-quote">"mock:inside"</span>/&gt;</span>
+    <span class="code-tag">&lt;/route&gt;</span>
+<span class="code-tag">&lt;/camelContext&gt;</span>
+</pre>
+</div></div>
+
+<p>Also notice that you can mix and match, having routes inside CamelContext 
and also externalized in RouteContext.</p>
+
+<p>You can have as many <tt>&lt;routeContextRef/&gt;</tt> as you like.</p>
+
+<div class="panelMacro"><table class="tipMacro"><colgroup span="1"><col 
span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" 
valign="top"><img align="middle" 
src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif"; 
width="16" height="16" alt="" border="0"></td><td colspan="1" 
rowspan="1"><b>Reusable routes</b><br clear="none">The routes defined in 
<tt>&lt;routeContext/&gt;</tt> can be reused by multiple 
<tt>&lt;camelContext/&gt;</tt>. However its only the definition which is 
reused. At runtime each CamelContext will create its own instance of the route 
based on the definition.</td></tr></table></div>
+
+
+
+
 <h4><a shape="rect" name="Spring-Testtimeexclusion."></a>Test time exclusion. 
</h4>
 
 <p>At test time it is often desirable to be able to selectively exclude 
matching routes from being initalized that are not applicable or useful to the 
test scenario. For instance you might a spring context file routes-context.xml 
and three Route builders RouteA, RouteB and RouteC in the 'org.example.routes' 
package. The packageScan definition would discover all three of these routes 
and initialize them.</p>
@@ -320,8 +384,7 @@ xmlns:camel=<span class="code-quote">"ht
 
 <h3><a shape="rect" name="Spring-Seealso"></a>See also</h3>
 
-<ul><li><a shape="rect" href="tutorial-jmsremoting.html" 
title="Tutorial-JmsRemoting">Spring JMS Tutorial</a></li><li><a shape="rect" 
href="creating-a-new-spring-based-camel-route.html" title="Creating a new 
Spring based Camel Route">Creating a new Spring based Camel 
Route</a></li><li><a shape="rect" href="spring-example.html" title="Spring 
Example">Spring example</a></li><li><a shape="rect" href="xml-reference.html" 
title="Xml Reference">Xml Reference</a></li><li><a shape="rect" 
href="advanced-configuration-of-camelcontext-using-spring.html" title="Advanced 
configuration of CamelContext using Spring">Advanced configuration of 
CamelContext using Spring</a></li></ul>
-
+<ul><li><a shape="rect" href="tutorial-jmsremoting.html" 
title="Tutorial-JmsRemoting">Spring JMS Tutorial</a></li><li><a shape="rect" 
href="creating-a-new-spring-based-camel-route.html" title="Creating a new 
Spring based Camel Route">Creating a new Spring based Camel 
Route</a></li><li><a shape="rect" href="spring-example.html" title="Spring 
Example">Spring example</a></li><li><a shape="rect" href="xml-reference.html" 
title="Xml Reference">Xml Reference</a></li><li><a shape="rect" 
href="advanced-configuration-of-camelcontext-using-spring.html" title="Advanced 
configuration of CamelContext using Spring">Advanced configuration of 
CamelContext using Spring</a></li><li><a shape="rect" 
href="how-do-i-import-routes-from-other-xml-files.html" title="How do I import 
routes from other XML files">How do I import routes from other XML 
files</a></li></ul>
 </div>
         </td>
         <td valign="top">


Reply via email to