Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
languagejava
@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
languagejava
@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.:

...

languagebash

...

.

...

Auto-configured OSGi integration

...

Code Block
languagetext
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
languagebash
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:

ContainerVersionRuntime
Weld SE1.1.28.FinalCDI 1.0 / Java SE 7
OpenWebBeans

1.2.7

CDI 1.0 / Java SE 7
Weld SE

2.3.2.Final

CDI 1.2 / Java SE 7
OpenWebBeans

1.6.2

CDI 1.2 / Java SE 7
WildFly8.2.1.FinalCDI 1.2 / Java EE 7
WildFly9.0.1.FinalCDI 1.2 / Java EE 7
Karaf2.4.4CDI 1.2 / OSGi 4 / PAX CDI
Karaf3.0.5CDI 1.2 / OSGi 5 / PAX CDI
Karaf4.0.4CDI 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.

See Also