Nicholas Whitehead wrote:
>
> Some RMI implementations use the native Java JRMIP (or
> something like that) and some use IIOP. The former
> allowed a simple cast from Object to your Home, but
> IIOP does not support the simple Java caset and so it
> requires the call to narrow which essentially
> unmarshalling an IIOP stream to your desired class.
>
> That's the general idea, though I am a little fuzzy on
> the details.

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). There is really only one valid reason why it is necessary to use
'narrow'.

(1) The spec says you must 'narrow', and some vendors require it, so to ensure
    portability of your code you must do it.

I suspect the reason the spec says you must 'narrow' the references is that one
or more vendors were having a hard time working out how to support the simple
type cast when using IIOP, and as a result pressed the EJB architects to make
their job easier. Frankly, I can see no good reason for the 'narrow'
requirement other than that.

Also, at this point one or more vendors may have modified their products so
that they 'require' the narrow, just to ensure that you always write portable
code (i.e. they know how to support a simple type cast but have decided it is
in your best interests (for portability) to insist on using the 'narrow').

> //Nicholas
> --- Craig Herder <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I am new to EJB.  Could someone explain the
> > following statement(s) in terms
> > of why
> > I need to typecast a generic object into the home
> > interface type, using the
> > narrow
> > method?  What's going on behind the scene here?
> >
> > Object boundObject =
> > context.lookup("java:comp/env/ejb/HelloHome");
> > helloHome = (HelloHome)
> > PortableRemoteObject.narrow(boundObject,
> > HelloHome.class);
> >
> > TIA,
> >
> > Craig Herder
> >
> >
> ===========================================================================
> > 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".
> >
>
> =====
> Nicholas Whitehead
> Home: (973) 377 9335
> Cell: (973) 615 9646
> [EMAIL PROTECTED]
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.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".

--
________________________________________________________________________________

Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
                            Wellington, New Zealand               +64 4 934-5856

===========================================================================
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".

Reply via email to