T
- The type of the object.public class Singleton<T>
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Singleton(Factory<T> objFactory)
Create a singleton of specified class T, and do not update the instance
by default.
|
Singleton(Factory<T> objFactory,
boolean toUpdateInstance)
Create a singleton manager of specified class T.
|
Modifier and Type | Method and Description |
---|---|
T |
getInst()
Get an instance of class T.
|
public Singleton(Factory<T> objFactory) throws java.lang.Exception
objFactory
- Factory to create new instance of class T when instance of it
does not exist.java.lang.Exception
- On failure creating a new instance.public Singleton(Factory<T> objFactory, boolean toUpdateInstance) throws java.lang.Exception
objFactory
- Factory to create new instance of class T when instance of it
does not exist.toUpdateInstance
- Whether to update the instance in the pool on create of this
singleton object.
java.lang.Exception
- On failure creating a new instance.public T getInst() throws java.lang.Exception
java.lang.Exception
- On failure creating a new instance.