aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes HFEJB C4 Pg 249/256 Q17 - Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "HFEJB C4 Pg 249/256 Q17 - Error" Watch "HFEJB C4 Pg 249/256 Q17 - Error" New topic
Author

HFEJB C4 Pg 249/256 Q17 - Error

Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
The provided solution was that for a local component (interface), its methods must not throw java.rmi.RemoteException (fully agree) & the local home (interface) can be used to retrieve an EJBLocalObject (totally disagree, the API says so too).

The question also states that its a 1-1 mapping in this question. As far as the API says, EJBLocalHome interface has only 1 single method, i.e., remove(Object pk). It is the EJBLocalObject (local component interface) that has a getEJBLocalHome method.
[ March 22, 2005: Message edited by: Chengwei Lee ]

SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Chengwei,

I agree with your answers.

Gemini
Stefan Guilhen
Ranch Hand

Joined: Jul 31, 2004
Posts: 61
Originally posted by Chengwei Lee:
The provided solution was that for a local component (interface), its methods must not throw java.rmi.RemoteException (fully agree) & the local home (interface) can be used to retrieve an EJBLocalObject (totally disagree, the API says so too).

The question also states that its a 1-1 mapping in this question. As far as the API says, EJBLocalHome interface has only 1 single method, i.e., remove(Object pk). It is the EJBLocalObject (local component interface) that has a getEJBLocalObject method.


Notice that the answer does not state that you can use the EJBLocalHome to retrieve an EJBLocalObject. It says that you can use the local home to retrieve an EJBLocalObject reference. Since session beans must define at least one create() method in the home interface, a client can use the create() method of the local home to retrieve a reference to an EJBLocalObject.

Regards,
Stefan


SCJP 1.4, SCBCD 1.3<br />IBM 141, 484, 486
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Hi Stefan,

Notice that the answer does not state that you can use the EJBLocalHome to retrieve an EJBLocalObject. It says that you can use the local home to retrieve an EJBLocalObject reference.


So in your opinion, what is the local home refering to? The container generated stubs?

Since session beans must define at least one create() method in the home interface, a client can use the create() method of the local home to retrieve a reference to an EJBLocalObject.


As you said it yourself, the create method is defined in the home interface, the ejbCreate method is implemented in the actual bean class. The bean isn't the local home, don't you agree?

I agree with you that the client is able to get the EJBLocalObject inside the ejbCreate method.

Cheers!

Chengwei
Stefan Guilhen
Ranch Hand

Joined: Jul 31, 2004
Posts: 61
Hi Chengwei,



So in your opinion, what is the local home refering to? The container generated stubs?



No, it can't be any generated stub since the home is local (it is just a normal java reference). I interpret local home as a reference to the local home that you get from the JNDI. Something along the lines of:

Context ctx = new InitialContext();
MyBeanLocalHome home = (MyBeanLocalHome) ctx.lookup("java:comp/env/ejb/mybeanlocal");

As you can see, home is a reference to something that implements MyLocalHome, the local home interface of my bean. The interface that provides the create() methods.



As you said it yourself, the create method is defined in the home interface, the ejbCreate method is implemented in the actual bean class. The bean isn't the local home, don't you agree?


Precisely. But what can be found in the MyBeanLocalHome interface? At least one create() method, that must return a reference to the local component interface. Something like:



So, a client who performed a lookup as I showed above, can use the local home reference he got from JNDI to get a reference to the local component interface, that is, an interface that extends EJBLocalObject by calling the create() method:



This is how I interpreted the question. From my point of view a client that has a local home reference of a session bean can use it to get a reference to the local component (something that is a EJBLocalObject) interface of the session bean by calling the create() method.

Also, you said in the first post that the EJBLocalObject interface has a getEJBLocalObject method, but that is wrong. You have a getEJBLocalHome method there instead.

Regards,
Stefan
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
HI Stefan,

Also, you said in the first post that the EJBLocalObject interface has a getEJBLocalObject method, but that is wrong. You have a getEJBLocalHome method there instead.


You're, it's a typo error. Going along your line of thinking, if the client has the EJBLocalObject, it would already holds a reference to it already. Won't this be correct too?

Also, since the EJBLocalObject has a method to find its local home object, the client could make use of the local home to create more local EJB objects. That way, the client can too get reference(s) to the EJBLocalObject(s).

What do you think?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HFEJB C4 Pg 249/256 Q17 - Error