...
Multiple Camel contexts support
Configuration properties
Auto-configured type converters
CDI beans annotated with the @Converter
annotation are automatically registered into the deployed Camel contexts, e.g.:
Code Block | ||
---|---|---|
| ||
@Converter
public class MyTypeConverter {
@Converter
public Output convert(Input input) {
//...
}
} |
Note that CDI injection is supported within the type converters.
Camel bean integration
Camel events to CDI events
...
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.
Auto-configured type converters
CDI beans annotated with the @Converter
annotation are automatically registered into the deployed Camel contexts, e.g.:
Code Block | ||
---|---|---|
| ||
@Converter
public class MyTypeConverter {
@Converter
public Output convert(Input input) {
//...
}
} |
Note that CDI injection is supported within the type converters.
Configuration properties
Camel bean integration
Maven Archetype
Among the available Camel Maven archetypes, you can use the provided camel-archetype-cdi
to generate a Camel CDI Maven project, e.g.:
...
language | bash |
---|
...
.
...
Auto-configured OSGi integration
...
Code Block | ||
---|---|---|
| ||
karaf@root()> camel:context-list
Context Status Total # Failed # Inflight # Uptime
------- ------ ------- -------- ---------- ------
camel-cdi Started 1 0 0 1 minute |
See the camel-example-cdi-osgi
example for a working example of the Camel CDI OSGi integration.
Maven Archetype
Among the available Camel Maven archetypes, you can use the provided camel-archetype-cdi
to generate a Camel CDI Maven project, e.g.:
Code Block | ||
---|---|---|
| ||
mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-cdi |
Supported containers
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:
Container | Version | Runtime |
---|---|---|
Weld SE | 1.1.28.Final | CDI 1.0 / Java SE 7 |
OpenWebBeans |
| CDI 1.0 / Java SE 7 |
Weld SE |
| CDI 1.2 / Java SE 7 |
OpenWebBeans |
| CDI 1.2 / Java SE 7 |
WildFly | 8.2.1.Final | CDI 1.2 / Java EE 7 |
WildFly | 9.0.1.Final | CDI 1.2 / Java EE 7 |
Karaf | 2.4.4 | CDI 1.2 / OSGi 4 / PAX CDI |
Karaf | 3.0.5 | CDI 1.2 / OSGi 5 / PAX CDI |
Karaf | 4.0.4 | CDI 1.2 / OSGi 6 / PAX CDI |
Examples
...
The following examples are available in the examples
directory of the Camel project:
camel-example-cdi-metrics
- illustrates the integration between Camel, Dropwizard Metrics and CDI,camel-example-cdi-properties
- illustrates the integration between Camel, DeltaSpike and CDI for configuration properties,camel-example-cdi-osgi
- a CDI application using the SJMS component that can be executed inside an OSGi container using PAX CDI,camel-example-cdi-rest-servlet
- illustrates the Camel REST DSL being used in a Web application that uses CDI as dependency injection framework,camel-example-widget-gadget-cdi
- The Widget and Gadget use-case from the EIP book implemented in Java with CDI dependency Injection.