• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When I need use PortableRemoteObject.narrow() ?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/161190/java-EJB-SCBCD/certification/narrowing-results
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic