Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PortableRemotObject.narrow

 
Carlos Llona
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello: can anybody help in that topic

I know that I have to narrow the home interface when I want to use acording to the specification laike this:

Context initialContext = new InitialContext();
CartHome cartHome = (CartHome)javax.rmi.PortableRemoteObject.narrow(
initialContext.lookup(“java:comp/env/ejb/cart” ,
CartHome.class);

But what happend when in a session I invoke a method of a entity that return a collecion of bean? do I have to use portableremoteObject() or a simple cast?

And what happend whith the findByPrimeryKey that return the component interface remote. I never use portableremoteObject, do I should???


Thanks!! a lot
 
Rajnish Bhasin
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Narrowing is only for the Initial EJBHome Stub....that too only in case of Remote Calls.... since u r doing a IIOP call which might result in u getting Objects of some other Language type...so u need to make sure that u get the right object from yr IIOP call.

After u get the EJBHome stub... u r all set... then u dont need a narrow call ever... since u already know what Object u r working on....of course u can get a collection from from yr EJBHome object when u fetch more than ONE primary key.... but the whole point is that u r aware that these calls are on the EJBHome STUB ...

But in case of the IIOP lookup u are not sure footed as to what Object type u might be returned ... so PortableRemoteObject.narrow() makes it sure u get the right Object.

Hope this helps...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic