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?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |