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
ConstructorsModifierConstructorDescriptionprotectedConstruct a newAbstractCacheResolver.protectedAbstractCacheResolver(CacheManager cacheManager) Construct a newAbstractCacheResolverfor the givenCacheManager. -
Method summary
Modifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.Return theCacheManagerthat this instance uses.protected abstract @Nullable 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.voidsetCacheManager(CacheManager cacheManager) set theCacheManagerthat this instance should use.
-
Constructor Details
-
AbstractCacheResolver
protected AbstractCacheResolver()Construct a newAbstractCacheResolver.- see Also:
-
AbstractCacheResolver
Construct a newAbstractCacheResolverfor the givenCacheManager.- Parameters:
cacheManager- the CacheManager to use
-
-
Method Details
-
setCacheManager
set theCacheManagerthat this instance should use. -
getCacheManager
Return theCacheManagerthat this instance uses. -
afterPropertiesset
public void afterPropertiesset()Description copied from interface: InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.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 interface InitializingBean
-
resolveCaches
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) Description copied from interface: CacheResolverReturn the cache(s) to use for the specified invocation.- specified by:
resolveCaches in interface CacheResolver- Parameters:
context- the context of the particular invocation- Returns:
- the cache(s) to use (never
null)
-
getCacheNames
protected abstract @Nullable Collection<string> getCacheNames(CacheOperationInvocationContext<?> context) Provide the name of the cache(s) to resolve against the current cache manager.It is acceptable to return
nullto 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
nullif no cache should be resolved
-