It's in the details :-)

Syed Fareed Ahmad wrote:
> I need more explanation on  returning of an Enumerations from a Entity EJB
> finder method. As far i know from RMI experience is that you cant return a type
> which does not implement "Serializable" interface So every returning type should
> be serializable. Now when i see at Entity EJB finder standards, it is saying
> that we can ONLY have Enumeration  or Collection  (Not a serializable
> interfaces) as the return types. And it also says that the underlying mechanism
> for the communication is RMI. In RMI,  reference can ONLY be passed for a remote
> type (implementing the remote interface). What is exactly going on ? I do know
> every EJB object is also remote type. I have two problems:
>
>    I return an enumeration (by reference) of Entity Beans in a function namely
>    ejbFindAllCustomers, but what happens ? Enumeration is not a Serializable
>    interface?
>    I need to return the enumeration by value? I dont want to have a helper
>    Session EJB (converts the Enumeration into vector). and my client need to
>    play (only read) with the Objects residing in the Enumeration  locally? How
>    can i do it with the existing standards?

Your above understanding of requirements of return values is
(fortunately?) incorrect. It is not the return type of the method that
must extend Serializable, but the class of the instance being returned
which must implement Serializable. Big big difference. For example,
instances of the below class would be allowed as return values:
public class MyEnum
  implements Enumeration, Serializable // Enumeration is indeed not
Serializable, *but* MyEnum is. That's the key.
{
  ...
  public boolean hasMoreElements() { ... }
  public Object nextElement() { ... }
  ...
}

Any RMI method, including EJB interface methods, could have Enumeration
as return type and return instances of the above class:
public Enumeration getTheValues() { return new MyEnum(...); } // MyEnum
is Serializable, so no problemo

/Rickard

--
Rickard �berg

@home: +46 13 177937
Email: [EMAIL PROTECTED]
Homepage: http://www-und.ida.liu.se/~ricob684

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