com.dp4j
Annotation Type Singleton
@Documented
@Target(value=TYPE)
public @interface Singleton
Intent:
- Ensure that only one instance of a class is created.
- Provide a global point of access to the object.
Motivation
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:
- Singleton
lazy
public abstract boolean lazy
- Default:
- false
getInstance
public abstract String getInstance
- Default:
- "getInstance"
instance
public abstract String instance
- Default:
- "instance"
Copyright © 2011. All Rights Reserved.