CacheOperation that caches attributes
for methods and implements a fallback policy: 1. specific target method;
2. target class; 3. declaring method; 4. declaring class/interface.
Defaults to using the target class's caching attribute if none is associated with the target method. Any caching attribute associated with the target method completely overrides a class caching attribute. If none found on the target class, the interface that the invoked method has been called through (in case of a JDK proxy) will be checked.
This implementation caches attributes by method after they are first used. If it is ever desirable to allow dynamic changing of cacheable attributes (which is very unlikely), caching could be made configurable.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | attributeCache
Cache of CacheOperations, keyed by method on a specific target class. |
| protected final Log | logger
Logger available to subclasses. |
| private static final Collection | NULL_CACHING_ATTRIBUTE
Canonical value held in cache to indicate no caching attribute was found for this method and we don't need to look again. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | |
| private Collection | |
| protected abstract Collection | Returns: all caching attribute associated with this class, ornull if nonethe class to retrieve the attribute for clazz)Subclasses need to implement this to return the caching attribute for the given class, if any. |
| protected abstract Collection | Returns: all caching attribute associated with this method, ornull if nonethe method to retrieve the attribute for method)Subclasses need to implement this to return the caching attribute for the given method, if any. |
| protected Object | Returns: the cache key (nevernull)the method (never method, Class<?> null)the target class (may be targetClass)null)Determine a cache key for the given method and target class. |
| public Collection | getCacheOperations(Method
the method for the current invocation (never method, Class<?> null)the target class for this invocation (may be targetClass)null)Implements org. Determine the caching attribute for this method invocation. |
| attributeCache | back to summary |
|---|---|
| private final Map<Object, Collection<CacheOperation>> attributeCache Cache of CacheOperations, keyed by method on a specific target class. As this base class is not marked Serializable, the cache will be recreated after serialization - provided that the concrete subclass is Serializable. | |
| logger | back to summary |
|---|---|
| protected final Log logger Logger available to subclasses. As this base class is not marked Serializable, the logger will be recreated after serialization - provided that the concrete subclass is Serializable. | |
| NULL_CACHING_ATTRIBUTE | back to summary |
|---|---|
| private static final Collection<CacheOperation> NULL_CACHING_ATTRIBUTE Canonical value held in cache to indicate no caching attribute was found for this method and we don't need to look again. | |
| AbstractFallbackCacheOperationSource | back to summary |
|---|---|
| public AbstractFallbackCacheOperationSource() | |
| allowPublicMethodsOnly | back to summary |
|---|---|
| protected boolean allowPublicMethodsOnly() Should only public methods be allowed to have caching semantics? The default implementation returns | |
| computeCacheOperations | back to summary |
|---|---|
private Collection
| |
| findCacheOperations | back to summary |
|---|---|
| protected abstract Collection Subclasses need to implement this to return the caching attribute for the given class, if any.
| |
| findCacheOperations | back to summary |
|---|---|
| protected abstract Collection Subclasses need to implement this to return the caching attribute for the given method, if any.
| |
| getCacheKey | back to summary |
|---|---|
| protected Object getCacheKey(Method method, Class<?> targetClass) Determine a cache key for the given method and target class. Must not produce same key for overloaded methods. Must produce same key for different instances of the same method. | |
| getCacheOperations | back to summary |
|---|---|
| public Collection Implements org. Determine the caching attribute for this method invocation. Defaults to the class's caching attribute if no method attribute is found.
| |