What about non Java clients? I thought one of the reason for using IIOP was
to better support interoperability.
Cheers
Lawrence
> ----------
> From: Jonathan K. Weedon[SMTP:[EMAIL PROTECTED]]
> Reply To: A mailing list for Enterprise JavaBeans development
> Sent: 27 February 2001 07:46
> To: [EMAIL PROTECTED]
> Subject: Re: narrow
>
> Sumesh,
>
> I am not sure if you were disagreeing with me or not. But if you
> were, then I might point out that COBOL is not relevant for RMI-
> over-IIOP. I fully agree (and previously stated) that there are
> needs for the narrow operation in CORBA, but in the case of RMI-
> over-IIOP (which is, by definition, a Java only case) the narrow
> should not be required. The fact that the current EJB spec requires
> it is an oversight.
>
> -jkw (the original developer of VisiBroker for Java)
>
> sumesh wrote:
> >
> > the javax.naming.Context.lookup() will return an Object.
> > In ejb1.0 it ws enough to cast it as teh protocol used was RMI .
> > but in ejb1.1 it is required that it be compatible with RMI-IIOP..
> > Since CORBA is programming language independent it is not possible to
> use
> > casting. Because of the fact that some languages doesn't have the
> concept of
> > polymorphism or inheritance(like COBOL) implicit casting is not at all
> aceptable
> >
> > "Jonathan K. Weedon" wrote:
> >
> > > Tibo,
> > >
> > > Although your answer is 100% correct, I thought it would be useful
> > > to reiterate Evan's comment:
> > >
> > > > Actually nothing prevents a vendor from supporting a simple cast
> even when
> > > > using IIOP (I know that because we implemented it in Sybase EAServer
> and it
> > > > was easy).
> > >
> > > <vendor>
> > > I second the fact that this is possible. In fact, an early version
> > > of Borland AppServer also did the "automagic" casting, over IIOP. But
> > > our users complained about non-compliance with the spec, and asked
> > > that we require the narrow by default, thereby forcing users to write
> > > portable code.
> > > </vendor>
> > >
> > > So, strictly speaking, the narrow is not required for the EJB use
> > > case of RMI-over-IIOP (although there are some very obscure pure-CORBA
> > > use cases that do require the narrow).
> > >
> > > As such, I would love to see a future version of the EJB spec lift
> > > this rather bothersome requirement, although until that happens we
> > > will require users to write portable EJB code.
> > >
> > > -jkw
> > >
> > > Thibault Cuvillier wrote:
> > > > narrow is a CORBAism, which cannot be hidden by the RMI API.
> > > > To understand the narrow method, you need to understand how CORBA
> proxies
> > > > are managed.
> > > >
> > > > CORBA proxies
> > > > -------------
> > > >
> > > > Example:
> > > > The remote interface B extends the remote interface A
> > > > The remote object implementing the interface B (and so, A)
> > > >
> > > > When you get a remote reference from the naming service, CORBA will
> create a
> > > > Corbae object stub, which is the super class of all the CORBA
> proxies. If
> > > > you try to cast it down to a proxy to B, you will get a
> ClassCastException.
> > > >
> > > > With CORBA, the proxy may not implemented all the remote interfaces
> of the
> > > > remote object.
> > > >
> > > > So, you have to call the narrow method to create a proxy
> implementing the
> > > > right interface.
> > > >
> > > > The narrow method do the following job:
> > > > 1- Test if the proxy implements the requested interface
> > > > If yes, the proxy is only casted-down and returned
> as-is.
> > > > 2- If No, the method test if the remote object implements
> the
> > > > requested interface
> > > > Call the CORBA method is_a which check if the cast
> is
> > > > correct on the server side (IIOP request)
> > > > If not, an exception is send (Corba BAD_PARAM
> exception)
> > > > 3- Create a new proxy
> > > > The narrow method return a new proxy.
> > > >
> > > > Here is an example of the narrow method generated by Javaidl:
> > > > public static A narrow (org.omg.CORBA.Object obj)
> > > > {
> > > > if (obj == null)
> > > > return null;
> > > > else if (obj instanceof A)
> > > > return (A)obj;
> > > > else if (!obj._is_a (id ()))
> > > > throw new org.omg.CORBA.BAD_PARAM ();
> > > > else
> > > > {
> > > > org.omg.CORBA.portable.Delegate delegate =
> > > > ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
> > > > return new AStub (delegate);
> > > > }
> > > > }
> > > > Remark:
> > > > - the Delegate object contains ORB specific code.
> > > > - The AStub do not implements the B interface.
> > > >
> > > > 2-- RMI over JRMP
> > > > Much simpler. When you lookup an object with RMI, RMI will create a
> proxy
> > > > consistant with the remote object interfaces.
> > > > So you don't need narrow at all.
> > > >
> > > > 3-- So,
> > > > With EJB, look at the following code:
> > > > Object object = context.lookup("ejb.A");
> > > > A a = (A)PortableRemoteObject.narrow(object, A.class);
> > > >
> > > > With CORBA, the proxy a implements the interface A, but not
> B !
> > > > With RMI, the proxy a implements A and B, because the remote
> object
> > > > support these interfaces.
> > > >
> > > > So if you cast down the proxy like that:
> > > > B b = (A)a;
> > > > With CORBA you will get an exception.
> > > > With RMI it will works.
> > > >
> > > > To make your code portable, you need to write:
> > > > B b = (B)PortableRemoteObject.narrow(a, B.class);
> > > > With CORBA, narrow will create a new proxy, but the proxies
> a and b
> > > > will contains a reference to the same remote object.
> > > >
> > > > Hope this help
> > > > Tibo.
> > > > http://www.valtech.com
> > >
> > >
> ==========================================================================
> =
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > > of the message "signoff EJB-INTEREST". For general help, send email
> to
> > > [EMAIL PROTECTED] and include in the body of the message "help".
> >
> >
> ==========================================================================
> =
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff EJB-INTEREST". For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
Visit us at http://www.clearstream.com
IMPORTANT MESSAGE
Internet communications are not secure and therefore Clearstream International does not
accept legal responsibility for the contents of this message.
The information contained in this e-mail is confidential and may be legally
privileged. It is
intended solely for the addressee. If you are not the intended recipient, any
disclosure,
copying, distribution or any action taken or omitted to be taken in reliance on it, is
prohibited and may be unlawful. Any views expressed in this e-mail are those of the
individual sender, except where the sender specifically states them to be the views of
Clearstream International or of any of its affiliates or subsidiaries.
END OF DISCLAIMER
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".