When to use Singleton session beans?


When to use Singleton session beans?

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

Singleton session beans are appropriate in the following circumstances:

  1. State needs to be shared across the application.
  2. A single enterprise bean needs to be accessed by multiple threads concurrently.
  3. The application needs an enterprise bean to perform tasks upon application startup and shutdown.

An application hit counter is a good example of Singleton session bean. Loading a global daily price list that will be the same for every user might be done with a singleton session bean, since this will prevent the application having to do the same query to a database over and over again.

Ninja Answered on 18th September 2018.
Add Comment