CDI

This section described how to add support of CDI, and embed a CDI container in Apache Karaf. It doesn’t describe how to develop CDI applications. See the developer guide for that.

Pax CDI

Apache Karaf supports different CDI containers by using Pax CDI.

Pax CDI is pre-referenced in Apache Karaf. To register the Pax CDI features, you can do:

karaf@root()> feature:repo-add pax-cdi

This command will register the latest pax-cdi features.

You can see now a set of new CDI features available:

karaf@root()> feature:list|grep -i cdi
pax-cdi                       | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Provide CDI support
pax-cdi-1.1                   | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Provide CDI 1.1 support
pax-cdi-weld                  | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Weld CDI support
pax-cdi-1.1-weld              | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Weld CDI 1.1 support
pax-cdi-openwebbeans          | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | OpenWebBeans CDI support
pax-cdi-web                   | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Web CDI support
pax-cdi-1.1-web               | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Web CDI 1.1 support
pax-cdi-web-weld              | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Weld Web CDI support
pax-cdi-1.1-web-weld          | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | Weld Web CDI 1.1 support
pax-cdi-web-openwebbeans      | 0.6.0   |           | org.ops4j.pax.cdi-0.6.0 | OpenWebBeans Web CDI support
pax-cdi-deltaspike-core       | >0.5    |           | org.ops4j.pax.cdi-0.6.0 | Apache Deltaspike core support
pax-cdi-deltaspike-jpa        | 0.5     |           | org.ops4j.pax.cdi-0.6.0 | Apche Deltaspike jpa support
Note

Starting from Apache Karaf 3.0.1, the feature:repo-add pax-cdi command is no more required. Pax CDI features are now automatically included in the Apache Karaf enterprise features.

CDI Containers

Thanks to Pax CDI, Apache Karaf supports multiple CDI implementation versions, and different CDI containers.

You just have to install the feature corresponding to the CDI container and version that you want to use.

Apache OpenWebBeans

Apache Karaf provides a ready to use feature for Apache OpenWebBeans.

The openwebbeans feature automatically install the Pax CDI features and the Apache OpenWebBeans bundles:

karaf@root()> feature:install openwebbeans
Note

With Apache Karaf 3.0.0, don’t forget to register the pax-cdi features repository first with:

karaf@root()> feature:repo-add pax-cdi
JBoss Weld CDI container

Apache Karaf provides a ready to use feature for JBoss Weld.

The weld feature automatically install the Pax CDI features and the JBoss Weld bundles:

karaf@root()> feature:install weld
Note

With Apache Karaf 3.0.0, don’t forget to register the pax-cdi features repository first with:

karaf@root()> feature:repo-add pax-cdi