concept stateful bean in category ejb

appears as: stateful bes, stateful bean, A stateful be, stateful be
EJB 3 in Action, Second Edition

This is an excerpt from Manning's book EJB 3 in Action, Second Edition.

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:

Recall that session beans come in three flavors: stateful, stateless, and singleton. You’ll use stateless beans and stateful beans in the examples, but not singleton beans. You’ll also save message-driven beans for later. You’ll take on stateless session beans first, primarily because they’re simpler.

Figure 2.3 depicts these ordering steps. With a stateful bean, the data the user enters at each workflow step can be cached into bean variables until the ordering workflow completes, including any hidden workflow state that the bean client doesn’t need to be aware of.

Figure 3.9. The lifecycle of a stateful session bean. A stateful bean maintains the client state and cannot be pooled. It may be passivated when the client isn’t using it and must be activated when the client needs it again.