This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PortableRemoteObject.narrow Explain

bala subramanian
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;
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,
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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!