When to use Singleton session beans?
Answered
When to use Singleton session beans?
Best answer
Singleton session beans are appropriate in the following circumstances:
- State needs to be shared across the application.
- A single enterprise bean needs to be accessed by multiple threads concurrently.
- 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.