Topics in This Chapter
Introducing Stateful Session Beans
Implications of Stateful vs. Stateless EJBs
Leveraging your EJB Components
Extending Multiple Interfaces
Value List Iterator Pattern
Example with a JSP Client
Local Interfaces
In the previous two chapters, we explored the design of stateless session beans. The most important characteristic of a stateless session bean is that it does not retain client-specific data. Thus, multiple clients can share stateless session beans, providing performance benefits. Stateless session beans also provide important business processes, but the results are transient, even during a session. Although a method of a stateless session bean could keep track of client-specific data, the bean does not retain the data when the method returns. Hence, the EJB container is free to assign the same instance of a stateless session bean to another client. All instances of a stateless session bean are therefore identical.
In contrast, stateful session beans do keep track of client-specific data. Multiple clients cannot share stateful session beans because the EJB container assigns a specific instance to each client. Stateful session beans have the advantage of being tightly coupled with clients, but there is more overhead involved. It's important, therefore, to understand how to properly design applications with stateful session beans so that performance does not suffer.
In this chapter, we'll look closely at stateful session beans and show you their benefits and costs over stateless session beans. We'll also discuss how the EJB container manages stateful session beans in a J2EE environment.
3.147.53.166