• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HFEJB C4 Pg 249/256 Q17 - Error

 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chengwei,

I agree with your answers.

Gemini
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic