Hi All, Can anybody please tell me how stateful session bean is maintaining the state? and Why does Stateless Session bean not store its state even though it has ejbActivate and ejbPassivate ? Thanks in advance. I am waiting for reply.
Stateless beans do not store conversational state. SLSB(Stateless Session beans) are pooled and are shared among clients. So when a request comes for a SLSB the container picks up one from the pool and the picked bean will process the request. Once processing is done the bean goes back to the pool. Later if the same client invokes a method on the same SLSB the container could pick up any available bean from the pool to handle the request. Note that this bean instance could be different from the first one. Since they are pooled ans shared they do not store any conversational state and they do not remember their client.
Stateful session beans are extensions of the client and store client specific state. They are created when a client makes a 'Create' request.
The ejbActivate and ejbPasivate method in SLSB are not used. EJB 3.0 spec (not final as yet) does not require a SLSB to implement the life cycle method.