This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Question regarding State of 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 "Question regarding State of session bean" Watch "Question regarding State of session bean" New topic
Author

Question regarding State of session bean

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
In Sun J2ee tutorial I read
"The state is retained for the duration of the client-bean session."
My doubt is how exactly state is retained in session bean?
Veena


SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
This same question was asked, and answered, not even ten posts down from your post: How does stateful session bean store its state?
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
Hi Chris,
Still it is not clear to me.Does it mean statefull session bean is serialized to retain its state till client finishes executing?Can you explain whole mechanism of serializing statefull session bean right from client invoking the bean?
Thanks
Veena
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
For the complete lifecycle of a Stateful Session Bean I suggest you refer to the EJB Specification. You can find it here: EJB Specification.
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
I tried downloading specification in PDF format.But it is not readable.
Thanks
Veena
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Do you have Adobe Acrobat Reader?
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
Yeah I do have Adobe Acrobat Reader.
Piyush Daiya
Ranch Hand

Joined: Jun 13, 2002
Posts: 67
Hi,
Well here is brief description:-
When the EJB object receives a new client request, a new stateful instance is instantiated and associate with the EJB object to handle the request.
Stateful beans maintain a conversational state, which must be preserved before the bean instance is evicted from memory. To accomplish this, the container will write the conversational state of the bean instance to a secondary storage (usually disk). Only the non-transient serializable instance fields are preserved. When the bean is activated the new instance is populated with the preserved state. References to live resources like the EJBContext, DataSource, JNDI ENC, and other beans must also be maintained somehow -- usually in memory -- by the container.
The javax.ejb.SessionBean interface provides two callback methods that notify the bean instance it is about to passivated or was just activated. The ejbPassivate( ) method notifies the bean instance that it is about have its conversational state written to disk and be evicted from memory. Within this method the bean developer can perform operations just prior to passivation like closing open resources. The ejbActivate( ) method is executed just after a new bean instance has been instantiated and populated with conversational state from disk. The bean developer can use the ejbActivate( ) method to perform operations just prior to servicing client request, like opening resources.

Refer to Richard Monson-Haefel book, it is good reference.
HTH,
Piyush


"A scientist is not person who gives right answers but a person who asks right questions"
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Veena Point:
I tried downloading specification in PDF format.But it is not readable.
Thanks
Veena

I (and many others) have downloaded that spec numerous times and I can assure you that I never had a problem opening it. I would have to assume the problem is on your end. Maybe the download got corrupted. Maybe you accidentally downloaded the postscript version. Maybe your Acrobat Reader is extremely old...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question regarding State of session bean
 
Similar Threads
difference between entity bean and session bean
HF mock exam question..
Stateful v/s stateless session bean
Bean Managed Vs Container managed
When the client makes its second call to the stateful session bean, how does that bean know it is co