Win a copy of Terraform in Action this week in the Cloud forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

PortableRemoteObject.narrow Explain

Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Bookmark Topic Watch Topic
  • New Topic