• Post Reply Bookmark Topic Watch Topic
  • New Topic

is is neccassary to narrow the object  RSS feed

 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
ctx = new InitialContext(ht);
java.lang.Object obj = ctx.lookup("RemoteCabinHome");
CabinHome home = (CabinHome) PortableRemoteObject.narrow(obj, CabinHome.class);
Why did we write narrow () method in EJB? Is it necessary to write?what PortableRemoteObject will do here?
can't we write directly like this?
ctx = new InitialContext(ht);
CabinHome home = (CabinHome) ctx.lookup("RemoteCabinHome");

bye
chaitanya
 
Prakash Anthony
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do a direct cast, if using EJB 2.0 Local clients.
However, communication b/w the Server and client relies on RMI and implement java.rmi.Remote interface. Given the underlying protocol is IIOP, which is generic (and not specifically for Java) and hence the explicit narrowing.
Hope this helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!