Package mondrian.util
Class ObjectFactory.Singleton<T>
- java.lang.Object
-
- mondrian.util.ObjectFactory<T>
-
- mondrian.util.ObjectFactory.Singleton<T>
-
- Direct Known Subclasses:
MemoryMonitorFactory
,RolapMemberBase.PropertyValueMapFactoryFactory
- Enclosing class:
- ObjectFactory<V>
public abstract static class ObjectFactory.Singleton<T> extends ObjectFactory<T>
Implementation of ObjectFactory that returns only a single instance of the Object.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class mondrian.util.ObjectFactory
ObjectFactory.Context, ObjectFactory.Singleton<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected T
singleInstance
The single instance of the object created by the factory.protected T
testSingleInstance
The test single instance of the object created by the factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected T
getObject(Properties props, Class[] parameterTypes, Object[] parameterValues)
Returns the singleton Object.protected T
getTestObject(String className, Class[] parameterTypes, Object[] parameterValues)
Create an instance for test purposes.-
Methods inherited from class mondrian.util.ObjectFactory
getClassName, getClassName, getDefault, getObject, getObject, getObject, getObject, getStringProperty, removeContext, restoreContext
-
-
-
-
Field Detail
-
singleInstance
protected T singleInstance
The single instance of the object created by the factory.
-
testSingleInstance
protected T testSingleInstance
The test single instance of the object created by the factory. Creating thistestSingleInstance
does not change the current value of thesingleInstance
variable.
-
-
Method Detail
-
getObject
protected T getObject(Properties props, Class[] parameterTypes, Object[] parameterValues) throws CreationException
Returns the singleton Object. The first time this is called, an object is created where theparameterTypes
andparameterValues
are constructor parameters and Properties parameter is used to look up a class name.This returns a same instance of the Object each time its called except if the
getClassName
method returns a non-null class name which should only happen as needed for unit testing.- Overrides:
getObject
in classObjectFactory<T>
- Parameters:
props
- the property definitions to use to determine theparameterTypes
- the class parameters that define the signature of the constructor to useparameterValues
- the values to use to construct the current instance of the object- Returns:
- the newly created object
- Throws:
CreationException
- if unable to create the object
-
getTestObject
protected T getTestObject(String className, Class[] parameterTypes, Object[] parameterValues) throws CreationException
Create an instance for test purposes.- Parameters:
className
- the class name used to create Object instanceparameterTypes
- the class parameters that define the signature of the constructor to useparameterValues
- the values to use to construct the current instance of the object- Returns:
- the newly created object
- Throws:
CreationException
- if unable to create the object
-
-