IMHO the reason for narrow() is the support for RMI-IIOP.
Since RMI-IIOP is a CORBA-protocol and CORBA is language independent, it
must be guaranteed that all serialized and transmitted data can be "cast" to
some kind of language specific structure, object etc.
However, not all languages support cast operations and thus have to make
manual transformations (i.e. fill a struct in C). This will be done in the
method or function narrow().
The simple cast works fine for java RMI, but as RMI-IIOP is the protocol of
the future it is highly recommended to use narrow().
----- Original Message -----
From: "Steve Holder" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 15, 2000 10:53 PM
Subject: Re: JSP-EJB problem.
> When and why should PortableRemoteObject.narrow() be used vs. a standard
> cast? I've noticed that in the Monson-Haefal book, he uses standard casts
> after doing JNDI lookups. That's the way we've been doing things here,
and
> it seems to work fine (though we haven't actually deployed any ejbs to
> production servers, yet). Most other code snippets I've seen seem to use
> .narrow(), but I haven't been able to find any explanation for why... all
> the javadocs say for .narrow() is "Checks to ensure that an object of a
> remote or abstract interface type can be cast to a desired type.", but we
> seem to get the same effect by just trying to cast normally. Is there
some
> advantage to using .narrow() that I'm not aware of?
>
> Steve Holder
>
>
> -----Original Message-----
> From: Christensen, Kurt [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 15, 2000 12:11 PM
> To: [EMAIL PROTECTED]
> Subject: Re: JSP-EJB problem.
>
>
> Probably you need to NOT do an RMI-style (that is, ordinary Java) type
cast
> and use a CORBA type cast, which will look something like:
>
> MyDesiredType castedObject =
> (MyDesiredType)javax.rmi.PortableRemoteObject.narrow( passedObject,
> <java.lang.Class object that corresponds to MyDesiredType>)
>
> KurtC
>
>
> -----Original Message-----
> From: Amit Tyagi [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 15, 2000 7:01 PM
> To: [EMAIL PROTECTED]
> Subject: JSP-EJB problem.
>
>
> Hi all,
>
> We r using JSP-EJB platform. Application Server we r
> using is Silver Stream 3.0. We have deployed JSP and
> EJB to App. Server. But we r unable to make JavaBean
> (used in JSP) talk to EJB.
>
> We get correct initialContext and lookup is also
> successfull. But when we try to type cast object
> returned in the lookup to our home interface. it
> generates class cast exception. What could be the
> reason? Object returned is the stub of home interface.
>
> Does Silverstream 3 supports Javabeans looking up for
> EJB?
>
> Thankx in advance
>
> Bye
> Amit Tyagi
> reply to [EMAIL PROTECTED]
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Photos -- now, 100 FREE prints!
> http://photos.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".
>
>
===========================================================================
> 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".