Session Bean

One form of EnterpriseJavaBeans. An object that encapsulates business logic or work flow, as opposed to a persistent entity (for which one uses EntityBeans). For example, a CustomerAccount might be an entity bean representing account data, and one might use an AccountServices session bean to perform tasks on accounts. Session beans come in 2 flavors: Stateless and Stateful. Stateless session beans do NOT save conversational state between the separate invocations that make up the session. Stateful session beans DO save conversational state.

The distinction between stateless and stateful is not your Java code per se. There is no StatelessSession interface to implement. The bean acquires its state policy when it is deployed to a container. You can write a session bean that preserves conversational state in instance variables, then deploy that bean as a stateless bean. In that case, the container has no obligation to give you the same bean (state) on successive invocations, making state unreliable from the client point of view. This is a hole that EJB developers might well fall into, and testing the system with a single client won't always (or likely) find the problem.


EditText of this page (last edited September 21, 2004) or FindPage with title or text search