net.sf.jasperreports.engine.util
Class JRSingletonCache<T>

java.lang.Object
  extended by net.sf.jasperreports.engine.util.JRSingletonCache<T>

public class JRSingletonCache<T>
extends java.lang.Object

Utility to use as a soft cache of singleton instances.

Version:
$Id: JRSingletonCache.java 5180 2012-03-29 13:23:12Z teodord $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Constructor Summary
JRSingletonCache(java.lang.Class<T> itf)
          Creates a cache of singleton instances.
 
Method Summary
protected  T createInstance(java.lang.String className)
           
 T getCachedInstance(java.lang.String className)
          Returns the singleton instance corresponding to a class.
protected  java.util.Map<java.lang.String,T> getContextInstanceCache()
           
protected  java.lang.Object getContextKey()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRSingletonCache

public JRSingletonCache(java.lang.Class<T> itf)
Creates a cache of singleton instances.

Parameters:
itf - a interface or class that should be implemented by all classes cached by this object
Method Detail

getCachedInstance

public T getCachedInstance(java.lang.String className)
                    throws JRException
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

protected T createInstance(java.lang.String className)
                    throws JRException
Throws:
JRException

getContextInstanceCache

protected java.util.Map<java.lang.String,T> getContextInstanceCache()

getContextKey

protected java.lang.Object getContextKey()


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com