public class DefaultJCacheOperationSource extends AnnotationCacheOperationSource implements InitializingBean, ApplicationContextAware
JCacheOperationSource
implementation delegating
default operations to configurable services with sensible defaults
when not present.Modifier and Type | Field and Description |
---|---|
private ApplicationContext |
applicationContext |
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).
|
protected <T> T |
getBean(java.lang.Class<T> type)
Locate or create an instance of the specified
type . |
CacheResolver |
getDefaultCacheResolver()
Return the default
CacheResolver if none is set. |
CacheResolver |
getDefaultExceptionCacheResolver()
Return the default exception
CacheResolver if none is set. |
KeyGenerator |
getDefaultKeyGenerator()
Return the default
KeyGenerator if none is set. |
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
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 KeyGenerator keyGenerator
private CacheResolver cacheResolver
private CacheResolver exceptionCacheResolver
private ApplicationContext applicationContext
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 setCacheManager(CacheManager cacheManager)
CacheManager
to use to lookup cache by name. Only mandatory
if the cache resolvers have not been set.public void setKeyGenerator(KeyGenerator keyGenerator)
KeyGenerator
. If none is set, a default JSR-107 compliant
key generator is used.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 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 void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAware
Invoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
and
MessageSourceAware
, if applicable.
setApplicationContext
in interface ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
protected <T> T getBean(java.lang.Class<T> type)
AnnotationCacheOperationSource
type
.getBean
in class AnnotationCacheOperationSource
type
- the type of the bean to managepublic CacheResolver getDefaultCacheResolver()
AnnotationCacheOperationSource
CacheResolver
if none is set.getDefaultCacheResolver
in class AnnotationCacheOperationSource
public CacheResolver getDefaultExceptionCacheResolver()
AnnotationCacheOperationSource
CacheResolver
if none is set.getDefaultExceptionCacheResolver
in class AnnotationCacheOperationSource
public KeyGenerator getDefaultKeyGenerator()
AnnotationCacheOperationSource
KeyGenerator
if none is set.getDefaultKeyGenerator
in class AnnotationCacheOperationSource