Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

statefulsessionbean

 
eswar kumar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how a stateful session bean maintain state (every time the request is coming from that particular client)? if the client wants to browse after 30 mints of idle time how the bean instance knows that request is coming from that parcticular client?
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,
How the Container actually associates the stateful session bean with a particular client is up to the vendor.
You can imagine that the stub object contains enough information to identify the client uniquely to the Container, and that this information is enough for the Container to pull a bean out of passivation and restore its state when the client comes back and makes another method call.
But the exact implementation mechanism the Container uses to uniquely identify a client, and to restore state after passivation (or even HOW and IF the Container passivates stateful session beans) is not part of the spec, and is entirely the choice of the vendor.
cheers,
Kathy
 
vinod
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually what happens when client is idle are not invoking any method or using stateful bean, container detects its idleness and prepare to passivate to free resources used by it. during passivation container calls ejbPassivate method on bean and save all non transient state of bean class in secondary memory. Along with data it also stores references of ejbObject, ejbContext, Home Object which are not released by client during passivation. So when passivated clent call some method on ejbObject associated with it, it retrives references and previous conversational state and activate bean.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic