next The Template Method
up Design Patterns
previous Design Patterns
  Contents
PDF version   PostScript version

The Singleton

The meta-data relevant to each deployed service is held in Port objects. These objects must be shared between the 20 concurrent workers (i.e. threaded request processors). This role has been assigned to a PortRegistry object.

Figure 4.1: The Singleton pattern
 
For the desired effect to occur, a single instance of PortRegistry must be shared: this is the role of the Singleton pattern.
To prevent the creation of more than one instance, all constructors are private, and the class is final, so it may not be subclassed. The class method (i.e. static method in Java) getDefaultRegistry() returns a reference to the private class member reg of type PortRegistry--instantiating reg the first time it is invoked.


next The Template Method
up Design Patterns
previous Design Patterns
  Contents

Copyright © 2001 Jean-Marc Rosengard