Dependencies: com.my-cdi-module meta-inf, com.my-other-cdi-module meta-inf
AS7 uses Weld, the CDI reference implementation as its CDI provider. To activate CDI for a deployment simply add a beans.xml file in any archive in the deployment.
This document is not intended to be a CDI tutorial, it only covers CDI usage that is specific to AS7. For some general information on CDI see the below links:
CDI Specification
Weld Reference Guide
The AS7 Quickstarts
For AS 7.2 onwards it is now possible have classes outside the deployment be picked up as CDI beans. In order for this to work you must add a dependency on the external deployment that your beans are coming from, and make sure the META-INF directory of this deployment is imported, so that your deployment has visibility to the beans.xml file (To import beans from outside the deployment they must be in an archive with a beans.xml file).
There are two ways to do this, either using the MANIFEST.MF or using jboss-deployment-structure.xml.
Using MANIFEST.MF you need to add a Dependencies entry, with meta-inf specified after the entry, e.g.
Dependencies: com.my-cdi-module meta-inf, com.my-other-cdi-module meta-inf
Using jboss-deployment-structure.xml you need to add a dependency entry with meta-inf="import", e.g.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <dependencies> <module name="deployment.d1.jar" meta-inf="import"/> </dependencies> </deployment> </jboss-deployment-structure>
Note that this can be used to create beans from both modules in the modules directory, and from other deployments.
For more information on class loading and adding dependencies to your deployment please see the Class Loading Guide