Top Description Inners Fields Constructors Methods
com.sun.faces.util

public final Class ExpiringConcurrentCache<K, V>

extends ConcurrentCache<K, V>
Class Inheritance
Imports
java.util.concurrent.Callable, .CancellationException, .ConcurrentHashMap, .ConcurrentMap, .ExecutionException, .Future, .FutureTask, .TimeUnit, .TimeoutException, java.util.logging.Level, .Logger, jakarta.faces.FacesException

This class implements an abstract ConcurrentCache with objects in the cache potentially expiring. Only non-expired objects will be returned from the cache or considered to be contained in the cache The cache is self-managing, so no remove() method is defined

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ExpiringConcurrentCache.ExpiryChecker<K, V>

Interface for checking whether a cached object expired

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<K, Future<V>>
private final ExpiringConcurrentCache.ExpiryChecker<K, V>
private static final Logger

Constructor Summary

AccessConstructor and Description
public
ExpiringConcurrentCache(ConcurrentCache.Factory<K, V>
used to create new instances of objects that are not already available
f
,
ExpiringConcurrentCache.ExpiryChecker<K, V>
used to check whether an object in the cache has expired
checker
)

Public constructor.

Method Summary

Modifier and TypeMethod and Description
private ExpiringConcurrentCache.ExpiryChecker<K, V>
public boolean
containsKey(final K
key to test
key
)

Implements abstract com.sun.faces.util.ConcurrentCache.containsKey.

Tests whether the cache contains a value for the specified key

public V
get(final K
the key the value is associated with
key
)

Implements abstract com.sun.faces.util.ConcurrentCache.get.

Retrieves a value for the specified key.

Inherited from com.sun.faces.util.ConcurrentCache:
getFactory

Field Detail

_cacheback to summary
private final ConcurrentMap<K, Future<V>> _cache
_checkerback to summary
private final ExpiringConcurrentCache.ExpiryChecker<K, V> _checker
_LOGGERback to summary
private static final Logger _LOGGER

Constructor Detail

ExpiringConcurrentCacheback to summary
public ExpiringConcurrentCache(ConcurrentCache.Factory<K, V> f, ExpiringConcurrentCache.ExpiryChecker<K, V> checker)

Public constructor.

Parameters
f:ConcurrentCache.Factory<K, V>

used to create new instances of objects that are not already available

checker:ExpiringConcurrentCache.ExpiryChecker<K, V>

used to check whether an object in the cache has expired

Method Detail

_getExpiryCheckerback to summary
private ExpiringConcurrentCache.ExpiryChecker<K, V> _getExpiryChecker()
containsKeyback to summary
public boolean containsKey(final K key)

Implements abstract com.sun.faces.util.ConcurrentCache.containsKey.

Doc from com.sun.faces.util.ConcurrentCache.containsKey.

Tests whether the cache contains a value for the specified key

Parameters
key:K

key to test

Returns:boolean

true if the value for the specified key is already cached, false otherwise

Annotations
@Override
getback to summary
public V get(final K key) throws ExecutionException

Implements abstract com.sun.faces.util.ConcurrentCache.get.

Doc from com.sun.faces.util.ConcurrentCache.get.

Retrieves a value for the specified key. If the value is not already present in the cache, a new instance will be allocated using the Factory interface

Parameters
key:K

the key the value is associated with

Returns:V

the value for the specified key

Annotations
@Override
com.sun.faces.util back to summary

public Interface ExpiringConcurrentCache.ExpiryChecker<K, V>

Known Direct Implementers
com.sun.faces.facelets.impl.DefaultFaceletCache.ExpiryChecker, com.sun.faces.facelets.impl.DefaultFaceletCache.NeverExpired

Interface for checking whether a cached object expired

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the value expired and should be removed from the cache, false otherwise
isExpired
(K
cache key
key
,
V
cached value
value
)

Checks whether a cached object expired

Method Detail

isExpiredback to summary
public boolean isExpired(K key, V value)

Checks whether a cached object expired

Parameters
key:K

cache key

value:V

cached value

Returns:boolean

true if the value expired and should be removed from the cache, false otherwise