• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why EJBs are serialized

 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EnterpriseBean interface extends Serializable interface, and Bean class implements the Serializable through EntityBean or SessionBean interface. But the Bean class never travels over the network. The Bean class consists of call back methods which are called by EJB container hence it can only run in the Server JVM. Then why do we need to have Bean class as Serializable?

This is what I feel
I think, when bean's activate and passivate method is called, bean has to store its state by persisting itself. As per java specification, object must be serialized to persist.
But here again, one more question arises, activate and passivate method is useless for stateless session bean then why stateless session bean is serialized.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say EnterpriseBean is a common base interface both for Session Beans and Entity Beans. It implements the Serializable interface for the Statefull Session Bean. It might be true that this is not used for stateless session beans and entity beans but you have to look at this from a higher level. The interface is common for all the beans, and you use what you need from it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic