Part II. Server-Side Component Models

We’ve now seen how EJB’s component types allow us to write less, allowing the container to equip us with services and other runtime support. In this section we’ll more fully address the available server-side models: session beans and message-driven beans.

EJB’s basic building block for implementing business logic—taskflow—is the session bean. Taskflow refers to all the steps required to service a request such as making a doctor’s appointment or renting a video. Session beans frequently manage the interactions within persistent data—entity beans—describing how they work together to accomplish a specific goal.

Session beans are divided into three basic types: stateless, stateful, and singleton.

A stateless session bean (Chapter 5) is a collection of related services, each represented by a business method; the bean maintains no conversational state from one method invocation to the next. When you make a request upon a stateless session bean, the container executes the target method and returns the result without knowing or caring what other requests have gone before or might follow. Think of a stateless session bean as a set of procedures or batch programs that execute based on some parameters and return a result.

A stateful session bean (Chapter 6) is an extension of the client application. It performs tasks on behalf of the client and maintains state related to that client. This is called conversational state because it represents a continuing set ...

Get Enterprise JavaBeans 3.1, 6th Edition 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.