Activation is a process of transferring an enterprise bean from secondary storage to memory.

Stateful session beans maintain sessions between method invocations, this is called conversational state because it represents the continuing conversation with the stateful session beanís client . The integrity of this conversational state needs to be maintained for the life of the beanís service to the client. But stateful session bean does not participate in instance pooling like stateless session beans and entity beans, instead activation is used with stateful session beans to conserve resources. When an EJB server needs to conserve resources, it can evict stateful session beans from memory. This reduces the number of instances maintained by the system. To passivate the bean and preserve its conversational state, the beans state is serialized to a secondary storage and maintained relative to its EJB object. When a client invokes a method on the EJB object, a new stateful instance is instantiated and populated from the passivated secondary storage.

Activating a bean is the act of restoring a stateful bean instanceís state relative to its EJB object. When a method on the passivated EJB object is invoked , the container automatically instantiates a new instance and sets it fields equal to the data stored during passivation.

The activation process is supported by the state management call methods ejbActivate () and ejbPassivate () methods which notify the stateful session bean that it is about to be activated or passivated respectively. The ejbActivate () method is called immediately following the successful activation of a bean instance and can be used to reset transient fields to an initial value if necessary.

Entity beans do not have conversational state that needs to be serialized like stateful beans; instead the state of entity bean instance is persisted directly to the data base. Entity beans do, however, leverage the activation callback methods ejbActivate () and ejbPassivate () to notify the instance when it si about to be swapped in or out of the instance pool. The ejbActivate () method is invoked immediately after the bean instance is swapped into the EJB object and the ejbPassivate () method is invoked just before the instance is swapped out of the instance pool.

abstract class
abstract factory
abstract method
access control
application server
Use of this website constitutes acceptance of the AllAppLabs.com Terms and Conditions