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

statefull session bean  RSS feed

 
Muko Rafter
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody tell me diffence between statefull session bean an d stateless session bean.
 
timothy zimmerman
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe a stateless session bean is a special case of a session ejb that does not keep any information related to its client whereas stateful session beans would contain information particular to the client that created it and maintains this information until removed.
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stateful session bean is bound to the client that has instanciated it.
The stateless is back to the pool each time a client does not use it anymore (end of each method call). Thus the Stateless is shared between clients but the Stateful is specific to each client.
Most of the time (IMHO), stateful is used to simulate a conversational state in HTTP (which is a stateless protocol)
HTH.

[This message has been edited by Bill Bailey (edited November 28, 2001).]
 
ravi shankar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
my doubt is not cleared, I want to know how the state will be maintained by the container? either it by any serialization? or any session object?

thanks and regards
Ravi
 
Tim Holloway
Bartender
Posts: 18661
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The session bean has passivation and activation methods. These are called by the container if there is a need to free up resources. Once passivated, the bean should be capable of being serialized by the container, and once deserialized, the activation method should restore the bean to a condition indistinquisable from its pre-passivation state.
Without actually checking the spec, I don't think that the passivation/activation mechanism is required to use Java serialization. I think that's left up to the container implementer.
Despite the name, "session" EJBs have no relation whatsoever with http server sessions outside of the fact that an http session can contain EJBs in the same way it can contain other Java objects.
 
Phil Sharp
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heres my attempt at an explanation
Stateful session bean - holds state during the lifetime of the session bean.
Stateless session beans - only have state during a method call and therefore the application server can make various performance improvements when it uses them.
An important thing to note is that the state is not persistent unless you code for it. The state is only available for the lifetime of the bean. Yes it maybe temporarily stored to disk due to passivation but that is for the app server to decide. If you need the data to be persisted you should be using an entity bean (or prehaps not). There is a long discussion on this at:
http://www.theserverside.com/home/thread.jsp?thread_id=9375
Hope that helps
Phil
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!