Java Reference
In-Depth Information
Listing 13.13. Structure of an EJB-JAR marked for CDI bean discovery
The beans.xml
marks the module for CDI bean discovery;
-
are classes scanned
by CDI, and if they contain CDI annotations, they're managed by CDI.
WAR
For WAR modules, add the WEB-INF/beans.xml file. The following listing shows an ex-
ample.
Listing 13.14. Structure of a WAR marked for CDI bean discovery
The beans.xml marks the module for CDI bean discovery; - are classes scanned
by CDI, and if they contain CDI annotations, they're managed by CDI. A WAR module
also contains a WEB-INF/lib/ directory, which may contain any number of JAR archives.
Remember, those JAR archives themselves may be marked for CDI by following the ex-
ample of listing 13.12 .
The beans.xml file has been vital to CDI up until Java EE 7. Now the Java EE 7 spe-
cification has made the beans.xml file optional. It's been replaced with the bean-
discovery-mod e annotation in the deployment descriptor. We'll look at this annotation
next.
Search WWH ::




Custom Search