//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

==== 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
----
====
