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 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 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 foo() {
try {
InitialContext ic = new lnitialContext();
Object obj = ic.lookup(“ejb/oldBar”);
OldBarHome OldBarHome =
(OldBarHome) PortableRemoteObject.narrow(obj,
OldBarHome.class);
OldBar oldBar = oldBarHome.create();

C.
@EJB private OldBarHome oldBarHome;
public void foo() {
try {
OldBar oldBar = oldBarHome.create();

D.
public void foo() {
try {
InitialContext ic = new lnitialContext();
OldBarHome oldBarHome =
(OldBarHome) ic.lookup(“ejb/oldBar”);
OldBar oldBar = oldBarHome.create();



Leave a Reply 0

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