What is Passivation and Activation in EJB?Activation is a process of associating an instance with EJB object. Activating a bean is the process 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 creates 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.
Passivation is the process of disassociating a bean instance from its EJB object so that the instance can be reused or evicted to conserve memory. Calling of ejbPassivate () for passivation is a warning to the bean that its held conversational state is about to be swapped out. It is important that the container inform the bean using ejbPassivate () so that the bean can relinquish held resources.
|