Developing a stateful session bean

In this section, we develop the stateful Reports session bean. This example may not be very real as a stateful session bean, but it illustrates some of the concepts.

Design issues

For a stateful session bean, you have to decide what data should be persistent, that is, the data items that are carried from one interaction to the next. These data items have to be serializable so that they can be saved in case the session bean is passivated between invocations of methods. For passivation and activation, see “Activation and passivation” on page 186.

Note that home and EJB references are not serializable, so we cannot keep home references over passivation/activation.

Persistent state

We will keep these data items ...

Get EJB 2.0 Development with WebSphere Studio Application Developer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.