Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why EJBs are serialized  RSS feed

 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • 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.
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!