• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Collections in component interface

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Carlos Llona
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic