Package net.sf.jasperreports.engine.util
Class JRSingletonCache<T>
java.lang.Object
net.sf.jasperreports.engine.util.JRSingletonCache<T>
Utility to use as a soft cache of singleton instances.
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected T
createInstance
(String className) getCachedInstance
(String className) Returns the singleton instance corresponding to a class.protected Object
-
Field Details
-
EXCEPTION_MESSAGE_KEY_CLASS_NOT_COMPATIBLE
- See Also:
-
EXCEPTION_MESSAGE_KEY_CLASS_NOT_FOUND
- See Also:
-
EXCEPTION_MESSAGE_KEY_INSTANCE_ERROR
- See Also:
-
-
Constructor Details
-
JRSingletonCache
Creates a cache of singleton instances.- Parameters:
itf
- a interface or class that should be implemented by all classes cached by this object
-
-
Method Details
-
getCachedInstance
Returns the singleton instance corresponding to a class.The instance is first searched into the cache and created if not found.
The class is expected to have a no-argument constructor.
- Parameters:
className
-- Returns:
- the singleton instance corresponding to a class
- Throws:
JRException
-
createInstance
- Throws:
JRException
-
getContextInstanceCache
-
getContextKey
-