public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSource implements BeanFactoryAware, InitializingBean, SmartInitializingSingleton
JCacheOperationSource
implementation delegating
default operations to configurable services with sensible defaults
when not present.Modifier and Type | Class and Description |
---|---|
(package private) class |
DefaultJCacheOperationSource.LazyCacheResolver
Only resolve the default exception cache resolver when an exception needs to be handled.
|
Modifier and Type | Field and Description |
---|---|
private KeyGenerator |
adaptedKeyGenerator |
private BeanFactory |
beanFactory |
private CacheManager |
cacheManager |
private CacheResolver |
cacheResolver |
private CacheResolver |
exceptionCacheResolver |
private KeyGenerator |
keyGenerator |
logger
Constructor and Description |
---|
DefaultJCacheOperationSource() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
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(java.lang.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, if any.
|
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
private CacheManager cacheManager
private CacheResolver cacheResolver
private CacheResolver exceptionCacheResolver
private KeyGenerator keyGenerator
private KeyGenerator adaptedKeyGenerator
private BeanFactory beanFactory
public void setCacheManager(CacheManager cacheManager)
CacheManager
to use to lookup cache by name. Only mandatory
if the cache resolvers have not been set.public CacheManager getCacheManager()
public void setCacheResolver(CacheResolver cacheResolver)
CacheResolver
to resolve regular caches. If none is set, a default
implementation using the specified cache manager will be used.public CacheResolver getCacheResolver()
public void setExceptionCacheResolver(CacheResolver exceptionCacheResolver)
CacheResolver
to resolve exception caches. If none is set, a default
implementation using the specified cache manager will be used.public CacheResolver getExceptionCacheResolver()
public void setKeyGenerator(KeyGenerator keyGenerator)
KeyGenerator
. If none is set, a SimpleKeyGenerator
honoring the JSR-107 javax.cache.annotation.CacheKey
and
javax.cache.annotation.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
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
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(java.lang.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