Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When I need use PortableRemoteObject.narrow() ?

 
Lu Jin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q52. Which of the following piece of code should be used to retrieve the component interface of Order entity bean (select the best answer):

A: (Order)javax.rmi.PortableRemoteObject.narrow(handle.getEJBObject(), Order.class)
B: handle.getEJBObject()
C: (Order)handle.getEJBObject()
D: javax.rmi.PortableRemoteObject.narrow(handle.getEJBObject(), Order.class)

The correct answer is "A".

Anybody can tell me in which cases I need use PortableRemoteObject.narrow()? Thanks!
 
Muthaiah Ramanathan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, are you sure the question is right? The answer provided is not correct, I believe. For the PortableRemoteObject, a JNDI context has to be passed in and not the EJBObject. The rest of the answers doesn't have much information to decide whether which is correct.
 
Lu Jin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't agree with u. I think not only the objects returned from JNDI look up need to be narrowed.
 
Imran Vohra
Ranch Hand
Posts: 77
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In HFEJB it is clearly mentioned that when you fetch EJBObject through handle at that time also you have to do narrow. (Page No 139)
Apart from lookup through JNDI you also have to do narrow when you try to lookup another bean from one bean, through special JNDI subcontext(java:comp/env). (PN 613).
I hope in these 3 cases we have to do narrow. If I have missed any point please let me know.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic