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:
Aware
,BeanFactoryAware
,SmartInitializingSingleton
,JCacheOperationSource
public class DefaultJCacheOperationSource
extends AnnotationJCacheOperationSource
implements BeanFactoryAware, 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<CacheManager> cacheManager, Supplier<CacheResolver> cacheResolver, Supplier<CacheResolver> exceptionCacheResolver, Supplier<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
Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.protected <T> T
Locate or create an instance of the specified cache strategytype
.Return the specified cache manager to use, if any.Return the specified cache resolver to use, if any.protected CacheManager
protected CacheResolver
Return the defaultCacheResolver
if none is set.protected CacheResolver
Return the default exceptionCacheResolver
if none is set.protected KeyGenerator
Return the defaultKeyGenerator
if none is set.Return the specified exception cache resolver to use, if any.Return the specified key generator to use.void
setBeanFactory
(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.void
setCacheManager
(CacheManager cacheManager) Set the defaultCacheManager
to use to lookup cache by name.void
setCacheResolver
(CacheResolver cacheResolver) Set theCacheResolver
to resolve regular caches.void
setExceptionCacheResolver
(CacheResolver exceptionCacheResolver) Set theCacheResolver
to resolve exception caches.void
setKeyGenerator
(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, isCandidateClass
Methods inherited from class org.springframework.cache.jcache.interceptor.AbstractFallbackJCacheOperationSource
allowPublicMethodsOnly, getCacheOperation, hasCacheOperation
-
Constructor Details
-
DefaultJCacheOperationSource
public DefaultJCacheOperationSource()Construct a newDefaultJCacheOperationSource
with the default key generator.- See Also:
-
DefaultJCacheOperationSource
public DefaultJCacheOperationSource(@Nullable Supplier<CacheManager> cacheManager, @Nullable Supplier<CacheResolver> cacheResolver, @Nullable Supplier<CacheResolver> exceptionCacheResolver, @Nullable Supplier<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
Set the defaultCacheManager
to use to lookup cache by name. Only mandatory if the cache resolver has not been set. -
getCacheManager
Return the specified cache manager to use, if any. -
setCacheResolver
Set theCacheResolver
to resolve regular caches. If none is set, a default implementation using the specified cache manager will be used. -
getCacheResolver
Return the specified cache resolver to use, if any. -
setExceptionCacheResolver
Set theCacheResolver
to resolve exception caches. If none is set, a default implementation using the specified cache manager will be used. -
getExceptionCacheResolver
Return the specified exception cache resolver to use, if any. -
setKeyGenerator
Set the defaultKeyGenerator
. If none is set, aSimpleKeyGenerator
honoring the JSR-107CacheKey
andCacheValue
will be used. -
getKeyGenerator
Return the specified key generator to use. -
setBeanFactory
Description copied from interface:BeanFactoryAware
Callback that supplies the owning factory to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()Description copied from interface:SmartInitializingSingleton
Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.ListableBeanFactory.getBeansOfType(java.lang.Class<T>)
calls within this method won't trigger accidental side effects during bootstrap.NOTE: This callback won't be triggered for singleton beans lazily initialized on demand after
BeanFactory
bootstrap, and not for any other bean scope either. Carefully use it for beans with the intended bootstrap semantics only.- Specified by:
afterSingletonsInstantiated
in interfaceSmartInitializingSingleton
-
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
-
getDefaultCacheResolver
Description copied from class:AnnotationJCacheOperationSource
Return the defaultCacheResolver
if none is set.- Specified by:
getDefaultCacheResolver
in classAnnotationJCacheOperationSource
-
getDefaultExceptionCacheResolver
Description copied from class:AnnotationJCacheOperationSource
Return the default exceptionCacheResolver
if none is set.- Specified by:
getDefaultExceptionCacheResolver
in classAnnotationJCacheOperationSource
-
getDefaultKeyGenerator
Description copied from class:AnnotationJCacheOperationSource
Return the defaultKeyGenerator
if none is set.- Specified by:
getDefaultKeyGenerator
in classAnnotationJCacheOperationSource
-