public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSource implements BeanFactoryAware, InitializingBean, SmartInitializingSingleton
JCacheOperationSource
implementation delegating
default operations to configurable services with sensible defaults
when not present.logger
Constructor and Description |
---|
DefaultJCacheOperationSource() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
void |
afterSingletonsInstantiated()
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 |
getBean(Class<T> type)
Locate or create an instance of the specified cache strategy
type . |
CacheManager |
getCacheManager()
Return the specified cache manager to use, if any.
|
CacheResolver |
getCacheResolver()
Return the specified cache resolver to use, if any.
|
protected CacheManager |
getDefaultCacheManager() |
protected CacheResolver |
getDefaultCacheResolver()
Return the default
CacheResolver if none is set. |
protected CacheResolver |
getDefaultExceptionCacheResolver()
Return the default exception
CacheResolver if none is set. |
protected KeyGenerator |
getDefaultKeyGenerator()
Return the default
KeyGenerator if none is set. |
CacheResolver |
getExceptionCacheResolver()
Return the specified exception cache resolver to use, if any.
|
KeyGenerator |
getKeyGenerator()
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 default
CacheManager to use to lookup cache by name. |
void |
setCacheResolver(CacheResolver cacheResolver)
Set the
CacheResolver to resolve regular caches. |
void |
setExceptionCacheResolver(CacheResolver exceptionCacheResolver)
Set the
CacheResolver to resolve exception caches. |
void |
setKeyGenerator(KeyGenerator keyGenerator)
Set the default
KeyGenerator . |
createCachePutOperation, createCacheRemoveAllOperation, createCacheRemoveOperation, createCacheResultOperation, determineCacheName, determineCacheResolverFactory, determineKeyGenerator, findCacheOperation, generateDefaultCacheName, getCacheDefaults, getCacheResolver, getExceptionCacheResolver
allowPublicMethodsOnly, getCacheOperation
public void setCacheManager(@Nullable CacheManager cacheManager)
CacheManager
to use to lookup cache by name.
Only mandatory if the cache resolver has not been set.@Nullable public CacheManager getCacheManager()
public void setCacheResolver(@Nullable CacheResolver cacheResolver)
CacheResolver
to resolve regular caches. If none is set, a default
implementation using the specified cache manager will be used.@Nullable public CacheResolver getCacheResolver()
public void setExceptionCacheResolver(@Nullable CacheResolver exceptionCacheResolver)
CacheResolver
to resolve exception caches. If none is set, a default
implementation using the specified cache manager will be used.@Nullable public CacheResolver getExceptionCacheResolver()
public void setKeyGenerator(KeyGenerator keyGenerator)
KeyGenerator
. If none is set, a SimpleKeyGenerator
honoring the JSR-107 CacheKey
and
CacheValue
will be used.public KeyGenerator getKeyGenerator()
public void setBeanFactory(BeanFactory beanFactory)
BeanFactoryAware
Invoked after the population of normal bean properties
but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanFactory
in interface BeanFactoryAware
beanFactory
- owning BeanFactory (never null
).
The bean can immediately call methods on the factory.BeanInitializationException
public void afterPropertiesSet()
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, 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.
afterPropertiesSet
in interface InitializingBean
public void afterSingletonsInstantiated()
SmartInitializingSingleton
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.
afterSingletonsInstantiated
in interface SmartInitializingSingleton
protected <T> T getBean(Class<T> type)
AnnotationJCacheOperationSource
type
.getBean
in class AnnotationJCacheOperationSource
type
- the type of the bean to manageprotected CacheManager getDefaultCacheManager()
protected CacheResolver getDefaultCacheResolver()
AnnotationJCacheOperationSource
CacheResolver
if none is set.getDefaultCacheResolver
in class AnnotationJCacheOperationSource
protected CacheResolver getDefaultExceptionCacheResolver()
AnnotationJCacheOperationSource
CacheResolver
if none is set.getDefaultExceptionCacheResolver
in class AnnotationJCacheOperationSource
protected KeyGenerator getDefaultKeyGenerator()
AnnotationJCacheOperationSource
KeyGenerator
if none is set.getDefaultKeyGenerator
in class AnnotationJCacheOperationSource