Repository: camel
Updated Branches:
  refs/heads/master cbeab0e14 -> 23420ceaa


CAMEL-9882: Add documentation


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9c5dee79
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9c5dee79
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9c5dee79

Branch: refs/heads/master
Commit: 9c5dee79a4bca5929d3980e0b9eb6790cc7c5c72
Parents: cbeab0e
Author: Antonin Stefanutti <anto...@stefanutti.fr>
Authored: Thu Apr 28 15:54:46 2016 +0200
Committer: Antonin Stefanutti <anto...@stefanutti.fr>
Committed: Thu Apr 28 15:54:46 2016 +0200

----------------------------------------------------------------------
 components/camel-cdi/src/main/docs/cdi.adoc | 99 +++++++++++++++++++++++-
 1 file changed, 95 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9c5dee79/components/camel-cdi/src/main/docs/cdi.adoc
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/docs/cdi.adoc 
b/components/camel-cdi/src/main/docs/cdi.adoc
index 8f49cf9..378d1ff 100644
--- a/components/camel-cdi/src/main/docs/cdi.adoc
+++ b/components/camel-cdi/src/main/docs/cdi.adoc
@@ -147,8 +147,8 @@ class CustomCamelContext extends DefaultCamelContext {
 ----
 
 link:http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#producer_method[Producer]
-and 
link:http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#disposer_method[disposer]Â
 methods
-can also be used as well to customize the Camel context bean, e.g.:
+and 
link:http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#disposer_method[disposer]
+methods can also be used as well to customize the Camel context bean, e.g.:
 
 [source,java]
 ----
@@ -271,8 +271,9 @@ Camel contexts. That may be useful, for example, for Camel 
routes that
 may be required to be added later during the application execution.
 
 NOTE: Since Camel version 2.17.0, Camel CDI is capable of managing any kind of
-`CamelContext` beans (e.g. `DefaultCamelContext`). In previous versions, it is 
only capable of managing beans
-of type `CdiCamelContext` so it is required to extend it.
+`CamelContext` beans (e.g. `DefaultCamelContext`). In previous versions,
+it is only capable of managing beans of type `CdiCamelContext` so it is
+required to extend it.
 
 The CDI qualifiers declared on the `CamelContext` beans are also used to
 bind the corresponding Camel primitives, e.g.:
@@ -769,6 +770,92 @@ 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.
 
+[[CDI-CamelXMLconfigurationimport]]
+Camel XML configuration import
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+*Available as of Camel 2.18*
+
+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).
+
+You can use the `@ImportResource` 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.:
+
+[source,java]
+----
+@ImportResource("camel-context.xml")
+class MyBean {
+}
+----
+
+Camel CDI will load the resources at the specified locations from the
+classpath (other protocols may be added in the future).
+
+Every `CamelContext` 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 `id` attribute set, the corresponding
+CDI bean is qualified with the `@Named` qualifier, e.g., given the
+following Camel XML configuration:
+
+[source,xml]
+----
+<camelContext id="foo">
+    <endpoint id="bar" uri="seda:inbound">
+        <property key="queue" value="#queue"/>
+        <property key="concurrentConsumers" value="10"/>
+    </endpoint>
+<camelContext/>
+----
+
+The corresponding CDI beans are automatically deployed and can be
+injected, e.g.:
+
+[source,java]
+----
+@Inject
+@ContextName("foo")
+CamelContext context;
+
+@Inject
+@Named("bar")
+Endpoint endpoint;
+----
+
+Note that the `CamelContext` beans are automatically qualified with both
+the `@Named` and `@ContextName` qualifiers. If the
+imported `CamelContext` element doesn't have an `id` attribute, the
+corresponding bean is deployed with the built-in `@Default` qualifier.
+
+Conversely, CDI beans deployed in the application can be referred to
+from the Camel XML configuration, usually using the `ref` attribute,
+e.g., given the following bean declared:
+
+[source,java]
+----
+@Produces
+@Named("baz")
+Processor processor = exchange -> exchange.getIn().setHeader("qux", "quux");
+----
+
+A reference to that bean can be declared in the imported Camel XML
+configuration, e.g.:
+
+[source,xml]
+----
+<camelContext id="foo">
+    <route>
+        <from uri="..."/>
+        <process ref="baz"/>
+    </route>
+<camelContext/>
+----
+
 [[CDI-Auto-configuredOSGiintegration]]
 Auto-configured OSGi integration
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -949,6 +1036,10 @@ uses CDI as dependency injection framework
 |Demonstrates the testing features that are provided as part of
 the integration between Camel and CDI
 
+|camel-example-cdi-xml
+|Illustrates the use of Camel XML configuration
+files into a Camel CDI application
+
 |camel-example-swagger-cdi
 |An example using REST DSL and Swagger Java with CDI
 

Reply via email to