Java Reference
In-Depth Information
Figure 3.3. Multiplayer games like RuneScape maintain state in the same way EJB singletons do.
Similarly, there's only ever one instance of an EJB singleton session bean that's shared
across all clients. Conceptually, it's the descendant of the Gang of Four's singleton pattern.
But instead of using a private constructor and a factory method for creating the singleton,
the container instantiates the singleton and ensures that only one instance is created. The
container also helps to properly manage concurrent access to the bean by multiple clients.
All clients share the internal state of the singleton, and the singleton is expected to hold
and pass on a state change that one client makes across all other clients via its current state.
Singletons are intended to model services that utilize state stored in a shared cache. In Ac-
tionBazaar, a singleton could be used for a service to get all current system alerts, such as
fraud alerts. Singletons are relatively uncommon in Enterprise applications but are a very
important use-case when they're needed.
Now that you have a rough sense of component state and session bean types, it's time to
cover each of the bean types in more detail. Because stateless session beans are the most
commonly used session bean, we'll start with them.
Search WWH ::

Custom Search