aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Collections in component interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Collections in component interface" Watch "Collections in component interface" New topic
Author

Collections in component interface

Carlos Llona
Greenhorn

Joined: Apr 09, 2004
Posts: 15
Hello, Sorry my english is poor but I try to explain.

In page 133 of HFEJB show us the "rules for the component interface".
And say that my method's arguments and return types must be serializabbe.....and collections of any of those.

what does it mean with collections?

Its about the interface java.util.Collection or his sons like Vector, ArrayList.

My doubt is because Collection not implemets Serializable and only some of his sons implements Serializable Like a Vector, but List dosn't.

I can have a method wiht that signature in my component interface

public java.util.Collection obtainAll (String s) thorws remoteException;


thanks a lot!!!

Carlos Llona
Vitaliy Geraymovych
Greenhorn

Joined: Jun 15, 2004
Posts: 24
It means that the collection or array should contain serializable elements. For example the collection of strings will be serializable because each element of the collection (string) is serializable by itself.

Check out page 67 in HFE.

Vitaliy


SCBCD 1.3<br />SCJP 1.2<br /> <br />"Every time I learn something new, it pushes some old stuff out of my brain" H.Simpson
Carlos Llona
Greenhorn

Joined: Apr 09, 2004
Posts: 15
Thnaks a Lot

Then, is it possible use the java.util.Collection (or java.util.List) as a return type in one method of my component interface??

When I use java.util.Vector or java.util.ArrayList, everything is ok, but When I use java.util.Collection or java.util.List I've got a message saying that I can't use these interfaces.

Carlos Llona
mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
Originally posted by Carlos Llona:
Thnaks a Lot

Then, is it possible use the java.util.Collection (or java.util.List) as a return type in one method of my component interface??

When I use java.util.Vector or java.util.ArrayList, everything is ok, but When I use java.util.Collection or java.util.List I've got a message saying that I can't use these interfaces.

Carlos Llona



In page 133 of HFEJB show us the "rules for the component interface".
And say that my method's arguments and return types must be serializabbe.....and collections of any of those.

Above means that even Collection should be serializable.

i.e even though the method signature may be

Collection getData()
{

return new ArrayList();
}

here the return Collection should be a Serializable Collection with serializable elements, so when you return the Collection object that object should be a serializable object i,e ArrayList or Vector or other.
Vitaliy Geraymovych
Greenhorn

Joined: Jun 15, 2004
Posts: 24
I am not sure if I understood everything correctly.

Collection is an interface. To use collection you would choose a class that implements collection (like Vector or HashSet, which implement Serializable interface.)

Are you saying that you cannot deploy your bean because methods returns java.util.Collection? or you have some compile error?

Could you post the error that you are getting?

Thanks,
Vitaliy
Carlos Llona
Greenhorn

Joined: Apr 09, 2004
Posts: 15
Sorry Vitaliy

I make a huge mistake, I use WSAD for running my beans. when I put a method in my component interface websphere shows me a warning that says something like that "the specifications says that all objects must implements Serializable". I thought that I coudn't deploy my beans, but I just made the test and all works fine , I suposse that the warning appears because Collecion doesn't implements Serializable.

Now it's all clear

And thanks a lot

byte!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collections in component interface
 
Similar Threads
Why are Iterators non-serializable?
Collection findXXX()
Soriting a vector in descending order
Generic Ques
how do i solve this recorsive function question??