Class DefaultJCacheOperationSource
java.lang.Object
org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource
org.springframework.cache.jcache.interceptor.AnnotationJCacheOperationSource
org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.SmartInitializingSingleton
,JCacheOperationSource
public class DefaultJCacheOperationSource
extends AnnotationJCacheOperationSource
implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.SmartInitializingSingleton
The default
JCacheOperationSource
implementation delegating
default operations to configurable services with sensible defaults
when not present.- Since:
- 4.1
- Author:
- Stephane Nicoll, Juergen Hoeller
-
Field Summary
Fields inherited from class org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource
logger
-
Constructor Summary
ConstructorDescriptionConstruct a newDefaultJCacheOperationSource
with the default key generator.DefaultJCacheOperationSource
(Supplier<org.springframework.cache.CacheManager> cacheManager, Supplier<org.springframework.cache.interceptor.CacheResolver> cacheResolver, Supplier<org.springframework.cache.interceptor.CacheResolver> exceptionCacheResolver, Supplier<org.springframework.cache.interceptor.KeyGenerator> keyGenerator) Construct a newDefaultJCacheOperationSource
with the given cache manager, cache resolver and key generator suppliers, applying the corresponding default if a supplier is not resolvable. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected <T> T
Locate or create an instance of the specified cache strategytype
.org.springframework.cache.CacheManager
Return the specified cache manager to use, if any.org.springframework.cache.interceptor.CacheResolver
Return the specified cache resolver to use, if any.protected org.springframework.cache.CacheManager
protected org.springframework.cache.interceptor.CacheResolver
Return the defaultCacheResolver
if none is set.protected org.springframework.cache.interceptor.CacheResolver
Return the default exceptionCacheResolver
if none is set.protected org.springframework.cache.interceptor.KeyGenerator
Return the defaultKeyGenerator
if none is set.org.springframework.cache.interceptor.CacheResolver
Return the specified exception cache resolver to use, if any.org.springframework.cache.interceptor.KeyGenerator
Return the specified key generator to use.void
setBeanFactory
(org.springframework.beans.factory.BeanFactory beanFactory) void
setCacheManager
(org.springframework.cache.CacheManager cacheManager) Set the defaultCacheManager
to use to lookup cache by name.void
setCacheResolver
(org.springframework.cache.interceptor.CacheResolver cacheResolver) Set theCacheResolver
to resolve regular caches.void
setExceptionCacheResolver
(org.springframework.cache.interceptor.CacheResolver exceptionCacheResolver) Set theCacheResolver
to resolve exception caches.void
setKeyGenerator
(org.springframework.cache.interceptor.KeyGenerator keyGenerator) Set the defaultKeyGenerator
.Methods inherited from class org.springframework.cache.jcache.interceptor.AnnotationJCacheOperationSource
createCachePutOperation, createCacheRemoveAllOperation, createCacheRemoveOperation, createCacheResultOperation, determineCacheName, determineCacheResolverFactory, determineKeyGenerator, findCacheOperation, generateDefaultCacheName, getCacheDefaults, getCacheResolver, getExceptionCacheResolver
Methods inherited from class org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource
allowPublicMethodsOnly, getCacheOperation
-
Constructor Details
-
DefaultJCacheOperationSource
public DefaultJCacheOperationSource()Construct a newDefaultJCacheOperationSource
with the default key generator.- See Also:
-
SimpleKeyGenerator
-
DefaultJCacheOperationSource
public DefaultJCacheOperationSource(@Nullable Supplier<org.springframework.cache.CacheManager> cacheManager, @Nullable Supplier<org.springframework.cache.interceptor.CacheResolver> cacheResolver, @Nullable Supplier<org.springframework.cache.interceptor.CacheResolver> exceptionCacheResolver, @Nullable Supplier<org.springframework.cache.interceptor.KeyGenerator> keyGenerator) Construct a newDefaultJCacheOperationSource
with the given cache manager, cache resolver and key generator suppliers, applying the corresponding default if a supplier is not resolvable.- Since:
- 5.1
-
-
Method Details
-
setCacheManager
public void setCacheManager(@Nullable org.springframework.cache.CacheManager cacheManager) Set the defaultCacheManager
to use to lookup cache by name. Only mandatory if the cache resolver has not been set. -
getCacheManager
@Nullable public org.springframework.cache.CacheManager getCacheManager()Return the specified cache manager to use, if any. -
setCacheResolver
public void setCacheResolver(@Nullable org.springframework.cache.interceptor.CacheResolver cacheResolver) Set theCacheResolver
to resolve regular caches. If none is set, a default implementation using the specified cache manager will be used. -
getCacheResolver
@Nullable public org.springframework.cache.interceptor.CacheResolver getCacheResolver()Return the specified cache resolver to use, if any. -
setExceptionCacheResolver
public void setExceptionCacheResolver(@Nullable org.springframework.cache.interceptor.CacheResolver exceptionCacheResolver) Set theCacheResolver
to resolve exception caches. If none is set, a default implementation using the specified cache manager will be used. -
getExceptionCacheResolver
@Nullable public org.springframework.cache.interceptor.CacheResolver getExceptionCacheResolver()Return the specified exception cache resolver to use, if any. -
setKeyGenerator
public void setKeyGenerator(org.springframework.cache.interceptor.KeyGenerator keyGenerator) Set the defaultKeyGenerator
. If none is set, aSimpleKeyGenerator
honoring the JSR-107CacheKey
andCacheValue
will be used. -
getKeyGenerator
public org.springframework.cache.interceptor.KeyGenerator getKeyGenerator()Return the specified key generator to use. -
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) - Specified by:
setBeanFactory
in interfaceorg.springframework.beans.factory.BeanFactoryAware
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiated
in interfaceorg.springframework.beans.factory.SmartInitializingSingleton
-
getBean
Description copied from class:AnnotationJCacheOperationSource
Locate or create an instance of the specified cache strategytype
.- Specified by:
getBean
in classAnnotationJCacheOperationSource
- Parameters:
type
- the type of the bean to manage- Returns:
- the required bean
-
getDefaultCacheManager
protected org.springframework.cache.CacheManager getDefaultCacheManager() -
getDefaultCacheResolver
protected org.springframework.cache.interceptor.CacheResolver getDefaultCacheResolver()Description copied from class:AnnotationJCacheOperationSource
Return the defaultCacheResolver
if none is set.- Specified by:
getDefaultCacheResolver
in classAnnotationJCacheOperationSource
-
getDefaultExceptionCacheResolver
protected org.springframework.cache.interceptor.CacheResolver getDefaultExceptionCacheResolver()Description copied from class:AnnotationJCacheOperationSource
Return the default exceptionCacheResolver
if none is set.- Specified by:
getDefaultExceptionCacheResolver
in classAnnotationJCacheOperationSource
-
getDefaultKeyGenerator
protected org.springframework.cache.interceptor.KeyGenerator getDefaultKeyGenerator()Description copied from class:AnnotationJCacheOperationSource
Return the defaultKeyGenerator
if none is set.- Specified by:
getDefaultKeyGenerator
in classAnnotationJCacheOperationSource
-