Author: buildbot
Date: Thu Nov 10 21:18:57 2016
New Revision: 1000900
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/how-do-i-import-routes-from-other-xml-files.html
websites/production/camel/content/spring.html
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified:
websites/production/camel/content/how-do-i-import-routes-from-other-xml-files.html
==============================================================================
---
websites/production/camel/content/how-do-i-import-routes-from-other-xml-files.html
(original)
+++
websites/production/camel/content/how-do-i-import-routes-from-other-xml-files.html
Thu Nov 10 21:18:57 2016
@@ -49,7 +49,7 @@
</script>
<title>
- Apache Camel: How do I import routes from other XML files
+ Apache Camel: How Do I Import Routes From Other XML Files
</title>
</head>
<body>
@@ -75,7 +75,7 @@
<div class="top_red_bar">
<div id="site-breadcrumbs">
<!-- Breadcrumbs -->
-<a href="index.html">Apache Camel</a> > <a
href="community.html">Community</a> > <a
href="faq.html">FAQ</a> > <a
href="using-camel-questions.html">Using Camel Questions</a> > <a
href="how-do-i-import-routes-from-other-xml-files.html">How do I import routes
from other XML files</a>
+<a href="index.html">Apache Camel</a> > <a
href="community.html">Community</a> > <a
href="faq.html">FAQ</a> > <a
href="using-camel-questions.html">Using Camel Questions</a> > <a
href="how-do-i-import-routes-from-other-xml-files.html">How Do I Import Routes
From Other XML Files</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" class="external-link"
href="https://github.com/apache/camel/" rel="nofollow">Github</a> | <a
shape="rect" href="discussion-forums.html">Forums</a> | <a shape="rect"
href="support.html">Support</a></p></div>
@@ -86,18 +86,7 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2
id="HowdoIimportroutesfromotherXMLfiles-HowdoIimportroutesfromotherXMLfiles">How
do I import routes from other XML files</h2>
-<p><strong>Available as of Camel 2.3</strong></p>
-
-<p>When defining routes in Camel using <a shape="rect"
href="xml-configuration.html">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 <strong>Camel 2.3</strong> it is now possible to define routes outside
<code><camelContext/></code> which you do in a new
<code><routeContext/></code> tag.</p>
-
-<div class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body">
-<p><strong>Notice:</strong> When you use <routeContext> then they are
separated, and cannot reuse existing <onException>, <intercept>,
<dataFormats> and similar cross cutting functionality defined in the
<camelContext>. In other words the <routeContext> is currently
isolated. This may change in Camel 3.x.</p></div></div>
-
-<p>For example we could have a file named <code>myCoolRoutes.xml</code> which
contains a couple of routes as shown:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width:
1px;"><b>myCoolRoutes.xml</b></div><div class="codeContent panelContent pdl">
+<div class="wiki-content maincontent"><h2
id="HowDoIImportRoutesFromOtherXMLFiles-HowdoIimportroutesfromotherXMLfiles">How
do I import routes from other XML files</h2><p><strong>Available as of Camel
2.3</strong></p><p>When defining routes in Camel using <a shape="rect"
href="xml-configuration.html">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 <strong>Camel 2.3</strong> it is
now possible to define routes outside
<strong><code><camelContext/></code></strong> which you do in a new
<strong><code><routeContext/></code></strong> tag.</p><div
class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information
-macro-icon"></span><div
class="confluence-information-macro-body"><p><strong>Notice:</strong> When you
use <strong><code><routeContext></code></strong> then they are
separated, and cannot reuse existing
<strong><code><onException></code></strong>,
<strong><code><intercept></code></strong>, <strong><code><dataFormats></code></strong>
and similar cross cutting functionality defined in the
<strong><code><camelContext></code></strong>. In other words
the <strong><code><routeContext></code></strong> is currently
isolated. This may change in Camel 3.x.</p></div></div><p>For example we could
have a file named <strong><code>myCoolRoutes.xml</code></strong> which contains
a couple of routes as shown:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>myCoolRoutes.xml</b></div><div
class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -122,12 +111,7 @@
</beans>
]]></script>
-</div></div>
-
-
-<p>Then in your XML file which contains the CamelContext you can use Spring to
import the <code>myCoolRoute.xml</code> file.<br clear="none">
-And then inside <code><camelContext/></code> you can refer to the
<code><routeContext/></code> by its id as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div>Then in your XML file which contains the CamelContext you can use
Spring to import the <strong><code>myCoolRoute.xml</code></strong> file. And
then inside <strong><code><camelContext/></code></strong> you can refer
to the <strong><code><routeContext/></code></strong> by
its <strong><code>id</code></strong> as shown below:<div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<!-- import the routes from another XML file -->
<import resource="myCoolRoutes.xml"/>
@@ -144,15 +128,7 @@ And then inside <code><camelContext/&
</route>
</camelContext>
]]></script>
-</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 <code><routeContextRef/></code> as you like.</p>
-
-<div class="confluence-information-macro confluence-information-macro-tip"><p
class="title">Reusable routes</p><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><div
class="confluence-information-macro-body">
-<p>The routes defined in <code><routeContext/></code> can be reused by
multiple <code><camelContext/></code>. However its only the definition
which is reused. At runtime each CamelContext will create its own instance of
the route based on the definition.</p></div></div>
-</div>
+</div></div>Also notice that you can mix and match, having routes
inside <strong><code>CamelContext</code></strong> and also externalized in
<strong><code>RouteContext</code></strong>.<p>You can have as many
<strong><code><routeContextRef/></code></strong> as you like.</p><div
class="confluence-information-macro confluence-information-macro-tip"><p
class="title">Reusable routes</p><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The routes defined in
<strong><code><routeContext/></code></strong> can be reused by multiple
<strong><code><camelContext/></code></strong>. However its only the
definition which is reused. At runtime
each <strong><code>CamelContext</code></strong> will create its own
instance of the route based on the definition.</p></div></div></div>
</td>
<td valign="top">
<div class="navigation">
Modified: websites/production/camel/content/spring.html
==============================================================================
--- websites/production/camel/content/spring.html (original)
+++ websites/production/camel/content/spring.html Thu Nov 10 21:18:57 2016
@@ -86,13 +86,13 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="Spring-SpringSupport">Spring
Support</h2><p>Apache Camel is designed to work nicely with the <a shape="rect"
class="external-link" href="http://www.springframework.org/"
rel="nofollow">Spring Framework</a> in a number of ways.</p><ul><li>Camel uses
Spring Transactions as the default transaction handling in components like <a
shape="rect" href="jms.html">JMS</a> and <a shape="rect"
href="jpa.html">JPA</a></li><li>Camel works with Spring 2 XML processing with
the <a shape="rect" href="xml-configuration.html">Xml
Configuration</a></li><li>Camel Spring XML Schema's is defined at <a
shape="rect" href="xml-reference.html">Xml Reference</a></li><li>Camel supports
a powerful version of <a shape="rect" href="spring-remoting.html">Spring
Remoting</a> which can use powerful routing between the client and server side
along with using all of the available <a shape="rect"
href="components.html">Components</a> for the transport</li><li>Camel provides p
owerful <a shape="rect" href="bean-integration.html">Bean Integration</a> with
any bean defined in a Spring ApplicationContext</li><li>Camel integrates with
various Spring helper classes; such as providing <a shape="rect"
href="type-converter.html">Type Converter</a> support for Spring Resources
etc</li><li>Allows Spring to dependency inject <a shape="rect"
href="component.html">Component</a> instances or the <a shape="rect"
href="camelcontext.html">CamelContext</a> instance itself and auto-expose
Spring beans as components and endpoints.</li><li>Allows you to reuse the <a
shape="rect" href="spring-testing.html">Spring Testing</a> framework to
simplify your unit and integration testing using <a shape="rect"
href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a>
and Camel's powerful <a shape="rect" href="mock.html">Mock</a> and <a
shape="rect" href="test.html">Test</a>
endpoints</li><li>From <strong>Camel 2.15</strong> onwards Camel supports
Spring Boot
using the <code><a shape="rect"
href="spring-boot.html">camel-spring-boot</a></code>
component.</li><li>From <strong>Camel 2.17.1 </strong>onwards Camel
supports Spring Cache based Idempotent repository</li></ul><h2
id="Spring-UsingSpringtoconfiguretheCamelContext">Using Spring to configure the
CamelContext</h2><p>You can configure a CamelContext inside any spring.xml
using the <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-spring/apidocs/org/apache/camel/spring/CamelContextFactoryBean.html">CamelContextFactoryBean</a>.
This will automatically <a shape="rect" href="lifecycle.html">start</a> the <a
shape="rect" href="camelcontext.html">CamelContext</a> along with any
referenced <a shape="rect" href="routes.html">Routes</a> along any referenced
<a shape="rect" href="component.html">Component</a> and <a shape="rect"
href="endpoint.html">Endpoint</a> instances.</p><ul><li>Adding Camel
schema</li><li>Configure <a shape="rect" href="
routes.html">Routes</a> in two ways:<ul><li>Using Java Code</li><li>Using
Spring XML</li></ul></li></ul><h3 id="Spring-AddingCamelSchema">Adding Camel
Schema</h3><div class="confluence-information-macro
confluence-information-macro-note"><span class="aui-icon aui-icon-small
aui-iconfont-warning confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>For Camel 1.x you need to use the
following namespace:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<div class="wiki-content maincontent"><h2 id="Spring-SpringSupport">Spring
Support</h2><p>Apache Camel is designed to work nicely with the <a shape="rect"
class="external-link" href="http://www.springframework.org/"
rel="nofollow">Spring Framework</a> in a number of ways.</p><ul><li>Camel uses
Spring Transactions as the default transaction handling in components like <a
shape="rect" href="jms.html">JMS</a> and <a shape="rect"
href="jpa.html">JPA</a></li><li>Camel works with Spring 2 XML processing with
the <a shape="rect" href="xml-configuration.html">Xml
Configuration</a></li><li>Camel Spring XML Schema's is defined at <a
shape="rect" href="xml-reference.html">Xml Reference</a></li><li>Camel supports
a powerful version of <a shape="rect" href="spring-remoting.html">Spring
Remoting</a> which can use powerful routing between the client and server side
along with using all of the available <a shape="rect"
href="components.html">Components</a> for the transport</li><li>Camel provides p
owerful <a shape="rect" href="bean-integration.html">Bean Integration</a> with
any bean defined in a Spring
<strong><code>ApplicationContext</code></strong>.</li><li>Camel integrates with
various Spring helper classes; such as providing <a shape="rect"
href="type-converter.html">Type Converter</a> support for Spring Resources
etc</li><li>Allows Spring to dependency inject <a shape="rect"
href="component.html">Component</a> instances or the <a shape="rect"
href="camelcontext.html">CamelContext</a> instance itself and auto-expose
Spring beans as components and endpoints.</li><li>Allows you to reuse the <a
shape="rect" href="spring-testing.html">Spring Testing</a> framework to
simplify your unit and integration testing using <a shape="rect"
href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a>
and Camel's powerful <a shape="rect" href="mock.html">Mock</a> and <a
shape="rect" href="test.html">Test</a>
endpoints</li><li>From <strong>Camel 2.15</strong>: Cam
el supports Spring Boot using the <code><a shape="rect"
href="spring-boot.html">camel-spring-boot</a></code>
component.</li><li>From <strong>Camel 2.17.1</strong>: Camel supports
Spring Cache based Idempotent repository</li></ul><h2
id="Spring-UsingSpringtoconfiguretheCamelContext">Using Spring to configure the
CamelContext</h2><p>You can configure
a <strong><code>CamelContext</code></strong> inside
any <strong><code>spring.xml</code></strong> using the <a shape="rect"
class="external-link"
href="http://camel.apache.org/maven/current/camel-spring/apidocs/org/apache/camel/spring/CamelContextFactoryBean.html">CamelContextFactoryBean</a>.
This will automatically <a shape="rect" href="lifecycle.html">start</a> the <a
shape="rect" href="camelcontext.html">CamelContext</a> along with any
referenced <a shape="rect" href="routes.html">Routes</a> along any referenced
<a shape="rect" href="component.html">Component</a> and <a shape="rect"
href="endpoint.html">Endpoint</a>
instances.</p><ul><li>Adding Camel schema</li><li>Configure <a shape="rect"
href="routes.html">Routes</a> in two ways:<ul><li>Using Java Code</li><li>Using
Spring XML</li></ul></li></ul><h3 id="Spring-AddingCamelSchema">Adding Camel
Schema</h3><div class="confluence-information-macro
confluence-information-macro-note"><span class="aui-icon aui-icon-small
aui-iconfont-warning confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>For Camel 1.x you need to use the
following namespace:</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[http://activemq.apache.org/camel/schema/spring
]]></script>
</div></div><p>with the following schema location:</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[http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
]]></script>
-</div></div></div></div><p>You need to add Camel to the
<code>schemaLocation</code> declaration</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div></div></div><p>You need to add Camel to the
<strong><code>schemaLocation</code></strong> declaration</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[http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
]]></script>
</div></div><p>So the XML file looks like this:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -102,7 +102,7 @@
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">
]]></script>
-</div></div><h4 id="Spring-Usingcamel:namespace">Using camel:
namespace</h4><p>Or you can refer to camel XSD in the XML declaration:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h4
id="Spring-Usingcamel:Namespace">Using <code>camel:</code>
Namespace</h4><p>Or you can refer to the camel XSD in the XML
declaration:</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[xmlns:camel="http://camel.apache.org/schema/spring"
]]></script>
</div></div><p>... so the declaration is:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -114,13 +114,13 @@
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">
]]></script>
-</div></div>... and then use the camel: namespace prefix, and you can omit the
inline namespace declaration:<div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div>... and then use the <strong><code>camel:</code></strong>
namespace prefix, and you can omit the inline namespace declaration:<div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<camel:camelContext id="camel5">
<camel:package>org.apache.camel.spring.example</camel:package>
</camel:camelContext>
]]></script>
-</div></div><h4 id="Spring-AdvancedconfigurationusingSpring">Advanced
configuration using Spring</h4><p>See more details at <a shape="rect"
href="advanced-configuration-of-camelcontext-using-spring.html">Advanced
configuration of CamelContext using Spring</a></p><h3
id="Spring-UsingJavaCode">Using Java Code</h3><p>You can use Java Code to
define your <a shape="rect" href="routebuilder.html">RouteBuilder</a>
implementations. These can be defined as beans in spring and then referenced in
your camel context e.g.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><h4 id="Spring-AdvancedConfigurationUsingSpring">Advanced
Configuration Using Spring</h4><p>See more details at <a shape="rect"
href="advanced-configuration-of-camelcontext-using-spring.html">Advanced
configuration of CamelContext using Spring</a></p><h3
id="Spring-UsingJavaCode">Using Java Code</h3><p>You can use Java Code to
define your <a shape="rect" href="routebuilder.html">RouteBuilder</a>
implementations. These can be defined as beans in spring and then referenced in
your camel context e.g.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<camelContext id="camel5"
xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="myBuilder" />
@@ -130,12 +130,12 @@
</beans>
]]></script>
-</div></div><h4 id="Spring-Using<package>">Using
<package></h4><p>Camel also provides a powerful feature that allows for
the automatic discovery and initialization of routes in given packages. This is
configured by adding tags to the camel context in your spring context
definition, specifying the packages to be recursively searched for <a
shape="rect" href="routebuilder.html">RouteBuilder</a> implementations. To use
this feature in 1.X, requires a <package></package> tag specifying
a comma separated list of packages that should be searched e.g.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h4
id="Spring-Using<package>">Using <code><package></code></h4><p>Camel
also provides a powerful feature that allows for the automatic discovery and
initialization of routes in given packages. This is configured by adding tags
to the camel context in your spring context definition, specifying the packages
to be recursively searched for <a shape="rect"
href="routebuilder.html">RouteBuilder</a> implementations. To use this feature
in <strong><code>1.X</code></strong>, requires
a <strong><code><package></package></code></strong> tag
specifying a comma separated list of packages that should be searched
e.g.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[ <camelContext
xmlns="http://camel.apache.org/schema/spring">
<package>org.apache.camel.spring.config.scan.route</package>
</camelContext>
]]></script>
-</div></div><div class="confluence-information-macro
confluence-information-macro-warning"><span class="aui-icon aui-icon-small
aui-iconfont-error confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Use caution when specifying the
package name as <code>org.apache.camel</code> or a sub package of this. This
causes Camel to search in its own packages for your routes which could cause
problems.</p></div></div><div class="confluence-information-macro
confluence-information-macro-information"><p class="title">Will ignore already
instantiated classes</p><span class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The <package> and
<packageScan> will skip any classes which has already been created by
Spring etc. So if you define a route builder as a spring bean tag then that
class will be skipped. You can include those beans using <code><routeBuilder
ref="theBeanId"/></code> or the <code><contextScan></code>
feature.</p></div></div><h4 id="Spring-Using<packageScan>">Using
<packageScan></h4><p>In Camel 2.0 this has been extended to allow
selective inclusion and exclusion of discovered route classes using Ant like
path matching. In spring this is specified by adding a <packageScan/>
tag. The tag must contain one or more 'package' elements (similar to 1.x), and
optionally one or more 'includes' or 'excludes' elements specifying patterns to
be applied to the fully qualified names of the discovered classes. e.g.</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"><span class="aui-icon aui-icon-small
aui-iconfont-error confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Use caution when specifying the
package name as <strong><code>org.apache.camel</code></strong> or a sub package
of this. This causes Camel to search in its own packages for your routes which
could cause problems.</p></div></div><div class="confluence-information-macro
confluence-information-macro-information"><p class="title">Will ignore already
instantiated classes</p><span class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The <strong><code><package></code></strong>
and <strong><code><packageScan></code></strong> will skip any
classes which has already been created by Spring etc. So if you define a route
builder as a spring bean tag the
n that class will be skipped. You can include those beans using
<strong><code><routeBuilder ref="theBeanId"/></code></strong> or the
<strong><code><contextScan></code></strong> feature.</p></div></div><h4
id="Spring-Using<packageScan>">Using <code><packageScan></code></h4><p>In
Camel 2.0 this has been extended to allow selective inclusion and exclusion of
discovered route classes using Ant like path matching. In spring this is
specified by adding a <strong><code><packageScan/></code></strong>
tag. The tag must contain one or
more <strong><code>package</code></strong> elements (similar to
<strong><code>1.x</code></strong>), and optionally one or
more <strong><code>includes</code></strong>
or <strong><code>excludes</code></strong> elements specifying patterns to
be applied to the fully qualified names of the discovered classes.
e.g.,</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl
">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[ <camelContext
xmlns="http://camel.apache.org/schema/spring">
<packageScan>
<package>org.example.routes</package>
@@ -144,12 +144,12 @@
</packageScan>
</camelContext>
]]></script>
-</div></div><p>Exclude patterns are applied before the include patterns. If no
include or exclude patterns are defined then all the Route classes discovered
in the packages will be returned.</p><p>In the above example, camel will scan
all the 'org.example.routes' package and any subpackages for RouteBuilder
classes. Say the scan finds two RouteBuilders, one in org.example.routes called
'MyRoute" and another 'MyExcludedRoute' in a subpackage 'excluded'. The fully
qualified names of each of the classes are extracted
(org.example.routes.MyRoute, org.example.routes.excluded.MyExcludedRoute) and
the include and exclude patterns are applied.</p><p>The exclude pattern
**.*Excluded* is going to match the fqcn
'org.example.routes.excluded.MyExcludedRoute' and veto camel from initializing
it.</p><p>Under the covers, this is using Spring's <a shape="rect"
class="external-link"
href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/util/AntPathMatcher.html"
rel="nofol
low">AntPatternMatcher</a> implementation, which matches as follows</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p>Exclude patterns are applied before the include patterns. If no
include or exclude patterns are defined then all the Route classes discovered
in the packages will be returned.</p><p>In the above example, camel will scan
all the <strong><code>org.example.routes</code></strong> package and any
subpackages for <strong><code>RouteBuilder</code></strong> classes. Say
the scan finds two <strong><code>RouteBuilders</code></strong>, one
in <strong><code>org.example.routes</code></strong>
called <strong><code>MyRoute</code></strong> and
another <strong><code>MyExcludedRoute</code></strong> in a subpackage
<strong><code>excluded</code></strong>. The fully qualified names of each of
the classes are extracted
(<strong><code>org.example.routes.MyRoute</code></strong>, <strong><code>org.example.routes.excluded.MyExcludedRoute</code></strong>
) and the include and exclude patterns are applied.</p><p>The exclude
pattern <strong><code>**.*Excluded*</
code></strong> is going to match the FQCN
<strong><code>org.example.routes.excluded.MyExcludedRoute</code></strong> and
veto camel from initializing it.</p><p>Under the covers, this is using Spring's
<a shape="rect" class="external-link"
href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/util/AntPathMatcher.html"
rel="nofollow">AntPatternMatcher</a> implementation, which matches 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[? matches one character
* matches zero or more characters
** matches zero or more segments of a fully qualified name
]]></script>
-</div></div><p>For example:</p><p>**.*Excluded* would match
org.simple.Excluded, org.apache.camel.SomeExcludedRoute or
org.example.RouteWhichIsExcluded</p><p>**.??cluded* would match
org.simple.IncludedRoute, org.simple.Excluded but not match
org.simple.PrecludedRoute</p><h4 id="Spring-UsingcontextScan">Using
contextScan</h4><p><strong>Available as of Camel 2.4</strong></p><p>You can
allow Camel to scan the container context, e.g. the Spring
<code>ApplicationContext</code> for route builder instances. This allow you to
use the Spring <code><component-scan></code> feature and have Camel
pickup any RouteBuilder instances which was created by Spring in its scan
process.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>For example:</p><p><strong><code>**.*Excluded*</code></strong>
would match
<strong><code>org.simple.Excluded</code></strong>, <strong><code>org.apache.camel.SomeExcludedRoute</code></strong>
or
<strong><code>org.example.RouteWhichIsExcluded</code></strong>.</p><p><strong><code>**.??cluded*</code></strong>
would match
<strong><code>org.simple.IncludedRoute</code></strong>, <strong><code>org.simple.Excluded</code></strong>
but <em>not</em> match
<strong><code>org.simple.PrecludedRoute</code></strong>.</p><h4
id="Spring-UsingcontextScan">Using <code>contextScan</code></h4><p><strong>Available
as of Camel 2.4</strong></p><p>You can allow Camel to scan the container
context, e.g. the Spring <strong><code>ApplicationContext</code></strong> for
route builder instances. This allow you to use the Spring
<strong><code><component-scan></code></strong> feature and have Camel
pickup any <strong><code>RouteBuilder</code></strong> instances which was
create
d by Spring in its scan process.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<!-- enable Spring @Component scan -->
<context:component-scan
base-package="org.apache.camel.spring.issues.contextscan"/>
@@ -159,28 +159,18 @@
<contextScan/>
</camelContext>
]]></script>
-</div></div>This allows you to just annotate your routes using the Spring
<code>@Component</code> and have those routes included by Camel<div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>This allows you to just annotate your routes using the Spring
<strong><code>@Component</code></strong> and have those routes included by
Camel:<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[@Component
public class MyRoute extends SpringRouteBuilder {
@Override
public void configure() throws Exception {
- from("direct:start").to("mock:result");
+ from("direct:start")
+ .to("mock:result");
}
}
]]></script>
-</div></div><p>You can also use the ANT style for inclusion and exclusion, as
mentioned above in the <code><packageScan></code>
documentation.</p><p></p><h2
id="Spring-HowdoIimportroutesfromotherXMLfiles">How do I import routes from
other XML files</h2>
-<p><strong>Available as of Camel 2.3</strong></p>
-
-<p>When defining routes in Camel using <a shape="rect"
href="xml-configuration.html">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 <strong>Camel 2.3</strong> it is now possible to define routes outside
<code><camelContext/></code> which you do in a new
<code><routeContext/></code> tag.</p>
-
-<div class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body">
-<p><strong>Notice:</strong> When you use <routeContext> then they are
separated, and cannot reuse existing <onException>, <intercept>,
<dataFormats> and similar cross cutting functionality defined in the
<camelContext>. In other words the <routeContext> is currently
isolated. This may change in Camel 3.x.</p></div></div>
-
-<p>For example we could have a file named <code>myCoolRoutes.xml</code> which
contains a couple of routes as shown:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width:
1px;"><b>myCoolRoutes.xml</b></div><div class="codeContent panelContent pdl">
+</div></div><p>You can also use the ANT style for inclusion and exclusion, as
mentioned above in the <strong><code><packageScan></code></strong>
documentation.</p><p></p><h2
id="Spring-HowdoIimportroutesfromotherXMLfiles">How do I import routes from
other XML files</h2><p><strong>Available as of Camel 2.3</strong></p><p>When
defining routes in Camel using <a shape="rect"
href="xml-configuration.html">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 <strong>Camel 2.3</strong> it is
now possible to define routes outside
<strong><code><camelContext/></code></strong> which you do in a new
<strong><code><routeContext/></code></strong> tag.</p><div
class="confluence-information-macro confluence
-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p><strong>Notice:</strong> When you
use <strong><code><routeContext></code></strong> then they are
separated, and cannot reuse existing
<strong><code><onException></code></strong>,
<strong><code><intercept></code></strong>, <strong><code><dataFormats></code></strong>
and similar cross cutting functionality defined in the
<strong><code><camelContext></code></strong>. In other words
the <strong><code><routeContext></code></strong> is currently
isolated. This may change in Camel 3.x.</p></div></div><p>For example we could
have a file named <strong><code>myCoolRoutes.xml</code></strong> which contains
a couple of routes as shown:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>
myCoolRoutes.xml</b></div><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -205,12 +195,7 @@ public class MyRoute extends SpringRoute
</beans>
]]></script>
-</div></div>
-
-
-<p>Then in your XML file which contains the CamelContext you can use Spring to
import the <code>myCoolRoute.xml</code> file.<br clear="none">
-And then inside <code><camelContext/></code> you can refer to the
<code><routeContext/></code> by its id as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div>Then in your XML file which contains the CamelContext you can use
Spring to import the <strong><code>myCoolRoute.xml</code></strong> file. And
then inside <strong><code><camelContext/></code></strong> you can refer
to the <strong><code><routeContext/></code></strong> by
its <strong><code>id</code></strong> as shown below:<div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<!-- import the routes from another XML file -->
<import resource="myCoolRoutes.xml"/>
@@ -227,15 +212,7 @@ And then inside <code><camelContext/&
</route>
</camelContext>
]]></script>
-</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 <code><routeContextRef/></code> as you like.</p>
-
-<div class="confluence-information-macro confluence-information-macro-tip"><p
class="title">Reusable routes</p><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><div
class="confluence-information-macro-body">
-<p>The routes defined in <code><routeContext/></code> can be reused by
multiple <code><camelContext/></code>. However its only the definition
which is reused. At runtime each CamelContext will create its own instance of
the route based on the definition.</p></div></div>
-<h4 id="Spring-Testtimeexclusion.">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><p>Say RouteC is not applicable to our test scenario and generates a
lot of noise during test. It would be nice to be able to exclude this route
from this specific test. The SpringTestSupport class has been modified to allow
this. It provides two methods (excludedRoute and excludedRoutes) that may be
overridden to exclude a single class or an array of classes.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div>Also notice that you can mix and match, having routes
inside <strong><code>CamelContext</code></strong> and also externalized in
<strong><code>RouteContext</code></strong>.<p>You can have as many
<strong><code><routeContextRef/></code></strong> as you like.</p><div
class="confluence-information-macro confluence-information-macro-tip"><p
class="title">Reusable routes</p><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The routes defined in
<strong><code><routeContext/></code></strong> can be reused by multiple
<strong><code><camelContext/></code></strong>. However its only the
definition which is reused. At runtime
each <strong><code>CamelContext</code></strong> will create its own
instance of the route based on the definition.</p></div></div><h4
id="Spring-TestTimeExclusion.">Test Time Exclusion.</h4><p>At test time it is
often desirable to be
able to selectively exclude matching routes from being initialized that are
not applicable or useful to the test scenario. For instance you might a spring
context file <strong><code>routes-context.xml</code></strong> and three
Route builders <strong><code>RouteA</code>, </strong><code>RouteB</code>
and <strong><code>RouteC</code></strong> in
the <strong><code>org.example.routes</code></strong> package.
The <strong><code>packageScan</code></strong> definition would discover
all three of these routes and initialize
them.</p><p>Say <strong><code>RouteC</code></strong> is not applicable to
our test scenario and generates a lot of noise during test. It would be nice to
be able to exclude this route from this specific test.
The <strong><code>SpringTestSupport</code></strong> class has been
modified to allow this. It provides two methods
(<strong><code>excludedRoute</code></strong> and
<strong><code>excludedRoutes</code></strong>) that may be overridden t
o exclude a single class or an array of classes.</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 class RouteAandRouteBOnlyTest extends
SpringTestSupport {
@Override
protected Class excludeRoute() {
@@ -243,13 +220,13 @@ And then inside <code><camelContext/&
}
}
]]></script>
-</div></div><p>In order to hook into the camelContext initialization by spring
to exclude the MyExcludedRouteBuilder.class we need to intercept the spring
context creation. When overriding createApplicationContext to create the spring
context, we call the getRouteExcludingApplicationContext() method to provide a
special parent spring context that takes care of the exclusion.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p>In order to hook into
the <strong><code>camelContext</code></strong> initialization by spring to
exclude the <strong><code>MyExcludedRouteBuilder.class</code></strong> we
need to intercept the spring context creation. When
overriding <strong><code>createApplicationContext</code></strong> to
create the spring context, we call
the <strong><code>getRouteExcludingApplicationContext()</code></strong>
method to provide a special parent spring context that takes care of the
exclusion.</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[@Override
protected AbstractXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext(new String[]
{"routes-context.xml"}, getRouteExcludingApplicationContext());
}
]]></script>
-</div></div><p>RouteC will now be excluded from initialization. Similarly, in
another test that is testing only RouteC, we could exclude RouteB and RouteA by
overriding</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p><strong><code>RouteC</code></strong> will now be excluded from
initialization. Similarly, in another test that is testing only
<strong><code>RouteC</code></strong>, we could
exclude <strong><code>RouteB</code></strong>
and <strong><code>RouteA</code></strong> by overriding:</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[@Override
protected Class[] excludeRoutes() {
return new Class[]{RouteA.class, RouteB.class};
@@ -278,7 +255,7 @@ protected Class[] excludeRoutes() {
</property>
</bean>
]]></script>
-</div></div>Which allows you to configure a component using some name
(activemq in the above example), then you can refer to the component using
<strong>activemq:[queue:|topic:]destinationName</strong>. This works by the
SpringCamelContext lazily fetching components from the spring context for the
scheme name you use for <a shape="rect" href="endpoint.html">Endpoint</a> <a
shape="rect" href="uris.html">URIs</a>.<p>For more detail see <a shape="rect"
href="how-do-i-configure-endpoints.html">Configuring Endpoints and
Components</a>.</p><h2 id="Spring-SpringCacheidempotentrepository">Spring Cache
idempotent repository</h2><p>Available as of <strong>Camel
2.17.1</strong></p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div>Which allows you to configure a component using some name
(<strong><code>activemq</code></strong> in the above example), then you can
refer to the component using
<strong><code>activemq:[queue:|topic:]destinationName</code></strong>. This
works by the <strong><code>SpringCamelContext</code></strong> lazily
fetching components from the spring context for the scheme name you use for <a
shape="rect" href="endpoint.html">Endpoint</a> <a shape="rect"
href="uris.html">URIs</a>.<p>For more detail see <a shape="rect"
href="how-do-i-configure-endpoints.html">Configuring Endpoints and
Components</a>.</p><h2 id="Spring-SpringCacheIdempotentRepository">Spring Cache
Idempotent Repository</h2><p>Available as of <strong>Camel
2.17.1</strong></p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<bean id="repo"
class="org.apache.camel.spring.processor.idempotent.SpringCacheIdempotentRepository">
<constructor-arg>
<bean
class="org.springframework.cache.guava.GuavaCacheManager"/>
@@ -296,7 +273,7 @@ protected Class[] excludeRoutes() {
</idempotentConsumer>
</route>
</camelContext>]]></script>
-</div></div><p> </p><p> </p><h3
id="Spring-CamelContextAware">CamelContextAware</h3><p>If you want to be
injected with the <a shape="rect" href="camelcontext.html">CamelContext</a> in
your POJO just implement the <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelContextAware.html">CamelContextAware
interface</a>; then when Spring creates your POJO the CamelContext will be
injected into your POJO. Also see the <a shape="rect"
href="bean-integration.html">Bean Integration</a> for further
injections.</p><h2 id="Spring-IntegrationTesting">Integration Testing</h2><p>To
avoid a hung route when testing using Spring Transactions see the note about
Spring Integration Testing under <a shape="rect"
href="transactional-client.html">Transactional Client</a>.</p><h3
id="Spring-Seealso">See also</h3><ul><li><a shape="rect"
href="tutorial-jmsremoting.html">Spring JMS Tutorial</a></li><li><a
shape="rect" href="cr
eating-a-new-spring-based-camel-route.html">Creating a new Spring based Camel
Route</a></li><li><a shape="rect" href="spring-example.html">Spring
example</a></li><li><a shape="rect" href="xml-reference.html">Xml
Reference</a></li><li><a shape="rect"
href="advanced-configuration-of-camelcontext-using-spring.html">Advanced
configuration of CamelContext using Spring</a></li><li><a shape="rect"
href="how-do-i-import-routes-from-other-xml-files.html">How do I import routes
from other XML files</a></li></ul></div>
+</div></div><p> </p><p> </p><h3
id="Spring-CamelContextAware">CamelContextAware</h3><p>If you want to be
injected with the <a shape="rect" href="camelcontext.html">CamelContext</a> in
your POJO just implement the <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelContextAware.html">CamelContextAware
interface</a>; then when Spring creates your POJO
the <strong><code>CamelContext</code></strong> will be injected into your
POJO. Also see the <a shape="rect" href="bean-integration.html">Bean
Integration</a> for further injections.</p><h2
id="Spring-IntegrationTesting">Integration Testing</h2><p>To avoid a hung route
when testing using Spring Transactions see the note about Spring Integration
Testing under <a shape="rect"
href="transactional-client.html">Transactional Client</a>.</p><h3
id="Spring-Seealso">See also</h3><ul><li><a shape="rect"
href="tutorial-jmsremoting.html">Spring JMS Tutorial</
a></li><li><a shape="rect"
href="creating-a-new-spring-based-camel-route.html">Creating a new Spring based
Camel Route</a></li><li><a shape="rect" href="spring-example.html">Spring
example</a></li><li><a shape="rect" href="xml-reference.html">Xml
Reference</a></li><li><a shape="rect"
href="advanced-configuration-of-camelcontext-using-spring.html">Advanced
configuration of CamelContext using Spring</a></li><li><a shape="rect"
href="how-do-i-import-routes-from-other-xml-files.html">How Do I Import Routes
From Other XML Files</a></li></ul></div>
</td>
<td valign="top">
<div class="navigation">