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><packageScan></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><camelContext/></tt> which you do in a new <tt><routeContext/></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"><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 + "> + + <span class="code-tag"><span class="code-comment"><!-- this is an included XML file where we only the the routeContext --></span></span> + <span class="code-tag"><routeContext id=<span class="code-quote">"myCoolRoutes"</span> xmlns=<span class="code-quote">"http://camel.apache.org/schema/spring"</span>></span> + <span class="code-tag"><span class="code-comment"><!-- we can have a route --></span></span> + <span class="code-tag"><route id=<span class="code-quote">"cool"</span>></span> + <span class="code-tag"><from uri=<span class="code-quote">"direct:start"</span>/></span> + <span class="code-tag"><to uri=<span class="code-quote">"mock:result"</span>/></span> + <span class="code-tag"></route></span> + <span class="code-tag"><span class="code-comment"><!-- and another route, you can have as many your like --></span></span> + <span class="code-tag"><route id=<span class="code-quote">"bar"</span>></span> + <span class="code-tag"><from uri=<span class="code-quote">"direct:bar"</span>/></span> + <span class="code-tag"><to uri=<span class="code-quote">"mock:bar"</span>/></span> + <span class="code-tag"></route></span> + <span class="code-tag"></routeContext></span> + +<span class="code-tag"></beans></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><camelContext/></tt> you can refer to the <tt><routeContext/></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"><!-- import the routes from another XML file --></span></span> +<span class="code-tag"><import resource=<span class="code-quote">"myCoolRoutes.xml"</span>/></span> + +<span class="code-tag"><camelContext xmlns=<span class="code-quote">"http://camel.apache.org/schema/spring"</span>></span> + + <span class="code-tag"><span class="code-comment"><!-- refer to a given route to be used --></span></span> + <span class="code-tag"><routeContextRef ref=<span class="code-quote">"myCoolRoutes"</span>/></span> + + <span class="code-tag"><span class="code-comment"><!-- we can of course still use routes inside camelContext --></span></span> + <span class="code-tag"><route id=<span class="code-quote">"inside"</span>></span> + <span class="code-tag"><from uri=<span class="code-quote">"direct:inside"</span>/></span> + <span class="code-tag"><to uri=<span class="code-quote">"mock:inside"</span>/></span> + <span class="code-tag"></route></span> +<span class="code-tag"></camelContext></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><routeContextRef/></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><routeContext/></tt> can be reused by multiple <tt><camelContext/></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">