org.jasig.portal.utils.threading
Class MapCachingDoubleCheckedCreator<K,T>
java.lang.Object
org.jasig.portal.utils.threading.DoubleCheckedCreator<T>
org.jasig.portal.utils.threading.MapCachingDoubleCheckedCreator<K,T>
public abstract class MapCachingDoubleCheckedCreator<K,T>
- extends DoubleCheckedCreator<T>
Implementation of DoubleCheckedCreator that stores what it creates in a backing Map. Subclasses need to implement
getKey(Object...) to provide a Map key to use for the arguments and create(Object...) to create
new instances of the objects.
The default constructor uses a ReferenceMap with hard references to the keys
- Version:
- $Revision$
- Author:
- Eric Dalquist
MapCachingDoubleCheckedCreator
public MapCachingDoubleCheckedCreator()
MapCachingDoubleCheckedCreator
public MapCachingDoubleCheckedCreator(Map<K,T> cache)
- Parameters:
cache - The Map to store created instances in
MapCachingDoubleCheckedCreator
public MapCachingDoubleCheckedCreator(Map<K,T> cache,
ReadWriteLock readWriteLock)
- Parameters:
cache - The Map to store created instances inreadWriteLock - the ReadWriteLock to use for the double checked locking
getCacheMap
public final Map<K,T> getCacheMap()
- Returns:
- A read-only view of the underlying Map used to cache created objects
clear
public final void clear()
- Allows the object cache map to be cleared of entries
getKey
protected abstract K getKey(Object... args)
- Parameters:
args - Optional arguments passed to DoubleCheckedCreator.get(Object...) used to create a key
- Returns:
- The key for the specified arguments
createInternal
protected abstract T createInternal(K key,
Object... args)
- Parameters:
key - The key to create the object forargs - The object retrieval arguments
- Returns:
- A new object instance for the key and args
create
protected final T create(Object... args)
- Specified by:
create in class DoubleCheckedCreator<T>
- Parameters:
args - Arguments to use when creating the object
- Returns:
- A newly created object
retrieve
protected final T retrieve(Object... args)
- Specified by:
retrieve in class DoubleCheckedCreator<T>
- Parameters:
args - Arguments to use when retrieving the object
- Returns:
- An existing object if available
toString
public String toString()
- Overrides:
toString in class Object
- See Also:
Object.toString()
Copyright © 2010 Jasig. All Rights Reserved.