File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Regarding Stateful Session Bean!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Regarding Stateful Session Bean!!" Watch "Regarding Stateful Session Bean!!" New topic
Author

Regarding Stateful Session Bean!!

Ravi Kumar Ravuru
Ranch Hand

Joined: Apr 18, 2002
Posts: 176
Hello Folks,
Stateful Session Bean will maintain conversational state between the method invocations.If so,I would like to know whether the conversation state will be maintained by bean itself or through container.Please throw some light abt this.
Regards,
Ravi
Gurumurthy Ramamurthy
Ranch Hand

Joined: Feb 13, 2003
Posts: 272
The container, of course. The details about the session bean (stateless or stateful) are provided by you in the deployment descriptor, which is mainly for the container's information.
Cheers,
Guru
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

The conversational state will be stored in bean.


Groovy
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
A little bit of both... the bean instance will store the conversational state but the Container will manage the bean instance. Therefore, if the Container needs to do some memory gymnastics then it will swap the bean instances (including session state) to and from persistance storage. The actual details on the storage (be it the file system, a database, etc.) are vendor specific.
Naveen Sharma
Ranch Hand

Joined: Mar 23, 2001
Posts: 65
hi all,
i think state will be maintained with Bean , managed by the container, using EJBContext...
think about in this way, suppose between the lulls, your bean get passivated...and container will save the state to some other media along with the context of bean...now the bean (instance) is free from resources and may be ready to server other clients...
now again the previous client comes.. this time the bean will be activated and restored its previous state..
so all("Bean(instance)+ BeanContext + Container") are responsible to maintain the converstaional state..
Hope this may help
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

i think state will be maintained with Bean , managed by the container, using EJBContext...

What has the EJBContext got to do with this?

...now the bean (instance) is free from resources and may be ready to server other clients...

I am not sure about this one though.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Naveen Sharma:
now the bean (instance) is free from resources and may be ready to server other clients... now again the previous client comes.. this time the bean will be activated and restored its previous state..

While it is technically possible, no EJB Container that I know of actually pools instances for Stateful Session Beans.
Naveen Sharma
Ranch Hand

Joined: Mar 23, 2001
Posts: 65
hi,
what i think is
to limit the number of stateful beans instances in memory, the container can swap out stateful bean , saving its conversational state to a hard disk or other storage ("Passivation").. After passivation a stateful bean, the conversation state is safely stored away, along with the resources being used... when the original clients invokes a method, the passivated conversational state is swapped in to a bean("Activation").. this bean now resumes the conversation with the original client...
It shud be noted that the bean receives the activated state may not be the original bean instance..
Thus EJB does indeed support the effect of pooling stateful beans. only a few instance can be in memory, when there are many clients
As the session context(EJB Context) remains associated with the instance for the lifetime of the instance.. and if the instances are swapping to serve clients while(Passivation/Activation)... their context do come into the picture
correct me if i am wrong
Naveen
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Thus EJB does indeed support the effect of pooling stateful beans. only a few instance can be in memory, when there are many clients

I DONT KNOW ANY CONTAINER WHICH DOES THAT.
When pooling does is not done:
The bean instance are destroyed after its state is passivated.
 
 
subject: Regarding Stateful Session Bean!!
 
Similar Threads
Looking at code how to differentiate between Stateless and Stateful
Amusing...
isIdentical
http session object,ejb session bean
how to handle session in EJB