Valid 1Z0-895 Dumps shared by ExamDiscuss.com for Helping Passing 1Z0-895 Exam! ExamDiscuss.com now offer the newest 1Z0-895 exam dumps, the ExamDiscuss.com 1Z0-895 exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com 1Z0-895 dumps with Test Engine here:
A developer writes a stateless session bean FooBean and uses its deployment descriptor to declare a local ejb dependency on a stateful session bean in the same ejb-jar. Which environment annotation, when declared within the FooBean bean class, is equivalent to the ejb- local-ref shown above?
Correct Answer: C
Explanation/Reference: name is barRef Example: ejb-local-ref share [gp] share [fb] share [tw] contribute Via annotation Usable by EJB, Interceptor, Servlet, Filter, or Listener package org.superbiz.refs; import javax.ejb.EJB; import javax.ejb.Stateless; import javax.naming.InitialContext; @ Stateless @ EJB(name = "myFooEjb", beanInterface = FooLocal.class) public class MyEjbLocalRefBean implements MyBeanInterface { @ EJB private BarLocal myBarEjb; public void someBusinessMethod() throws Exception { if (myBarEjb == null) throw new NullPointerException("myBarEjb not injected"); / / Both can be looked up from JNDI as well InitialContext context = new InitialContext(); FooLocal fooLocal = (FooLocal) context.lookup("java:comp/env/ myFooEjb"); BarLocal barLocal = (BarLocal) context.lookup("java:comp/env/ org.superbiz.refs.MyEjbLocalRefBean/myBarEjb"); } } Via xml The above @EJB annotation usage is 100% equivalent to the following xml. < ejb-local-ref> < ejb-ref-name>myFooEjb</ejb-ref-name> <local>org.superbiz.refs.FooLocal</local> </ejb-local-ref> < ejb-local-ref> < ejb-ref-name>org.superbiz.refs.MyEjbLocalRefBean/myBarEjb</ejb-ref-name> < local>org.superbiz.refs.BarLocal</local> < injection-target> <injection-target-class>org.superbiz.refs.MyEjbLocalRefBean</injection- target-class> < injection-target-name>myBarEjb</injection-target-name> < /injection-target> </ejb-local-ref>