Java Reference
In-Depth Information
java:app/accountejb/AccountBean!com.bazaar.Account
java:module/AccountBean
java:module/AccountBean!com.bazaar.Account
If it's deployed as accountejb.jar inside accountapp.ear, it'll have the following JNDI bind-
ings:
java:global/accountapp/accountejb/AccountBean
java:global/accountapp/accountejb/AccountBean!com.bazaar.Account
java:app/accountejb/AccountBean
java:app/accountejb/AccountBean!com.bazaar.Account
java:module/AccountBean
java:module/AccountBean!com.bazaar.Account
If it's deployed as accountweb.war, it'll have the following JNDI bindings:
java:global/accountweb/AccountBean
java:global/accountweb/AccountBean!com.bazaar.Account
java:app/accountweb/AccountBean
java:app/accountweb/AccountBean!com.bazaar.Account
java:module/AccountBean
java:module/AccountBean!com.bazaar.Account
Now that you know how the portable JNDI names for EJBs are assigned, we'll look at the
@EJB annotation, which takes away the complexity of JNDI lookups and allows the EE
server to inject EJBs as needed.
5.2.3. EJB injection using @EJB
The @EJB annotation was introduced to allow injection of EJBs into client code without
the client code needing to perform JNDI lookups. Although the portable JNDI names for
EJBs make the look-up of beans easier, lookups still put the responsibility on the developer
to get the dependencies your code needs. By using the @EJB annotation, that responsibility
is now part of the EE server, and the EJB container will inject the dependencies for you.
The following listing shows the @EJB annotation.
Search WWH ::




Custom Search