Annotation Type Singleton
public @interface Singleton
- Ensure that only one instance of a class is created.
- Provide a global point of access to the object.
A Singleton Object maybe used to represent a resource that:
- is unique e.g. the file system, or a print spooler. Since the OS provides only one print spooler it'd be inconvenient to create multiple instances of our interface to it, since then all those instances must coordinate the fact that they represent the same resource (e.g. merge print job queues).
- accessed with the same configuration throughout the system. This may refer to a password-protected shared service. Indeed, Facade and State Objects are often Singletons, [GoF p193,313] and Abstract Factory, Builder, and Prototype can use Singleton in their implementation. [GoF, p134]
- is expensive to instantiate (e.g. remote resources).
- See Also:
public abstract boolean lazy
public abstract String getInstance
public abstract String instance
Copyright © 2011. All Rights Reserved.