Repository: camel
Updated Branches:
  refs/heads/master e26e8be21 -> 330abef80


Add CDI example on how to configure endpoints


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

Branch: refs/heads/master
Commit: 330abef8095e36fd51fb3e803bb87a24c93132bd
Parents: 0acecac
Author: Antonin Stefanutti <anto...@stefanutti.fr>
Authored: Wed Feb 24 20:13:24 2016 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Thu Feb 25 08:20:35 2016 +0100

----------------------------------------------------------------------
 .../en/how-do-i-configure-endpoints.adoc        | 58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/330abef8/docs/user-manual/en/how-do-i-configure-endpoints.adoc
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/how-do-i-configure-endpoints.adoc 
b/docs/user-manual/en/how-do-i-configure-endpoints.adoc
index 70639d0..014761c 100644
--- a/docs/user-manual/en/how-do-i-configure-endpoints.adoc
+++ b/docs/user-manual/en/how-do-i-configure-endpoints.adoc
@@ -22,6 +22,63 @@ SomeEndpoint endpoint = camelContext.getEndpoint("someURI", 
SomeEndpoint.class);
 endpoint.setSomething("aValue");
 ----
 
+[[HowdoIconfigureendpoints-UsingCDI]]
+Using CDI
+^^^^^^^^^
+
+You can use link:cdi.html[CDI] as dependency injection framework to configure
+your link:component.html[Component] or link:endpoint.html[Endpoint] instances.
+
+For example, to configure the SJMS component, you can declare a producer method
+in a CDI bean:
+
+[source,java]
+----
+class MyCdiComponent {
+
+  @PropertyInject("jms.maxConnections")
+  int maxConnections;
+
+  @Produces
+  @Named("sjms")
+  @ApplicationScoped
+    SjmsComponent sjms() {
+        SjmsComponent component = new SjmsComponent();
+        component.setConnectionFactory(new 
ActiveMQConnectionFactory("vm://broker?broker.persistent=false"));
+        component.setConnectionCount(maxConnections);
+        return component;
+    }
+}
+----
+
+Then, the component is lazily looked-up by Camel CDI whenever it is referenced,
+e.g. from the Camel Java DSL:
+
+[source,java]
+----
+class MyCdiRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("sjms:sample.queue")
+            .log("Received message [${body}]");
+    }
+}
+----
+
+Besides, endpoints of that component can be injected in any CDI beans, e.g.:
+
+[source,java]
+----
+class MyCdiBean {
+
+    @Inject
+    @Uri("sjms:sample.queue")
+    Endpoint endpoint;
+}
+----
+
+
 [[HowdoIconfigureendpoints-UsingGuice]]
 Using Guice
 ^^^^^^^^^^^
@@ -267,6 +324,7 @@ See Also
 ~~~~~~~~
 
 * link:how-do-i-add-a-component.html[How do I add a component]
+* link:cdi.html[CDI]
 * link:spring.html[Spring]
 * link:uris.html[URIs]
 * link:using-propertyplaceholder.html[Using `PropertyPlaceholder`]

Reply via email to