public class JCacheAspectSupport extends AbstractCacheInvoker implements InitializingBean
JCacheInterceptor
or an AspectJ aspect.
Use the Spring caching abstraction for cache-related operations. No JSR-107
javax.cache.Cache
or javax.cache.CacheManager
are required to
process standard JSR-107 cache annotations.
The JCacheOperationSource
is used for determining caching operations
A cache aspect is serializable if its JCacheOperationSource
is serializable.
CacheAspectSupport
,
KeyGeneratorAdapter
,
CacheResolverAdapter
Modifier and Type | Class and Description |
---|---|
private class |
JCacheAspectSupport.CacheOperationInvokerAdapter |
Modifier and Type | Field and Description |
---|---|
private JCacheOperationSource |
cacheOperationSource |
private CachePutInterceptor |
cachePutInterceptor |
private CacheRemoveAllInterceptor |
cacheRemoveAllInterceptor |
private CacheRemoveEntryInterceptor |
cacheRemoveEntryInterceptor |
private CacheResultInterceptor |
cacheResultInterceptor |
private boolean |
initialized |
protected Log |
logger |
errorHandler
Constructor and Description |
---|
JCacheAspectSupport() |
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. |
private CacheOperationInvocationContext<?> |
createCacheOperationInvocationContext(java.lang.Object target,
java.lang.Object[] args,
JCacheOperation<?> operation) |
private java.lang.Object |
execute(CacheOperationInvocationContext<?> context,
CacheOperationInvoker invoker) |
protected java.lang.Object |
execute(CacheOperationInvoker invoker,
java.lang.Object target,
java.lang.reflect.Method method,
java.lang.Object[] args) |
JCacheOperationSource |
getCacheOperationSource()
Return the CacheOperationSource for this cache aspect.
|
protected java.lang.Object |
invokeOperation(CacheOperationInvoker invoker)
Execute the underlying operation (typically in case of cache miss) and return
the result of the invocation.
|
void |
setCacheOperationSource(JCacheOperationSource cacheOperationSource)
Set the CacheOperationSource for this cache aspect.
|
doClear, doEvict, doGet, doPut, getErrorHandler, setErrorHandler
protected final Log logger
@Nullable private JCacheOperationSource cacheOperationSource
@Nullable private CacheResultInterceptor cacheResultInterceptor
@Nullable private CachePutInterceptor cachePutInterceptor
@Nullable private CacheRemoveEntryInterceptor cacheRemoveEntryInterceptor
@Nullable private CacheRemoveAllInterceptor cacheRemoveAllInterceptor
private boolean initialized
public void setCacheOperationSource(JCacheOperationSource cacheOperationSource)
public JCacheOperationSource getCacheOperationSource()
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
@Nullable protected java.lang.Object execute(CacheOperationInvoker invoker, java.lang.Object target, java.lang.reflect.Method method, java.lang.Object[] args)
private CacheOperationInvocationContext<?> createCacheOperationInvocationContext(java.lang.Object target, java.lang.Object[] args, JCacheOperation<?> operation)
@Nullable private java.lang.Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker)
protected java.lang.Object invokeOperation(CacheOperationInvoker invoker)
ThrowableWrapper
: the exception can be handled or modified but it
must be wrapped in a ThrowableWrapper
as well.invoker
- the invoker handling the operation being cachedCacheOperationInvoker.invoke()