Package com.sun.faces.util
Class ConcurrentCache<K,V>
- java.lang.Object
-
- com.sun.faces.util.ConcurrentCache<K,V>
-
- Direct Known Subclasses:
ExpiringConcurrentCache
public abstract class ConcurrentCache<K,V> extends Object
Defines a concurrent cache with a factory for creating new object instances. This (combined with ExpiringConcurrentCache) offers functionality similar to com.sun.faces.util.Cache. Two differences: 1. Cache is concrete/assumes a particular implementation. ConcurrentCache is abstract/allows subclasses to provide the implementation. This facilitates alternative implementations, such as DefaultFaceletCache's NoCache. 2. ConcurrentCache does not provide remove() as part of its contract, since remove behavior may be subclass-specific. For example, ExpiringConcurentCache automatically removes items by checking for expiration rather than requiring manual removes. We should consider consolidating Cache and ConcurrentCache + ExpiringConcurrentCache into a single class hierarchy so that we do not need to duplicate the JCIP scalable result cache code.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ConcurrentCache.Factory<K,V>
Factory interface for creating various cacheable objects.
-
Constructor Summary
Constructors Constructor Description ConcurrentCache(ConcurrentCache.Factory<K,V> f)
Constructs this cache using the specifiedFactory
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
containsKey(K key)
Tests whether the cache contains a value for the specified keyabstract V
get(K key)
Retrieves a value for the specified key.protected ConcurrentCache.Factory<K,V>
getFactory()
Retrieves aFactory
instance aasociated with this cache
-
-
-
Constructor Detail
-
ConcurrentCache
public ConcurrentCache(ConcurrentCache.Factory<K,V> f)
Constructs this cache using the specifiedFactory
.- Parameters:
f
-
-
-
Method Detail
-
get
public abstract V get(K key) throws ExecutionException
Retrieves a value for the specified key. If the value is not already present in the cache, a new instance will be allocated using theFactory
interface- Parameters:
key
- the key the value is associated with- Returns:
- the value for the specified key
- Throws:
ExecutionException
-
containsKey
public abstract boolean containsKey(K key)
Tests whether the cache contains a value for the specified key- Parameters:
key
- key to test- Returns:
- true if the value for the specified key is already cached, false otherwise
-
getFactory
protected final ConcurrentCache.Factory<K,V> getFactory()
Retrieves aFactory
instance aasociated with this cache- Returns:
Factory
instance
-
-