When to use Stateful session beans?
Answered
When to use Stateful session beans?
Best answer
Stateful session beans are appropriate if any of the following conditions are true:
- The bean’s state represents the interaction between the bean and a specific client.
- The bean needs to hold information about the client across method invocations.
- The bean mediates between the client and the other components of the application, presenting a simplified view to the client.
- Behind the scenes, the bean manages the work flow of several enterprise beans.
For example, a shopping cart in an online shopping application can be represented as a stateful session bean. A user can add several items to shopping cart one by one and then call checkout. The shopping cart instance represents the conversational state of the person shopping who is the client; it can be discarded when the client completes the purchase of the shopping cart contents and it is emptied. Its state is the current contents.