Class AbstractCacheResolver
java.lang.Object
org.springframework.cache.interceptor.AbstractCacheResolver
- All Implemented Interfaces:
InitializingBean
,CacheResolver
- Direct Known Subclasses:
NamedCacheResolver
,SimpleCacheResolver
,SimpleExceptionCacheResolver
public abstract class AbstractCacheResolver
extends Object
implements CacheResolver, InitializingBean
A base
CacheResolver
implementation that requires the concrete
implementation to provide the collection of cache name(s) based on the
invocation context.- Since:
- 4.1
- Author:
- Stephane Nicoll, Juergen Hoeller
-
Constructor Summary
ModifierConstructorDescriptionprotected
Construct a newAbstractCacheResolver
.protected
AbstractCacheResolver
(CacheManager cacheManager) Construct a newAbstractCacheResolver
for the givenCacheManager
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.Return theCacheManager
that this instance uses.protected abstract Collection<String>
getCacheNames
(CacheOperationInvocationContext<?> context) Provide the name of the cache(s) to resolve against the current cache manager.Collection<? extends Cache>
resolveCaches
(CacheOperationInvocationContext<?> context) Return the cache(s) to use for the specified invocation.void
setCacheManager
(CacheManager cacheManager) Set theCacheManager
that this instance should use.
-
Constructor Details
-
AbstractCacheResolver
protected AbstractCacheResolver()Construct a newAbstractCacheResolver
. -
AbstractCacheResolver
Construct a newAbstractCacheResolver
for the givenCacheManager
.- Parameters:
cacheManager
- the CacheManager to use
-
-
Method Details
-
setCacheManager
Set theCacheManager
that this instance should use. -
getCacheManager
Return theCacheManager
that this instance uses. -
afterPropertiesSet
public void afterPropertiesSet()Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
resolveCaches
Description copied from interface:CacheResolver
Return the cache(s) to use for the specified invocation.- Specified by:
resolveCaches
in interfaceCacheResolver
- Parameters:
context
- the context of the particular invocation- Returns:
- the cache(s) to use (never
null
)
-
getCacheNames
@Nullable protected abstract Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) Provide the name of the cache(s) to resolve against the current cache manager.It is acceptable to return
null
to indicate that no cache could be resolved for this invocation.- Parameters:
context
- the context of the particular invocation- Returns:
- the cache name(s) to resolve, or
null
if no cache should be resolved
-