Java Reference
In-Depth Information
3.4. Singleton session beans
Singleton session beans were added in EJB 3.1. As their name suggests, only one instance
is created during the lifecycle of an enterprise application. Thus, all clients access the same
bean, as shown in figure 3.10 . Singleton beans solved two architectural problems that had
long plagued Java EE applications: how to initialize at server startup and also have only a
single instance of a bean. Solutions prior to EJB 3.1 involved the use of “startup servlets”
or JCA connectors. Countless applications undoubtedly violated the Java EE specification
and used static variables or nonmanaged objects. At best these were inelegant solutions,
but many solutions were undoubtedly unsound.
Figure 3.10. A single bean instance is created that all clients then use.
Singleton session beans are very similar to stateless session beans. Singleton beans support
the same callbacks as stateless session beans but come with some unique features, in-
cluding the ability to control concurrent access to the bean as well as the ability to chain
singleton bean instantiation. Chaining instantiation means that one bean can depend on an-
Search WWH ::

Custom Search