Which is portable code to achieve this goal?

OldBarBean is a stateless session bean written to the EJB 2.1 API with remote home interface.
OldBarHome and remote component interface OldBar. FooBean is a stateless session bean
written to the EJB 3.0 API.
OldBarBean and FooBean are the only EJBs packaged in the ejb-jar. The FooBean portion of the
ejb-jar. xml also declares an ejb-ref whose ejb-ref-name is ejb/oldBar. The ejb-ref is linked to
OldBarBean. There are no other ejb dependencies defined.
A business method foo in FooBean needs to access OldBarBean.
Which is portable code to achieve this goal?

OldBarBean is a stateless session bean written to the EJB 2.1 API with remote home interface.
OldBarHome and remote component interface OldBar. FooBean is a stateless session bean
written to the EJB 3.0 API.
OldBarBean and FooBean are the only EJBs packaged in the ejb-jar. The FooBean portion of the
ejb-jar. xml also declares an ejb-ref whose ejb-ref-name is ejb/oldBar. The ejb-ref is linked to
OldBarBean. There are no other ejb dependencies defined.
A business method foo in FooBean needs to access OldBarBean.
Which is portable code to achieve this goal?

A.
©Remote
private OldBar oldBar;

B.
public void fooQ {
try {
InitialContext ic = new InitialContextO;
Object obj = ic.lookup(“ejb/oldBar”);
OldBarHome OldBarHome =
(OldBarHome) PortableRemoteObject.narrow(obj,
OldBarHome.class);
OldBar oldBar = oldBarHome.createO;

C.
@EJB private OldBarHome OldBarHome;
public void fooQ {
try {
OldBar oldBar = oldBarHome.createQ;

D.
public void fooQ {
try {
InitialContext ic = new InitialContextO;
OldBarHome OldBarHome =
(OldBarHome) ic.lookup(“ejb/oldBar”);
OldBar oldBar = oldBarHome.createQ;

Explanation:



Leave a Reply 0

Your email address will not be published. Required fields are marked *