• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Bean

 
Prashanth reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I would greately appreciate if somebody can clarify my following doubts regarding session beans.
1) When stateful session bean is passivated the serialized object of the bean will be stored in a secondary stoarage. How the container will do this. Is bean developer responsible in any way for this storage process?
2) Stateful session beans keep the conversation state between the method calls. How the bean will keep this state. where does it store this informaton. Again Is bean developer responsible in any way for this storage process.
Thanks,
Prashanth.
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think it is the duty of the bean developer to do the storage on either of the aforementioned, rather the container does this internally without having to involve the bean developer; how the container does it might be container specific also - meaning different container vendors do it the way they feel fit.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,
Yep, Anselm is correct--it is entirely up to the Container, and a Bean Developer does not need to worry about this
I just wanted to point out that stateful session bean passivation is NOT always using serialization, even though you can *virtually* always think of it as though it IS being serialized. The important point to remember is that YOU DO NOT KNOW how the Container is actually saving and restoring the state, except you DO need to know that by the end of your ejbPassivate() method, you need to be certain that your variables are in a state in which they can be passivated, and that you take care of restoring anything in your ejbActivate() method.
In other words, you can think to yourself:
"I do not know how and when ejbPassivate() and ejbActivate() will be called, and where the data is going or coming from, BUT when either of those methods is called on my bean, I have to know what to do inside the methods to make sure the Container can do its job."
cheers,
Kathy
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And about (2) above, yes, the bean developer is responsible for storing client state in instance variables of the stateful session bean object (or a data base I guesss...).
For example, if a client gives you her name via, e.g., createClient(String name) and you, as bean developer, don't save that name in an instance variable, then you loose that part of the client state.
Needles to say, you can apply the same to address, phone number, items in the cart etc... They have to be kept in instance variables at least.
At passivation the container will save them for you with the bean, if all rules have been met for passivating your instance variables.
Please correct me if I'm wrong.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic