You are right.  If you have to cast, and its a remote object, then do a PRO.narrow().
Since the Enum/Collection methods return "Object" you need to cast to your interface 
so do the narrow.

Dion

> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Dale V. Georg
> Sent: Tuesday, October 23, 2001 8:32 AM
> To: [EMAIL PROTECTED]
> Subject: PortableRemoteObject.narrow() Clarification
>
>
> My understanding of PortableRemoteObject.narrow() is that it ensures
> that the remote object can be cast to the appropriate class that you
> need to cast it to.  So, for example, when you do a ctx.lookup() for a
> home interface, you have to do PRO.narrow() before your cast to make
> sure that the cast will work.  (I know that some app servers work just
> fine without ever doing the PRO.narrow(), but I'm trying to speak to the
> generic case here, since app server independence is critical for me).
>
> Now, when calling the create() method on the home interface, or when
> calling the findByPrimaryKey() method on the home interface of an Entity
> Bean, PRO.narrow() is not called.  This is because those methods are
> already declared with the appropriate runtime return type, therefore no
> casting is needed, and because no casting is needed, no PRO.narrow() is
> needed.  Correct so far?
>
> OK, so here's where I'm looking for clarification:  If I have a finder
> method which returns an Enumeration, I then am required to cast the
> objects that I take out of the Enumeration.  Is it therefore reasonable
> to assume that I ought to be doing a PRO.narrow() as well?  Our code was
> not doing this, and it was working fine until we tried to run it on one
> particular app server, and then adding PRO.narrow() seemed to resolve
> the problem.  So is it a reasonable rule of thumb to say that to
> guarantee portability, PRO.narrow() must be called whereever casting of
> a remote object is required?
>
> Thanks,
> Dale
>
> ================================
>    Dale V. Georg
>    Technical Manager
>    Indus Consultancy Services
>    [EMAIL PROTECTED]
>    (201) 261-3100 x229
> ================================
>
> ===========================================================================
> 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".

Reply via email to