Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PortableRemoteObject.narrow Explain  RSS feed

 
bala subramanian
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the diff between the two?
Properties prop=new Properties();
Context cxt=null;
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://localhost:80");
cxt=new InitialContext(prop);
EmployeeHome home = (EmployeeHome)cxt.lookup("emp");
Employee emp = home.create();

Properties p = new Properties() ;
Context ctx = null ;
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory") ;
p.put(Context.PROVIDER_URL, url) ;
ctx = new InitialContext(p) ;
Object obj = ctx.lookup("utils.Sequence") ;
SequenceHome sHome = (SequenceHome) javax.rmi.PortableRemoteObject.narrow(obj, SequenceHome.class) ;
Sequence sRemote = (Sequence) sHome.create() ;
thanks in adv,
Bala
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This difference could be two different things:
1) The first example might be looking up a local home interface, in which case the use of PortableRemoteObject.narrow() is not necessary and in fact is wrong.
2) The first example is looking up a remote home and the PortableRemoteObject.narrow() should have indeed been used to support compatibility with IIOP. However, since WebLogic's T3 protocol is being used then it is not strictly necessary.
For more information on why we need to use PortableRemoteObject.narrow(), see these threads:
Portable remote object
PortableRemoteObject.narrow()
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!