Java Reference
In-Depth Information
1.6.3. Enhancements to stateful session beans
In EJB 3.2, session beans haven't changed dramatically, at least not as dramatically as
MDBs. A few enhancements have been made to stateful session beans concerning passiva-
tion and transaction support. Here's a quick look at these enhancements.
Disable passivation
Prior to EJB 3.2, stateful beans needed all objects in them to implement Serializable
so that the EJB container could passivate a bean without error. If one object in your stateful
bean wasn't serializable, passivation would fail and the EJB container would destroy the
bean, losing the state. Although it's highly advisable to make sure your stateful beans
are serializable so the EJB container can provide you with services like passivation and
clustered failover, sometimes it's not possible. To prevent the container from attempting to
passivate a stateful bean you don't want to passivate, use the passivationCapable
element:
Transaction support to lifecycle callbacks
Prior to EJB 3.2, stateful session beans had lifecycle callback methods, but it was undefined
how transactions were supported during these method calls. So the new API adds transac-
tional support to the lifecycle callback methods by introducing the ability to annotate the
lifecycle callback methods with @TransactionalAttribute(REQUIRES_NEW) .
REQUIRES_NEW is the only valid value for stateful lifecycle callback methods:
Search WWH ::




Custom Search