• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is difference between stateless and stateful session bean?

 
liang sun
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel difference is if method ejbCreate'parameter can be saved。
is it right?
besides it, has other difference?
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you mention is just a consequence of the difference betwee Stateful and Stateless.
Http protocol is Non-conversational.
A stateless EJB is based on the non-conversational characteristic of the protocol.
Each time a method of the EJB is called, there is no mean to know what was the method the client previously called, and who he was.
It means after each invocation, the stateless EJB clears himself out from past invocations'information
At the opposite, a stateful EJB is bound to the client who instanciated it. When a method is called, the EJB knows what has been asked before.
It holds conversations with clients
As a consequence of this, using a stateless EJB, it does not make sense to call the create method with a parameter beacause immediately after the call, the parameter will be cleared
But if you are using a stateful EJB, you can pass arguments to the create method.

There are a lot of other differences.
Stateless can be pooled (multiple clients for a same instance), but not passivated
There is one Stateful per client, and activation/passivation processes are called during its lyfecycle...

HTH, but further (and better) info available at :
Session Beans on Sun WebSite
 
liang sun
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks BillBailey very much。In fact, what u wrote is understood by me early,but I still don't understand
some question at work。If I found farther question, I will go on posting。

Diamond Sun
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!