IT Community - Software Programming, Web Development and Technical Support

Can anybody explain in brief Life cycle for Stateless and Stateful beans?

This is a discussion on Can anybody explain in brief Life cycle for Stateless and Stateful beans? within the Java Programming forums, part of the Software Development category; Can anybody explain in brief Life cycle for Stateless and Stateful beans?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-26-2007, 04:29 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Question Can anybody explain in brief Life cycle for Stateless and Stateful beans?

Can anybody explain in brief Life cycle for Stateless and Stateful beans?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-26-2007, 04:49 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: Can anybody explain in brief Life cycle for Stateless and Stateful beans?

Life cycle for stateless session beans
When the application server is not started or just starting there are no instances ofbeans.
EJB Container looks in to the pooling policy and instantiates new beans accordingly.For instance if the pooling policy says to create a pool of 10 object it will createaccordingly.
Container instantiates the bean using “Class.newInstance(“MyBean.class”).
After the object is created EJB container calls the “setSessionContext()” to set thecontext object so that bean can make a call back to the container if it ever needs to.
Container then calls “ejbCreate()” method and this initializes you bean. Just a note to make when a client makes a new object or destroys an EJB object. It’s not necessary that EJB container will do it instantly. It will decide that whether it should really destroy this object or move it pool or should not create an object and take one from the pool.
Finally container makes calls to the business methods of the bean. All the business methods are called depending on the client makes calls. All the method calls are treated in the same way as session beans are in the same state after the method call. When a request comes in from client1 the container can take bean1 from the pool process the request and bring bean1 to a previous state. Later when again client1calls container can take bean2 process the request and bring bean2 to the previous state. So the object treats every request as a new request and does not care to save the previous data of the request.
Finally when the container is about the remove the object it calls the “ejbRemove()”of the bean.

Life cycle of stateful session beans
Life cycle of the stateful session beans is same as stateless only leaving the below points:-

First as its stateful there is no pool of objects.
Second with every client call there are “ejbPassivate” and “ejbActivate” methods to save and retain the conversational state.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The system developmetn life cycle playasol73 Quality Engineering and Methodologies 2 11-06-2007 07:05 AM
Explain software development life cycle? itbarota Software Testing 8 08-09-2007 11:58 PM
What is the 'software life cycle'? devarajan.v Software Testing 1 07-30-2007 06:57 AM
Defect Life Cycle vadivelanvaidyanathan Software Testing 0 03-24-2007 12:51 AM
Concepts on the Software Life Cycle vadivelanvaidyanathan Software Testing 2 03-23-2007 03:16 AM


All times are GMT -7. The time now is 10:57 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0