As I understand it you only have to narrow 'remote' objects, by which I mean
objects which are being returned as a remote interface (java.rmi.remote),
not objects on a remote machine.

Bear in mind that what you get when you lookup a home object from JNDI is
not an object of type MyObjectHome, because MyObjectHome is an interface.
You are actually getting a stub object which implements MyObjectHome but
also has the necessary network code in it. If you have ever worked with
CORBA then the whole narrowing thing will be very familiar, and RMI over
IIOP (IIOP being the CORBA protocol) pushes you down the same route.

In short, you do not need to narrow object when you put them into the JNDI
context.

Dave Smith
Senior Team Leader
Aristocrat Technologies Australia Pty Ltd

mailto:[EMAIL PROTECTED]


-----Original Message-----
From: Jens Stutte [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 27 July 2000 22:04
To: Orion-Interest
Subject: AW: Getting remote objects


Hi,

very interesting. BTW, what should i do if i _bind_ an object to a naming
context? Do i have to narrow the object, too? Like:
ctx.bind(JNDINAME, javax.rmi.PortableRemoteObject.narrow(MyObject,
???.class));
And if so, to which class type must it be narrowd? java.lang.Object ? 

Regards,

Jens Stutte

> -----Ursprüngliche Nachricht-----
> Von: Dave Smith [mailto:[EMAIL PROTECTED]]
> Gesendet am: Donnerstag, 27. Juli 2000 00:40
> An: Orion-Interest
> Betreff: RE: Getting remote objects
> 
> These are not exclusive, they are both required:
>  
>  Context context = new InitialContext();
>  MyHome mh = (MyHome)javax.rmi.PortableRemoteObject.narrow(
> context.lookup("HomeName"), MyHome.class);
> 
> It used to be permissible to just do
>  
> MyHome th = (MyHome)context.lookup("HomeName");
>  
> but the advent of RMI-IIOP made this extra narrowing step 
> necessary. You may
> find that EJB servers that do not use RMI over IIOP will work 
> with the old
> (brief) method, but protect yourself by using the narrowing 
> step for all
> remote objects as well.
> 
> 
> Dave Smith 
> Senior Team Leader 
> Aristocrat Technologies Australia Pty Ltd 
> 
> mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  
> 
>  
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 27 July 2000 7:05
> To: Orion-Interest
> Subject: Getting remote objects
> 
> 
> 
> After reading volumes of information on EJB's, I am a bit 
> confused as to
> what is the preferred method for obtaining a reference to an 
> EJB from the
> client.  I see 2 styles of doing this.  One involves casting 
> to the Home
> interface by doing a 'Context.lookup(String jndi_name)', 
> while the other is
> by using PortableRemoteObject.narrow(...).   Is there any 
> benefit to either
> one?  I prefer the former, since the syntax seems much 
> cleaner, but what's
> the bottom line? 
> 
> Also, what are the core set of Orion-specific .jars that must 
> be distributed
> to a client when using orionserver? 
> 
> Thanks, 
> -Jason
> 
> 

Reply via email to