• Post Reply Bookmark Topic Watch Topic
  • New Topic

activation/passivation Stateful beans  RSS feed

 
Claudio Gualberto
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know what the EJB container does when it wants to passivate a Stateful Session Bean instance behind the scenes.
Does it serializes the bean to a long term storage ( as the HD ) and deserializes it when it needs the bean�s instance ?
If it�s true, what is the programer�s role in this serialization ?
Thanks in advance.
Claudio Gualberto.
SCJP 1.4
 
Nagendra Prasad
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The container would serialize the information to secondary storage( could be hard disk) and deserialize on the ejbActivate() is invoked on that bean.
The whole operation is managed by the application and therefore the vendor. These actions cannot be controlled by the programmer.
 
Claudio Gualberto
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that i dont need to write code to manage this feature.
Imagine a EJB Stateful like this :
public class MyBean implements EntityBean{
private Collection mySessionData = null;
// this field will be serialized by container..
public void ejbPassivation(){
// i need to do nothing...
}
public void ejbActivation(){
// nothing again...
}
}
that�s it ?
Claudio Gualberto
SCJP 1.4
 
Nagendra Prasad
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm.. a bit more detail.. from what I understand of the situation:
ejbPassivate() would be automatically invoked by the container, BUT:
- We need to clear up any resources such as sockets and JDBC resources. Stateful session beans will not maintain resources for the life of the bean. If these resources are left open, there could be repurcussions when the bean is activated.
HOWEVER, in ejb 1.0, the jndi contexts also had to be closed. This is not required in EJB 1.1

Also as an aside, if u are removing the session bean, then it is recommended to release the resources that are normally done by the ejbPassivate() method. In this case, you could call ejbPAssivate() from the ejbRemove() method.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!