CDIPage edited by Christian MuellerChanges (1)
Full ContentCamel CDIAs of 2.10 we now have support Contexts and Dependency Injection - JSR299 and Dependency Injection for Java - JSR330 as a dependency injection framework. This offers new opportunities to develop and deploy Apache Camel projects in Java EE 6 containers but also in standalone Java SE or CDI container The current project is under active development and does not provide all the features that we have with injection frameworks like Spring or Blueprint Dependency Injecting Camel with CDIBasically, two things should be done to use Apache Camel in a CDI environment. First, we just need to create a BootStrap class which will be use by the Java EE 6 container or Java SE to start the Camel Context. The CdiCamelContext when instantiated will add a CDI Bean Registry. That will allow Camel to perform lookup of beans injected and registered in CDI container. Next, we must add CDI annotated beans (@inject, @named, ...) to use them from the Apache Camel routes. Bootstrapping Camel with CDI containerThe following example shows how we can bootstrap an Apache Camel Context in a Boot Strap class. This class contains important annotations like the javax.ejb.Singleton. This annotation will tell the container to create a Singleton instance of the BootStrapClass class. This mechanism is similar to Bean instance creation that we have with Spring framework. By combining this annotation with javax.ejb.Startup, the container will start the camel context at the startup of the CDI container. @Singleton @Startup public class BootStrap { ...
Stop watching space
|
Change email notification preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Camel > CDI Christian Mueller (Confluence)
- [CONF] Apache Camel > CDI Christian Mueller (Confluence)
- [CONF] Apache Camel > CDI Christian Mueller (Confluence)
- [CONF] Apache Camel > CDI Christian Mueller (Confluence)