When to use Stateful session beans?

Answered

When to use Stateful session beans?

Ninja Asked on 18th September 2018 in EJB 3.x.
Add Comment
1 Answer(s)
Best answer

Stateful session beans are appropriate if any of the following conditions are true:

  1. The bean’s state represents the interaction between the bean and a specific client.
  2. The bean needs to hold information about the client across method invocations.
  3. The bean mediates between the client and the other components of the application, presenting a simplified view to the client.
  4. 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.

Ninja Answered on 18th September 2018.
Add Comment