Modified: websites/production/camel/content/cdi.html
==============================================================================
--- websites/production/camel/content/cdi.html (original)
+++ websites/production/camel/content/cdi.html Thu Nov 10 19:22:09 2016
@@ -87,10 +87,10 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="CDI-CamelCDI">Camel
CDI</h2><p>The Camel CDI component provides auto-configuration for Apache Camel
using CDI as dependency injection framework based
on <em>convention-over-configuration</em>. It auto-detects Camel routes
available in the application and provides beans for common Camel primitives
like <code>Endpoint</code>, <code>ProducerTemplate</code>
or <code>TypeConverter</code>. It implements standard <a shape="rect"
href="bean-integration.html">Camel bean integration</a> so that Camel
annotations like <code>@Consume</code>, <code>@Produce</code>
and <span style="color: rgb(0,0,0);"><code>@PropertyInject</code> can be
used seamlessly in CDI beans</span>. Besides, it bridges Camel events (e.g.
<code>RouteAddedEvent</code>,
<code>CamelContextStartedEvent</code>, <code>ExchangeCompletedEvent</code>,
...) as CDI events and provides a CDI events endpoint that can be used to
consume / produce CDI events
from / to Camel routes.</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>While the Camel CDI component is
available as of <strong>Camel 2.10</strong>, it's been rewritten in
<strong>Camel 2.17</strong> to better fit into the CDI programming model. Hence
some of the features like the Camel events to CDI events bridge and the CDI
events endpoint only apply starting Camel 2.17.</p></div></div><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>More details on how to test Camel
CDI applications are available in <a shape="rect" href="cdi-testing.html">Camel
CDI testing</a>.</p></div></div><h3 id="CDI-Auto-configuredCamelcontext">Aut
o-configured Camel context</h3><p>Camel CDI automatically deploys and
configures a <code>CamelContext</code> bean. That
<code>CamelContext</code> bean is automatically instantiated, configured and
started (resp. stopped) when the CDI container initialises (resp. shuts down).
It can be injected in the application, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<div class="wiki-content maincontent"><h2 id="CDI-CamelCDI">Camel
CDI</h2><p>The Camel CDI component provides auto-configuration for Apache Camel
using CDI as dependency injection framework based
on <em>convention-over-configuration</em>. It auto-detects Camel routes
available in the application and provides beans for common Camel primitives
like <strong><code>Endpoint</code>, <code>ProducerTemplate</code></strong>
or <strong><code>TypeConverter</code></strong>. It implements standard <a
shape="rect" href="bean-integration.html">Camel bean integration</a> so that
Camel annotations
like <strong><code>@Consume</code></strong>, <strong><code>@Produce</code></strong>
and <span style="color:
rgb(0,0,0);"><strong><code>@PropertyInject</code></strong> can be used
seamlessly in CDI beans</span>. Besides, it bridges Camel events (e.g.
<strong><code>RouteAddedEvent</code></strong>,
<strong><code>CamelContextStartedEvent</code></strong>, <strong><code>Exchang
eCompletedEvent</code></strong>, ...) as CDI events and provides a CDI events
endpoint that can be used to consume / produce CDI events from / to Camel
routes.</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>While the Camel CDI component is
available as of <strong>Camel 2.10</strong>, it's been rewritten in
<strong>Camel 2.17</strong> to better fit into the CDI programming model. Hence
some of the features like the Camel events to CDI events bridge and the CDI
events endpoint only apply starting Camel 2.17.</p></div></div><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>More details on how to test Camel
CDI applications are
available in <a shape="rect" href="cdi-testing.html">Camel CDI
testing</a>.</p></div></div><h3
id="CDI-Auto-ConfiguredCamelContext">Auto-Configured Camel Context</h3><p>Camel
CDI automatically deploys and configures
a <strong><code>CamelContext</code></strong> bean. That
<strong><code>CamelContext</code></strong> bean is automatically instantiated,
configured and started (resp. stopped) when the CDI container initializes
(resp. shuts down). It can be injected in the application, e.g.:</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[@Inject
CamelContext context;]]></script>
-</div></div><p>That default <code>CamelContext</code> bean is qualified with
the built-in <code>@Default</code> qualifier, is
scoped <code>@ApplicationScoped</code> and is of type
<code>DefaultCamelContext</code>.</p><p>Note that this bean can be customised
programmatically and other Camel context beans can be deployed in the
application as well.</p><h3 id="CDI-Auto-detectingCamelroutes">Auto-detecting
Camel routes</h3><p>Camel CDI automatically collects all
the <code>RoutesBuilder</code> beans in the application, instantiates and
add them to the <code>CamelContext</code> bean instance when the CDI container
initialises. For example, adding a Camel route is as simple as declaring a
class, e.g.:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>That default <strong><code>CamelContext</code></strong> bean is
qualified with the built-in <strong><code>@Default</code></strong>
qualifier, is scoped <strong><code>@ApplicationScoped</code></strong> and
is of type <strong><code>DefaultCamelContext</code></strong>.</p><p>Note that
this bean can be customized programmatically and other Camel context beans can
be deployed in the application as well.</p><h3
id="CDI-Auto-DetectingCamelRoutes">Auto-Detecting Camel Routes</h3><p>Camel CDI
automatically collects all
the <strong><code>RoutesBuilder</code></strong> beans in the application,
instantiates and add them to the <strong><code>CamelContext</code></strong>
bean instance when the CDI container initializes. For example, adding a Camel
route is as simple as declaring a class, e.g.:</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[class MyRouteBean extends RouteBuilder {
Â
@Override
@@ -98,7 +98,7 @@ CamelContext context;]]></script>
from("jms:invoices").to("file:/invoices");
}
}]]></script>
-</div></div><p>Note that you can declare as
many <code>RoutesBuilder</code> beans as you want.
Besides, <code>RouteContainer</code> beans are also automatically
collected, instantiated and added to the <code>CamelContext</code> bean
instance managed by Camel CDI when the container initialises.</p><h3
id="CDI-Auto-configuredCamelprimitives">Auto-configured Camel
primitives</h3><p>Camel CDI provides beans for common Camel primitives that can
be injected in any CDI beans, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Note that you can declare as
many <strong><code>RoutesBuilder</code></strong> beans as you want.
Besides, <strong><code>RouteContainer</code></strong> beans are also
automatically collected, instantiated and added to
the <strong><code>CamelContext</code></strong> bean instance managed by
Camel CDI when the container initializes.</p><h3
id="CDI-Auto-ConfiguredCamelPrimitives">Auto-Configured Camel
Primitives</h3><p>Camel CDI provides beans for common Camel primitives that can
be injected in any CDI beans, e.g.:</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[@Inject
@Uri("direct:inbound")
ProducerTemplate producerTemplate;
@@ -112,7 +112,7 @@ Endpoint endpoint;
@Inject
TypeConverter converter;]]></script>
-</div></div><h3 id="CDI-Camelcontextconfiguration">Camel context
configuration</h3><p>If you just want to change the name of the default
<code>CamelContext</code> bean, you can used the <code>@ContextName</code>
qualifier provided by Camel CDI, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="CDI-CamelContextConfiguration">Camel Context
Configuration</h3><p>If you just want to change the name of the default
<strong><code>CamelContext</code></strong> bean, you can used the
<strong><code>@ContextName</code></strong> qualifier provided by Camel
CDI, e.g.:</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[@ContextName("camel-context")
class MyRouteBean extends RouteBuilder {
Â
@@ -121,7 +121,7 @@ class MyRouteBean extends RouteBuilder {
from("jms:invoices").to("file:/invoices");
}
}]]></script>
-</div></div><p>Else, if more customisation is needed,
any <code>CamelContext</code> class can be used to declare a custom
Camel context bean. Then,
the <code>@PostConstruct</code> and <code>@PreDestroy</code> lifecycle
callbacks can be done to do the customisation, e.g.:</p><div class="highlight
highlight-source-java"><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Else, if more customization is needed,
any <strong><code>CamelContext</code></strong> class can be used to
declare a custom Camel context bean. Then,
the <strong><code>@PostConstruct</code></strong> and <code>@PreDestroy</code> lifecycle
callbacks can be done to do the customization, e.g.:</p><div class="highlight
highlight-source-java"><p> </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[@ApplicationScoped
class CustomCamelContext extends DefaultCamelContext {
@@ -164,7 +164,7 @@ class CustomCamelContext extends Default
setName("custom");
}
}]]></script>
-</div></div><p>This pattern can be used for example to avoid having the Camel
context routes started automatically when the container initialises by calling
the <code>setAutoStartup</code> method, e.g.:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>This pattern can be used for example to avoid having the Camel
context routes started automatically when the container initializes by calling
the <strong><code>setAutoStartup</code></strong> method,
e.g.:</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[@ApplicationScoped
class ManualStartupCamelContext extends DefaultCamelContext {
@@ -173,7 +173,7 @@ class ManualStartupCamelContext extends
setAutoStartup(false);
}
}]]></script>
-</div></div><h3 id="CDI-MultipleCamelcontexts">Multiple Camel
contexts</h3><p>Any number of <code>CamelContext</code> beans can actually be
declared in the application as documented above. In that case, the CDI
qualifiers declared on these <code>CamelContext</code> beans are used to bind
the Camel routes and other Camel primitives to the corresponding Camel
contexts. From example, if the following beans get declared:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h3 id="CDI-MultipleCamelContexts">Multiple Camel
Contexts</h3><p>Any number of <strong><code>CamelContext</code></strong> beans
can actually be declared in the application as documented above. In that case,
the CDI qualifiers declared on these <strong><code>CamelContext</code></strong>
beans are used to bind the Camel routes and other Camel primitives to the
corresponding Camel contexts. From example, if the following beans get
declared:</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[@ApplicationScoped
@ContextName("foo")
class FooCamelContext extends DefaultCamelContext {
@@ -219,7 +219,7 @@ class RouteNotAddedToAnyCamelContext ext
// ...
}
}]]></script>
-</div></div><p>The <code>RoutesBuilder</code> beans qualified
with <code>@ContextName</code> are automatically added to the
corresponding <code>CamelContext</code> beans by Camel CDI. If no such
<code>CamelContext</code> bean exists, it gets automatically created, as for
the <code>RouteAddedToBazCamelContext</code> bean. Note this only happens for
the <code>@ContextName</code> qualifier provided by Camel CDI. Hence
the <code>RouteNotAddedToAnyCamelContext</code> bean qualified with the
user-defined <code>@MyOtherQualifier</code> qualifier does not get
added to any Camel contexts. That may be useful, for example, for Camel routes
that may be required to be added later during the application
execution.</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>Since Camel version
2.17.0, Camel CDI is capable of managing any kind of
<code>CamelContext</code> beans. In previous versions, it is only capable of
managing beans of type <code>CdiCamelContext</code> so it is required to extend
it.</p></div></div><p>The CDI qualifiers declared on
the <code>CamelContext</code> beans are also used to bind the
corresponding Camel primitives, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>The <strong><code>RoutesBuilder</code></strong> beans
qualified with <strong><code>@ContextName</code></strong> are
automatically added to the corresponding
<strong><code>CamelContext</code></strong> beans by Camel CDI. If no such
<strong><code>CamelContext</code></strong> bean exists, it gets automatically
created, as for the <strong><code>RouteAddedToBazCamelContext</code></strong>
bean. Note this only happens for
the <strong><code>@ContextName</code></strong> qualifier provided by
Camel CDI. Hence
the <strong><code>RouteNotAddedToAnyCamelContext</code></strong> bean
qualified with the
user-defined <strong><code>@MyOtherQualifier</code></strong> qualifier
does not get added to any Camel contexts. That may be useful, for example, for
Camel routes that may be required to be added later during the application
execution.</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>Since Camel version 2.17.0, Camel
CDI is capable of managing any kind of
<strong><code>CamelContext</code></strong> beans. In previous versions, it is
only capable of managing beans of type
<strong><code>CdiCamelContext</code></strong> so it is required to extend
it.</p></div></div><p>The CDI qualifiers declared on
the <strong><code>CamelContext</code></strong> beans are also used to
bind the corresponding Camel primitives, e.g.:</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[@Inject
@ContextName("foo")
@Uri("direct:inbound")
@@ -233,7 +233,7 @@ MockEndpoint outbound; // URI defaults t
@ContextName("baz")
@Uri("direct:inbound")
Endpoint endpoint;]]></script>
-</div></div><h3 id="CDI-Configurationproperties">Configuration
properties</h3><p>To configure the sourcing of the configuration properties
used by Camel to resolve properties placeholders, you can declare
a <code>PropertiesComponent</code> bean qualified with
<code>@Named("properties")</code>, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="CDI-ConfigurationProperties">Configuration
Properties</h3><p>To configure the sourcing of the configuration properties
used by Camel to resolve properties placeholders, you can declare
a <strong><code>PropertiesComponent</code></strong> bean qualified
with <strong><code>@Named("properties")</code></strong>, e.g.:</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[@Produces
@ApplicationScoped
@Named("properties")
@@ -245,7 +245,7 @@ PropertiesComponent propertiesComponent(
component.setLocation("classpath:placeholder.properties");
return component;
}]]></script>
-</div></div><p>If you want to use <a shape="rect" class="external-link"
href="http://deltaspike.apache.org/documentation/configuration.html">DeltaSpike
configuration mechanism</a> you can declare the
following <code>PropertiesComponent</code> bean:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>If you want to use <a shape="rect" class="external-link"
href="http://deltaspike.apache.org/documentation/configuration.html">DeltaSpike
configuration mechanism</a> you can declare the
following <strong><code>PropertiesComponent</code></strong> bean:</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[@Produces
@ApplicationScoped
@Named("properties")
@@ -262,7 +262,7 @@ static class DeltaSpikeParser extends De
return ConfigResolver.getPropertyValue(key);
}
}]]></script>
-</div></div><div class="highlight highlight-source-java"><p>You can see
the <span><code>camel-example-cdi-properties</code> example for a working
example of a Camel CDI application using DeltaSpike configuration
mechanism.</span></p></div><h3
id="CDI-Auto-configuredtypeconverters">Auto-configured type
converters</h3><p>CDI beans annotated with
the <code>@Converter</code> annotation are automatically registered
into the deployed Camel contexts, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><div class="highlight highlight-source-java"><p>You can see
the <span><strong><code>camel-example-cdi-properties</code></strong>
example for a working example of a Camel CDI application using DeltaSpike
configuration mechanism.</span></p></div><h3
id="CDI-Auto-ConfiguredTypeConverters">Auto-Configured Type
Converters</h3><p>CDI beans annotated with
the <strong><code>@Converter</code></strong> annotation are
automatically registered into the deployed Camel contexts, e.g.:</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[@Converter
public class MyTypeConverter {
@@ -271,7 +271,7 @@ public class MyTypeConverter {
//...
}
}]]></script>
-</div></div><p>Note that CDI injection is supported within the type
converters.</p><h3 id="CDI-Camelbeanintegration">Camel bean integration</h3><h4
id="CDI-Camelannotations">Camel annotations</h4><p>As part of the Camel <a
shape="rect" class="external-link"
href="http://camel.apache.org/bean-integration.html">bean
integration</a>, Camel comes with a set of <a shape="rect"
class="external-link"
href="http://camel.apache.org/bean-integration.html#BeanIntegration-Annotations">annotations</a> that
are seamlessly supported by Camel CDI. So you can use any of these annotations
in your CDI beans, e.g.:</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> </th><th colspan="1" rowspan="1"
class="confluenceTh">Camel annotation</th><th colspan="1" rowspan="1"
class="confluenceTh">CDI equivalent</th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Configuration property</td><td colspan="1" rowspa
n="1" class="confluenceTd"><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Note that CDI injection is supported within the type
converters.</p><h3 id="CDI-CamelBeanIntegration">Camel Bean Integration</h3><h4
id="CDI-CamelAnnotations">Camel Annotations</h4><p>As part of the Camel <a
shape="rect" class="external-link"
href="http://camel.apache.org/bean-integration.html">bean
integration</a>, Camel comes with a set of <a shape="rect"
class="external-link"
href="http://camel.apache.org/bean-integration.html#BeanIntegration-Annotations">annotations</a> that
are seamlessly supported by Camel CDI. So you can use any of these annotations
in your CDI beans, e.g.:</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> </th><th colspan="1" rowspan="1"
class="confluenceTh">Camel annotation</th><th colspan="1" rowspan="1"
class="confluenceTh">CDI equivalent</th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Configuration property</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><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[@PropertyInject("key")
String value;
]]></script>
@@ -279,21 +279,21 @@ String value;
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[@Inject
@ConfigProperty(name = "key")
String value;]]></script>
-</div></div><p>See <a shape="rect"
href="#CDI-Configurationproperties">configuration properties</a> for more
details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Producer template injection (default Camel
context)</td><td colspan="1" rowspan="1" class="confluenceTd"><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>See <a shape="rect"
href="#CDI-Configurationproperties">configuration properties</a> for more
details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Producer template injection (default Camel
context)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><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[@Produce(uri = "mock:outbound")
ProducerTemplate producer;]]></script>
</div></div></td><td colspan="1" rowspan="1" class="confluenceTd"><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[@Inject
@Uri("direct:outbound")
ProducerTemplate producer;]]></script>
-</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Endpoint injection (default Camel context)</td><td
colspan="1" rowspan="1" class="confluenceTd"><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Endpoint injection (default Camel context)</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><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[@EndpointInject(uri =
"direct:inbound")
Endpoint endpoint;]]></script>
</div></div></td><td colspan="1" rowspan="1" class="confluenceTd"><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[@Inject
@Uri("direct:inbound")
Endpoint endpoint;]]></script>
-</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Endpoint injection (Camel context by name)</td><td
colspan="1" rowspan="1" class="confluenceTd"><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Endpoint injection (Camel context by name)</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><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[@EndpointInject(uri =
"direct:inbound", context = "foo")
Endpoint contextEndpoint;]]></script>
</div></div></td><td colspan="1" rowspan="1" class="confluenceTd"><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
@@ -301,14 +301,14 @@ Endpoint contextEndpoint;]]></script>
@ContextName("foo")
@Uri("direct:inbound")
Endpoint contextEndpoint;]]></script>
-</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Bean injection (by type)</td><td colspan="1" rowspan="1"
class="confluenceTd"><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Bean injection (by type)</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><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[@BeanInject
MyBean bean;]]></script>
</div></div></td><td colspan="1" rowspan="1" class="confluenceTd"><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[@Inject
MyBean bean;
]]></script>
-</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Bean injection (by name)</td><td colspan="1" rowspan="1"
class="confluenceTd"><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Bean injection (by name)</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><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[@BeanInject("foo")
MyBean bean;]]></script>
</div></div></td><td colspan="1" rowspan="1" class="confluenceTd"><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
@@ -316,12 +316,12 @@ MyBean bean;]]></script>
@Named("foo")
MyBean bean;
]]></script>
-</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">POJO consuming</td><td colspan="1" rowspan="1"
class="confluenceTd"><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>POJO consuming</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><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[@Consume(uri = "seda:inbound")
void consume(@Body String body) {
//...
}]]></script>
-</div></div></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td></tr></tbody></table></div><h4
id="CDI-Beancomponent">Bean component</h4><p>You can refer to CDI beans, either
by type or name, From the Camel DSL, e.g. with the Java Camel DSL:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td></tr></tbody></table></div><h4
id="CDI-BeanComponent">Bean Component</h4><p>You can refer to CDI beans, either
by type or name, From the Camel DSL, e.g. with the Java Camel DSL:</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[class MyBean {
//...
}
@@ -334,9 +334,9 @@ class MyNamedBean {
}
Â
from("direct:inbound").bean("foo");]]></script>
-</div></div><h4 id="CDI-ReferringbeansfromEndpointURIs">Referring beans from
Endpoint URIs</h4><p><span style="color: rgb(0,0,0);">When configuring
endpoints using the URI syntax you can refer to beans in the </span><a
shape="rect" href="registry.html">Registry</a><span style="color:
rgb(0,0,0);"> using the <code>#</code>
notation.</span><span> </span><span style="color: rgb(0,0,0);">If the URI
parameter value starts with a </span><code>#</code><span style="color:
rgb(0,0,0);"> sign then Camel CDI will lookup</span><span style="color:
rgb(0,0,0);"> for a bean of the given type by name, e.g.:</span></p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h4 id="CDI-ReferringBeansFromEndpointURIs">Referring Beans From
Endpoint URIs</h4><p><span style="color: rgb(0,0,0);">When configuring
endpoints using the URI syntax you can refer to beans in the </span><a
shape="rect" href="registry.html">Registry</a><span style="color:
rgb(0,0,0);"> using the <code>#</code>
notation.</span><span> </span><span style="color: rgb(0,0,0);">If the URI
parameter value starts with a </span><strong><code>#</code></strong><span
style="color: rgb(0,0,0);"> sign then Camel CDI will lookup</span><span
style="color: rgb(0,0,0);"> for a bean of the given type by name,
e.g.:</span></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[from("jms:queue:{{destination}}?transacted=true&transactionManager=#jtaTransactionManager").to("...");]]></script>
-</div></div><p>Having the following CDI bean qualified
with <code>@Named("jtaTransactionManager")</code>:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Having the following CDI bean qualified
with <strong><code>@Named("jtaTransactionManager")</code></strong>:</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[@Produces
@Named("jtaTransactionManager")
PlatformTransactionManager createTransactionManager(TransactionManager
transactionManager, UserTransaction userTransaction) {
@@ -346,17 +346,17 @@ PlatformTransactionManager createTransac
jtaTransactionManager.afterPropertiesSet();
return jtaTransactionManager;
}]]></script>
-</div></div><h3 id="CDI-CameleventstoCDIevents">Camel events to CDI
events</h3><p><strong>Available as of Camel 2.17</strong></p><p>Camel provides
a set of <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/management/event/package-summary.html">management
events</a> that can be subscribed to for listening to Camel context,
service, route and exchange events. Camel CDI seamlessly translates these Camel
events into CDI events that can be observed using CDI <a shape="rect"
class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#observer_methods"
rel="nofollow">observer methods</a>, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="CDI-CamelEventstoCDIEvents">Camel Events to CDI
Events</h3><p><strong>Available as of Camel 2.17</strong></p><p>Camel provides
a set of <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/management/event/package-summary.html">management
events</a> that can be subscribed to for listening to Camel context,
service, route and exchange events. Camel CDI seamlessly translates these Camel
events into CDI events that can be observed using CDI <a shape="rect"
class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#observer_methods"
rel="nofollow">observer methods</a>, e.g.:</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[void onContextStarting(@Observes
CamelContextStartingEvent event) {
// Called before the default Camel context is about to start
}]]></script>
-</div></div><p>As of Camel 2.18, it is possible to observe events for a
particular route (<code>RouteAddedEvent</code>, <code>RouteStartedEvent</code>,
<code>RouteStoppedEvent</code> and <code>RouteRemovedEvent</code>) should it
have an explicit defined, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>From Camel 2.18: it's possible to observe events for a
particular route (<strong><code>RouteAddedEvent</code></strong>,
<strong><code>RouteStartedEvent</code></strong>,
<strong><code>RouteStoppedEvent</code></strong> and
<strong><code>RouteRemovedEvent</code></strong>) should it have an explicit
defined, e.g.:</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[from("...").routeId("foo").to("...");
Â
void onRouteStarted(@Observes @Named("foo") RouteStartedEvent event)
{
// Called after the route "foo" has started
}]]></script>
-</div></div><p>When multiple Camel contexts exist in the CDI container, the
Camel context bean qualifiers, like <code>@ContextName</code>, can be
used to refine the observer method resolution to a particular Camel context as
specified in <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#observer_resolution"
rel="nofollow">observer resolution</a>, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>When multiple Camel contexts exist in the CDI container, the
Camel context bean qualifiers,
like <strong><code>@ContextName</code></strong>, can be used to
refine the observer method resolution to a particular Camel context as
specified in <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#observer_resolution"
rel="nofollow">observer resolution</a>, e.g.:</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[void onRouteStarted(@Observes
@ContextName("foo") RouteStartedEvent event) {
// Called after the route 'event.getRoute()' for the Camel context
'foo' has started
}
@@ -364,11 +364,11 @@ void onRouteStarted(@Observes @Named(&qu
void onContextStarted(@Observes @Manual CamelContextStartedEvent event) {
// Called after the the Camel context qualified with '@Manual' has
started
}]]></script>
-</div></div><p>Similarly, the <code>@Default</code> qualifier can be
used to observe Camel events for the <em>default</em> Camel context
if multiples contexts exist, e.g.:</p><div class="highlight
highlight-source-java"><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Similarly,
the <strong><code>@Default</code></strong> qualifier can be used to
observe Camel events for the <em>default</em> Camel context if
multiples contexts exist, e.g.:</p><div class="highlight
highlight-source-java"><p> </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[void onExchangeCompleted(@Observes @Default
ExchangeCompletedEvent event) {
// Called after the exchange 'event.getExchange()' processing has
completed
}]]></script>
-</div></div><p>In that example, if no qualifier is specified,
the <code>@Any</code> qualifier is implicitly assumed, so that
corresponding events for all the Camel contexts get received.</p></div><p>Note
that the support for Camel events translation into CDI events is only activated
if observer methods listening for Camel events are detected in the deployment,
and that per Camel context.</p><h3 id="CDI-CDIeventsendpoint">CDI events
endpoint</h3><p><strong>Available as of Camel 2.17</strong></p><p>The CDI event
endpoint bridges the <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#events"
rel="nofollow">CDI events</a> with the Camel routes so that CDI events can
be seamlessly observed / consumed (resp. produced / fired) from Camel consumers
(resp. by Camel
producers).</p><p>The <code>CdiEventEndpoint<T></code> bean
provided by Camel CDI can be used to observe / consume CDI events
whose <em>event type<
/em> is <code>T</code>, for example:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>In that example, if no qualifier is specified,
the <code>@Any</code> qualifier is implicitly assumed, so that
corresponding events for all the Camel contexts get received.</p></div><p>Note
that the support for Camel events translation into CDI events is only activated
if observer methods listening for Camel events are detected in the deployment,
and that per Camel context.</p><h3 id="CDI-CDIEventsEndpoint">CDI Events
Endpoint</h3><p><strong>Available as of Camel 2.17</strong></p><p>The CDI event
endpoint bridges the <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#events"
rel="nofollow">CDI events</a> with the Camel routes so that CDI events can
be seamlessly observed / consumed (resp. produced / fired) from Camel consumers
(resp. by Camel
producers).</p><p>The <strong><code>CdiEventEndpoint<T></code></strong> bean
provided by Camel CDI can be used to observe / consume CDI events whose
0;<em>event type</em> is <strong><code>T</code></strong>, for
example:</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[@Inject
CdiEventEndpoint<String> cdiEventEndpoint;
@@ -382,13 +382,15 @@ void observeCdiEvents(@Observes String e
producer.sendBody(event);
}
-from("direct:event").log("CDI event received:
${body}");]]></script>
-</div></div><p>Conversely,
the <code>CdiEventEndpoint<T></code> bean can be used to
produce / fire CDI events whose <em>event
type</em> is <code>T</code>, for example:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+from("direct:event")
+ .log("CDI event received: ${body}");]]></script>
+</div></div><p>Conversely,
the <strong><code>CdiEventEndpoint<T></code></strong> bean can
be used to produce / fire CDI events whose <em>event
type</em> is <strong><code>T</code></strong>, for example:</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[@Inject
CdiEventEndpoint<String> cdiEventEndpoint;
-from("direct:event").to(cdiEventEndpoint).log("CDI event sent:
${body}");]]></script>
-</div></div><p>This is equivalent to writing:</p><div class="highlight
highlight-source-java"><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+from("direct:event")
+ .to(cdiEventEndpoint).log("CDI event sent: ${body}");]]></script>
+</div></div><p>This is equivalent to writing:</p><div class="highlight
highlight-source-java"><p> </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[@Inject
Event<String> event;
@@ -405,7 +407,7 @@ Event<String> event;
from("direct:event")
.process(exchange -> event.fire(exchange.getIn().getBody(String.class)))
.log("CDI event sent: ${body}");]]></script>
-</div></div><p>The type variable <code>T</code> (resp. the qualifiers) of
a particular <code>CdiEventEndpoint<T></code> injection point
are automatically translated into the parameterized <em>event
type</em> (resp. into the <em>event
qualifiers</em>) e.g.:</p></div><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>The type variable <strong><code>T</code></strong> (resp.
the qualifiers) of a
particular <strong><code>CdiEventEndpoint<T></code></strong> injection
point are automatically translated into the parameterized <em>event
type</em> (resp. into the <em>event
qualifiers</em>) e.g.:</p></div><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[@Inject
@FooQualifier
CdiEventEndpoint<List<String>> cdiEventEndpoint;
@@ -415,7 +417,7 @@ from("direct:event").to(cdiEve
void observeCdiEvents(@Observes @FooQualifier List<String> event) {
logger.info("CDI event: {}", event);
}]]></script>
-</div></div><p>When multiple Camel contexts exist in the CDI container, the
Camel context bean qualifiers, like <code>@ContextName</code>, can be
used to qualify the <code>CdiEventEndpoint<T></code> injection
points, e.g.:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>When multiple Camel contexts exist in the CDI container, the
Camel context bean qualifiers,
like <strong><code>@ContextName</code></strong>, can be used to
qualify
the <strong><code>CdiEventEndpoint<T></code></strong> injection
points, e.g.:</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[@Inject
@ContextName("foo")
CdiEventEndpoint<List<String>> cdiEventEndpoint;
@@ -429,13 +431,13 @@ void observeCdiEvents(@Observes @Context
}]]></script>
</div></div><p>Note that the CDI event Camel endpoint dynamically adds
an <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#observer_methods"
rel="nofollow">observer method</a> for each unique combination
of <em>event type</em> and <em>event qualifiers</em> and
solely relies on the container typesafe <a shape="rect"
class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#observer_resolution"
rel="nofollow">observer resolution</a>, which leads to an implementation as
efficient as possible.</p><p>Besides, as the impedance between
the <em>typesafe</em> nature of CDI and
the <em>dynamic</em> nature of the <a shape="rect"
class="external-link" href="http://camel.apache.org/component.html">Camel
component</a> model is quite high, it is not possible to create an
instance of the CDI event Camel endpoint via <a shape="rect"
class="external-link" href="http://c
amel.apache.org/uris.html">URIs</a>. Indeed, the URI format for the CDI event
component is:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="brush: text; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[cdi-event://PayloadType<T1,...,Tn>[?qualifiers=QualifierType1[,...[,QualifierTypeN]...]]]]></script>
-</div></div><p>With the authority <code>PayloadType</code> (resp.
the <code>QualifierType</code>) being the URI escaped fully qualified name
of the payload (resp. qualifier) raw type followed by the type parameters
section delimited by angle brackets for payload parameterized type. Which leads
to <em>unfriendly</em> URIs, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>With the
authority <strong><code>PayloadType</code></strong> (resp.
the <strong><code>QualifierType</code></strong>) being the URI escaped
fully qualified name of the payload (resp. qualifier) raw type followed by the
type parameters section delimited by angle brackets for payload parameterized
type. Which leads to <em>unfriendly</em> URIs, e.g.:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<script class="brush: text; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[cdi-event://org.apache.camel.cdi.example.EventPayload%3Cjava.lang.Integer%3E?qualifiers=org.apache.camel.cdi.example.FooQualifier%2Corg.apache.camel.cdi.example.BarQualifier]]></script>
-</div></div><p>But more fundamentally, that would prevent efficient binding
between the endpoint instances and the observer methods as the CDI container
doesn't have any ways of discovering the Camel context model during the
deployment phase.</p><h3 id="CDI-CamelXMLconfigurationimport">Camel XML
configuration import</h3><p><strong>Available as of Camel
2.18</strong></p><p>While CDI favors a typesafe dependency injection mechanism,
it may be useful to reuse existing Camel XML configuration files into a
Camel CDI application. In other use cases, it might be handy to rely on
the Camel XML DSL to configure its Camel context(s).</p><p>You can use
the <code>@ImportResource</code> annotation that's provided by Camel CDI
on any CDI beans and Camel CDI will automatically load the Camel XML
configuration at the specified locations, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>But more fundamentally, that would prevent efficient binding
between the endpoint instances and the observer methods as the CDI container
doesn't have any ways of discovering the Camel context model during the
deployment phase.</p><h3 id="CDI-CamelXMLConfigurationImport">Camel XML
Configuration Import</h3><p><strong>Available as of Camel
2.18</strong></p><p>While CDI favors a typesafe dependency injection mechanism,
it may be useful to reuse existing Camel XML configuration files into a
Camel CDI application. In other use cases, it might be handy to rely on
the Camel XML DSL to configure its Camel context(s).</p><p>You can use
the <strong><code>@ImportResource</code></strong> annotation that's
provided by Camel CDI on any CDI beans and Camel CDI will automatically load
the Camel XML configuration at the specified locations, e.g.:</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[@ImportResource("camel-context.xml")
class MyBean {
}]]></script>
-</div></div><p>Camel CDI will load the resources at the specified locations
from the classpath (other protocols may be added in the future).</p><p>Every
<code>CamelContext</code> elements and other Camel primitives from the imported
resources are automatically deployed as CDI beans during the container
bootstrap so that they benefit from the auto-configuration provided by Camel
CDI and become available for injection at runtime. If such an element has an
explicit <code>id</code> attribute set, the corresponding CDI bean is qualified
with the <code>@Named</code> qualifier, e.g., given the following Camel XML
configuration:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>Camel CDI will load the resources at the specified locations
from the classpath (other protocols may be added in the future).</p><p>Every
<strong><code>CamelContext</code></strong> elements and other Camel primitives
from the imported resources are automatically deployed as CDI beans during the
container bootstrap so that they benefit from the auto-configuration provided
by Camel CDI and become available for injection at run-time. If such an element
has an explicit <code>id</code> attribute set, the corresponding CDI bean is
qualified with the <code>@Named</code> qualifier, e.g., given the following
Camel XML configuration:</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="foo">
<endpoint id="bar" uri="seda:inbound">
<property key="queue" value="#queue"/>
@@ -450,7 +452,7 @@ CamelContext context;
@Inject
@Named("bar")
Endpoint endpoint;]]></script>
-</div></div><p><span style="color: rgb(71,71,71);"><span style="color:
rgb(71,71,71);">Note that the </span><code>CamelContext</code><span
style="color: rgb(71,71,71);"> beans are automatically qualified with both
the </span><code>Named</code><span style="color:
rgb(71,71,71);"> and </span><code>ContextName</code><span
style="color: rgb(71,71,71);"> qualifiers. If the
imported </span><code>CamelContext</code><span style="color:
rgb(71,71,71);"> element doesn't have an </span><code>id</code><span
style="color: rgb(71,71,71);"> attribute, the corresponding bean is
deployed with the built-in </span><code>Default</code><span style="color:
rgb(71,71,71);"> qualifier.</span></span></p><p>Conversely, CDI beans
deployed in the application can be referred to from the Camel XML
configuration, usually using the <code>ref</code> attribute, e.g.,
given the following bean declared:</p><div class="code panel pdl"
style="border-w
idth: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p><span style="color: rgb(71,71,71);"><span style="color:
rgb(71,71,71);">Note that
the </span><strong><code>CamelContext</code></strong><span style="color:
rgb(71,71,71);"> beans are automatically qualified with both
the </span><code>Named</code><span style="color:
rgb(71,71,71);"> and </span><strong><code>ContextName</code></strong><span
style="color: rgb(71,71,71);"> qualifiers. If the
imported </span><strong><code>CamelContext</code></strong><span
style="color: rgb(71,71,71);"> element doesn't have
an </span><strong><code>id</code></strong><span style="color:
rgb(71,71,71);"> attribute, the corresponding bean is deployed with the
built-in </span><strong><code>Default</code></strong><span style="color:
rgb(71,71,71);"> qualifier.</span></span></p><p>Conversely, CDI beans
deployed in the application can be referred to from the Camel XML
configuration, usually using the <strong><code>ref</code></strong>&#
160;attribute, e.g., given the following bean declared:</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[@Produces
@Named("baz")
Processor processor = exchange ->
exchange.getIn().setHeader("qux", "quux");]]></script>
@@ -461,12 +463,12 @@ Processor processor = exchange -> exc
<process ref="baz"/>
</route>
<camelContext/>]]></script>
-</div></div><h3 id="CDI-Auto-configuredOSGiintegration">Auto-configured OSGi
integration</h3><p><strong>Available as of Camel 2.17</strong></p><p>The Camel
context beans are automatically adapted by Camel CDI so that they are
registered as OSGi services and the various resolvers
(like <code>ComponentResolver</code>
and <code>DataFormatResolver</code>) integrate with the OSGi registry.
That means that the <a shape="rect" href="karaf.html#Karaf-Karafcommands">Karaf
Camel commands</a> can be used to operate the Camel contexts auto-configured by
Camel CDI, e.g.:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><h3 id="CDI-Auto-configuredOSGiintegration">Auto-configured OSGi
integration</h3><p><strong>Available as of Camel 2.17</strong></p><p>The Camel
context beans are automatically adapted by Camel CDI so that they are
registered as OSGi services and the various resolvers
(like <strong><code>ComponentResolver</code></strong>
and <strong><code>DataFormatResolver</code></strong>) integrate with the
OSGi registry. That means that the <a shape="rect"
href="karaf.html#Karaf-Karafcommands">Karaf Camel commands</a> can be used to
operate the Camel contexts auto-configured by Camel CDI, e.g.:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<script class="brush: text; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[karaf@root()> camel:context-list
Context Status Total # Failed # Inflight #
Uptime
------- ------ ------- -------- ----------
------
camel-cdi Started 1 0 0 1
minute ]]></script>
-</div></div><p>See the <span><code>camel-example-cdi-osgi</code> example
for a working example of the Camel CDI OSGi integration.</span></p><h3
id="CDI-LazyInjection/ProgrammaticLookup">Lazy Injection / Programmatic
Lookup</h3><p><strong>Available as of Camel 2.17</strong></p><p>While the CDI
programmatic model favors a <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#typesafe_resolution"
style="text-decoration: underline;" rel="nofollow">type-safe
resolution</a> mechanism that occurs at application initialization time,
it is possible to perform dynamic / lazy injection later during the application
execution using the <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#programmatic_lookup"
style="text-decoration: underline;" rel="nofollow">programmatic
lookup</a> mechanism.</p><p>Camel CDI provides for convenience the
annotation literals corresponding to the CDI qualifiers t
hat you can use for standard injection of Camel primitives. These annotation
literals can be used in conjunction with
the<code>javax.enterprise.inject.Instance</code> interface which is the
CDI entry point to perform lazy injection / programmatic lookup.</p><p>For
example, you can use the provided annotation literal for
the <code>@Uri</code>qualifier to lazily lookup for Camel primitives, e.g.
for <code>ProducerTemplate</code>beans:</p><div class="listingblock"><div
class="content"><div class="line"><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>See
the <span><strong><code>camel-example-cdi-osgi</code></strong> example for
a working example of the Camel CDI OSGi integration.</span></p><h3
id="CDI-LazyInjection/ProgrammaticLookup">Lazy Injection / Programmatic
Lookup</h3><p><strong>Available as of Camel 2.17</strong></p><p>While the CDI
programmatic model favors a <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#typesafe_resolution"
style="text-decoration: underline;" rel="nofollow">type-safe
resolution</a> mechanism that occurs at application initialization time,
it is possible to perform dynamic / lazy injection later during the application
execution using the <a shape="rect" class="external-link"
href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#programmatic_lookup"
style="text-decoration: underline;" rel="nofollow">programmatic
lookup</a> mechanism.</p><p>Camel CDI provides for convenience the
annotation literals corresponding to the
CDI qualifiers that you can use for standard injection of Camel primitives.
These annotation literals can be used in conjunction with the<strong><code>
javax.enterprise.inject.Instance</code></strong> interface which is the
CDI entry point to perform lazy injection / programmatic lookup.</p><p>For
example, you can use the provided annotation literal for
the <strong><code>@Uri</code></strong> qualifier to lazily lookup for
Camel primitives, e.g. for <strong><code>ProducerTemplate</code></strong>
beans:</p><div class="listingblock"><div class="content"><div
class="line"><p> </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[@Any
@Inject
Instance<ProducerTemplate> producers;
@@ -474,7 +476,7 @@ Instance<ProducerTemplate> produce
ProducerTemplate inbound = producers
.select(Uri.Literal.of("direct:inbound"))
.get();]]></script>
-</div></div></div><div class="line">Or
for <code>Endpoint</code> beans, e.g.:</div></div></div><div
class="paragraph"><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p> </p></div><div class="line">Or
for <strong><code>Endpoint</code></strong> beans,
e.g.:</div></div></div><div class="paragraph"><p> </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[@Any
@Inject
Instance<Endpoint> endpoints;
@@ -482,7 +484,7 @@ Instance<Endpoint> endpoints;
MockEndpoint outbound = endpoints
.select(MockEndpoint.class, Uri.Literal.of("mock:outbound"))
.get();]]></script>
-</div></div></div><div class="paragraph"><p>Similarly, you can use the
provided annotation literal for the<code>@ContextName</code> qualifier to
lazily lookup for <code>CamelContext</code> beans,
e.g.:</p></div><div class="listingblock"><div class="content"><div
class="line"><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p> </p></div><div class="paragraph"><p>Similarly, you can
use the provided annotation literal for the<strong><code>
@ContextName</code></strong> qualifier to lazily lookup
for <strong><code>CamelContext</code></strong> beans,
e.g.:</p></div><div class="listingblock"><div class="content"><div
class="line"><p> </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[@Any
@Inject
Instance<CamelContext> contexts;
@@ -490,7 +492,7 @@ Instance<CamelContext> contexts;
CamelContext context = contexts
.select(ContextName.Literal.of("foo"))
.get();]]></script>
-</div></div></div></div></div><div class="paragraph"><p>You can also refined
the selection based on the Camel context type, e.g.:</p></div><div
class="listingblock"><div class="content"><div class="line"><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p> </p></div></div></div><div class="paragraph"><p>You can
also refined the selection based on the Camel context type, e.g.:</p></div><div
class="listingblock"><div class="content"><div class="line"><p> </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[@Any
@Inject
Instance<CamelContext> contexts;
@@ -501,16 +503,16 @@ Instance<DefaultCamelContext> cont
// Check if such a bean exists then retrieve a reference
if (!context.isUnsatisfied())
context.get();]]></script>
-</div></div></div></div></div><div class="paragraph"><p>Or even iterate over a
selection of Camel contexts, e.g.:</p></div><div class="listingblock"><div
class="content"><div class="line"><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p> </p></div></div></div><div class="paragraph"><p>Or even
iterate over a selection of Camel contexts, e.g.:</p></div><div
class="listingblock"><div class="content"><div class="line"><p> </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[@Any
@Inject
Instance<CamelContext> contexts;
for (CamelContext context : contexts)
context.setUseBreadcrumb(true);]]></script>
-</div></div></div></div></div><h3 id="CDI-MavenArchetype">Maven
Archetype</h3><p>Among the available <a shape="rect"
href="camel-maven-archetypes.html">Camel Maven archetypes</a>, you can use the
provided <code>camel-archetype-cdi</code> to generate a Camel CDI
Maven project, e.g.:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><p> </p></div></div></div><h3 id="CDI-MavenArchetype">Maven
Archetype</h3><p>Among the available <a shape="rect"
href="camel-maven-archetypes.html">Camel Maven archetypes</a>, you can use the
provided <strong><code>camel-archetype-cdi</code></strong> to
generate a Camel CDI Maven project, e.g.:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: bash; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[mvn archetype:generate
-DarchetypeGroupId=org.apache.camel.archetypes
-DarchetypeArtifactId=camel-archetype-cdi]]></script>
-</div></div><h3 id="CDI-Supportedcontainers">Supported containers</h3><p>The
Camel CDI component is compatible with any CDI 1.0, CDI 1.1 and CDI 1.2
compliant runtime. It's been successfully tested against the following
runtimes:</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh">Container</th><th colspan="1" rowspan="1"
class="confluenceTh">Version</th><th colspan="1" rowspan="1"
class="confluenceTh">Runtime</th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Weld SE</td><td colspan="1" rowspan="1"
class="confluenceTd"><code>1.1.28.Final</code></td><td colspan="1" rowspan="1"
class="confluenceTd">CDI 1.0 / Java SE 7</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd">OpenWebBeans</td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>1.2.7</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd">CDI 1.0 / Java SE 7</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd">Weld S
E</td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>2.3.4.Final</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd">CDI 1.2 / Java SE 7</td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">OpenWebBeans</td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>1.6.3</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd">CDI 1.2 / Java SE 7</td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">WildFly</td><td colspan="1"
rowspan="1" class="confluenceTd"><code>8.2.1.Final</code></td><td colspan="1"
rowspan="1" class="confluenceTd">CDI 1.2 / Java EE 7</td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">WildFly</td><td colspan="1"
rowspan="1" class="confluenceTd"><code>9.0.1.Final</code></td><td colspan="1"
rowspan="1" class="confluenceTd">CDI 1.2 / Java EE 7</td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">WildFly</td><td colspan="1"
rowspan="1" class="confluenceTd"><code>10.0.0.Final</code></td><td colspan="1"
rowspan="1" class="confluenceTd">CDI 1.2 / Java EE 7</td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">Karaf</td><td colspan="1"
rowspan="1" class="confluenceTd"><code>2.4.4</code></td><td colspan="1"
rowspan="1" class="confluenceTd">CDI 1.2 / <span>OSGi 4 / PAX
CDI</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">Karaf</td><td colspan="1" rowspan="1"
class="confluenceTd"><code>3.0.5</code></td><td colspan="1" rowspan="1"
class="confluenceTd">CDI 1.2 / <span>OSGi 5 / PAX CDI</span></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">Karaf</td><td colspan="1"
rowspan="1" class="confluenceTd"><code>4.0.4</code></td><td colspan="1"
rowspan="1" class="confluenceTd">CDI 1.2 / <span>OSGi 6 / PAX
CDI</span></td></tr></tbody></table></div><h3
id="CDI-Examples">Examples</h3><p>The following examples are available in the
<code>examples</code> directory of the Camel project:</p><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th cols
pan="1" rowspan="1" class="confluenceTh">Example</th><th colspan="1"
rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><code><span>camel-example-cdi</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">Illustrates how to work with Camel
using CDI to configure components, endpoints and beans</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><code><span>camel-example-cdi-kubernetes</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">Illustrates the integration
between Camel, CDI and Kubernetes</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>camel-example-cdi-metrics</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">Illustrates the integration
between Camel, Dropwizard Metrics and CDI</td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><code><span>camel-example-cdi-properties</span></code></td><td
colspan="1" rowspan="1" class="confluenc
eTd">Illustrates the integration between Camel, DeltaSpike and CDI for
configuration properties</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>camel-example-cdi-osgi</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">A CDI application using the
SJMS component that can be executed inside an OSGi container using PAX
CDI</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>camel-example-cdi-test</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">Demonstrates the testing features
that are provided as part of the integration between Camel and
CDI</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>camel-example-cdi-rest-servlet</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">Illustrates the Camel REST DSL
being used in a Web application that uses CDI as dependency injection
framework</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>camel-example
-cdi-xml</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><span>Illustrates the use of Camel XML configuration files
into a Camel CDI application</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>camel-example-widget-gadget-cdi</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">The Widget and Gadget use-case
from the EIP book implemented in Java with CDI dependency
injection</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>camel-example-swagger-cdi</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">An example using REST DSL and
Swagger Java with CDI</td></tr></tbody></table></div><h3 id="CDI-SeeAlso">See
Also</h3><ul><li><a shape="rect" href="cdi-testing.html">Camel CDI
Testing</a></li><li><a shape="rect" class="external-link"
href="http://www.cdi-spec.org" rel="nofollow">CDI Web site</a></li><li><a
shape="rect" class="external-link" href="http://www.cdi-spec.org/ecosystem/"
rel="nofol
low">CDI ecosystem</a></li><li><a shape="rect" class="external-link"
href="https://github.com/astefanutti/further-cdi" rel="nofollow">Going further
with CDI</a> (See Camel CDI section)</li></ul></div>
+</div></div><h3 id="CDI-SupportedContainers">Supported Containers</h3><p>The
Camel CDI component is compatible with any CDI 1.0, CDI 1.1 and CDI 1.2
compliant runtime. It's been successfully tested against the following
runtimes:</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Container</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Version</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Runtime</p></th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Weld SE</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>1.1.28.Final</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>CDI 1.0 / Java SE 7</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>OpenWebBeans</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>1.2.7</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>CDI 1.0 / Java SE
7</p></td></tr><tr
><td colspan="1" rowspan="1" class="confluenceTd"><p>Weld SE</p></td><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>2.3.4.Final</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p>CDI 1.2 / Java SE 7</p></td></tr><tr><td
>colspan="1" rowspan="1" class="confluenceTd"><p>OpenWebBeans</p></td><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>1.6.3</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p>CDI 1.2 / Java SE 7</p></td></tr><tr><td
>colspan="1" rowspan="1" class="confluenceTd"><p>WildFly</p></td><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>8.2.1.Final</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p>CDI 1.2 / Java EE 7</p></td></tr><tr><td
>colspan="1" rowspan="1" class="confluenceTd"><p>WildFly</p></td><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>9.0.1.Final</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p>CDI 1.2 / Java EE 7</p></td></tr><tr><td
>colspan="1" rowspan="1" c
lass="confluenceTd"><p>WildFly</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>10.0.0.Final</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>CDI 1.2 / Java EE 7</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>Karaf</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>2.4.4</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>CDI 1.2 / <span>OSGi 4 / PAX
CDI</span></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Karaf</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>3.0.5</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>CDI 1.2 / <span>OSGi 5 / PAX
CDI</span></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>Karaf</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>4.0.4</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>CDI 1.2 / <span>OSGi 6 / PAX
CDI</span></p></td></tr></tbody></table></div><h3
id="CDI-Examples">Examples</h3><p>The following examples are available in the
<strong><code>examples</code></strong> directory of the Camel project:</p><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Example</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code><span>camel-example-cdi</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Illustrates how to work with
Camel using CDI to configure components, endpoints and
beans</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><span>camel-example-cdi-kubernetes</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Illustrates the integration
between Camel, CDI and Kubernetes</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><span>camel-example-cdi-metrics</span></code></p></td><td
cols
pan="1" rowspan="1" class="confluenceTd"><p>Illustrates the integration
between Camel, Dropwizard Metrics and CDI</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code><span>camel-example-cdi-properties</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Illustrates the integration
between Camel, DeltaSpike and CDI for configuration
properties</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><span>camel-example-cdi-osgi</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>A CDI application using
the SJMS component that can be executed inside an OSGi container using PAX
CDI</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><span>camel-example-cdi-test</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Demonstrates the testing
features that are provided as part of the integration between Camel and
CDI</p></td></tr><tr><td colspan="1" rowspan="1
"
class="confluenceTd"><p><code><span>camel-example-cdi-rest-servlet</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Illustrates the Camel REST DSL
being used in a Web application that uses CDI as dependency injection
framework</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>camel-example-cdi-xml</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><span>Illustrates the use of
Camel XML configuration files into a Camel CDI
application</span></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><span>camel-example-widget-gadget-cdi</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>The Widget and Gadget use-case
from the EIP book implemented in Java with CDI dependency
injection</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><span>camel-example-swagger-cdi</span></code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>An example using
REST DSL and Swagger Java with CDI</p></td></tr></tbody></table></div><h3
id="CDI-SeeAlso">See Also</h3><ul><li><a shape="rect"
href="cdi-testing.html">Camel CDI Testing</a></li><li><a shape="rect"
class="external-link" href="http://www.cdi-spec.org" rel="nofollow">CDI Web
site</a></li><li><a shape="rect" class="external-link"
href="http://www.cdi-spec.org/ecosystem/" rel="nofollow">CDI
ecosystem</a></li><li><a shape="rect" class="external-link"
href="https://github.com/astefanutti/further-cdi" rel="nofollow">Going further
with CDI</a> (See Camel CDI section)</li></ul></div>
</td>
<td valign="top">
<div class="navigation">
Modified: websites/production/camel/content/test.html
==============================================================================
--- websites/production/camel/content/test.html (original)
+++ websites/production/camel/content/test.html Thu Nov 10 19:22:09 2016
@@ -97,7 +97,7 @@
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[test:expectedMessagesEndpointUri
]]></script>
</div></div><p>Where <strong><code>expectedMessagesEndpointUri</code></strong>
refers to some other <a shape="rect" href="component.html">Component</a> URI
that the expected message bodies are pulled from before starting the
test.</p><h3 id="Test-URIOptions">URI Options</h3><div
class="confluenceTableSmall"><div class="table-wrap">
- <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><code>anyOrder</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.17:</strong> Whether the
expected messages should arrive in the same order, or in any
order.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>delimiter</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><code>\n|\r</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.17:</strong> The delimiter to use
when <strong><code>split=true</code></strong>. The delimiter can be a
regular expression.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>split<
/code></td><td colspan="1" rowspan="1"
class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.17:</strong>
If <strong><code>true</code></strong> messages loaded from the test
endpoint will be split using the defined
<strong><code>delimiter</code></strong>.<br clear="none">For example to use
a <strong><code>file</code></strong> endpoint to load a file where each
line is an expected message. </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>timeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>2000</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> The timeout to
use when polling for message bodies from the URI.</p></td></tr></tbody></table>
+ <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>anyOrder</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.17:</strong>
Whether the expected messages should arrive in the same order, or in any
order.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>delimiter</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>\n|\r</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.17:</strong> The delimiter
to use when <strong><code>split=true</code></strong>. The delimiter can be
a regular expression.</p></td></tr><tr><td colspan="1" row
span="1" class="confluenceTd"><p><code>split</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.17:</strong>
If <strong><code>true</code></strong> messages loaded from the test
endpoint will be split using the defined
<strong><code>delimiter</code></strong>.For example to use
a <strong><code>file</code></strong> endpoint to load a file where each
line is an expected message. </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>timeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>2000</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> The timeout to
use when polling for message bodies from the URI.</p></td></tr></tbody></table>
</div></div><h3 id="Test-Example">Example</h3><p>For example, you could write
a test case 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[from("seda:someEndpoint")
.to("test:file://data/expectedOutput?noop=true");