Singleton session beans

As the name suggests, there is only one instance of a singleton bean class in the EJB container (this is true in the clustered environment too; each EJB container will have one instance of a singleton bean). This means that they are shared by multiple clients, and they are not pooled by EJB containers (because there can be only one instance). Since a singleton session bean is a shared resource, we need to manage concurrency in it. Java EE provides two concurrency management options for singleton session beans, namely container-managed concurrency and bean-managed concurrency. Container-managed concurrency can be easily specified by annotations.


See https://javaee.github.io/tutorial/ejb-basicexamples003.html#GIPSZ for more information on managing concurrency in singleton session beans.

The use of a singleton bean could have an impact on the scalability of the application if there are resource contentions.

We use the @Singleton annotation on the class to mark it as a singleton session bean.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.134.151