@Singleton public class CacheInterceptor extends Object implements MethodInterceptor<Object,Object>
An AOP MethodInterceptor implementation for the Cache annotations Cacheable,
CachePut and CacheInvalidate.
| Modifier and Type | Field and Description |
|---|---|
static int |
POSITION
The position on the interceptor in the chain.
|
HOTSWAP, LAZY, PROXY_TARGETHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| Constructor and Description |
|---|
CacheInterceptor(CacheManager cacheManager,
CacheErrorHandler errorHandler,
AsyncCacheErrorHandler asyncCacheErrorHandler,
ExecutorService ioExecutor,
BeanContext beanContext)
Create Cache Interceptor with given arguments.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getOrder() |
Object |
intercept(MethodInvocationContext<Object,Object> context)
Extended version of the
MethodInterceptor.intercept(InvocationContext) method that accepts a MethodInvocationContext. |
protected Object |
interceptCompletableFuture(MethodInvocationContext<Object,Object> context,
ReturnType<?> returnTypeObject,
Class returnType)
Intercept the aync method invocation.
|
protected Object |
interceptSync(MethodInvocationContext context,
ReturnType returnTypeObject,
Class returnType)
Intercept the annotated method invocation with sync.
|
protected List<AnnotationValue<CacheInvalidate>> |
invalidateOperations(MethodInvocationContext context)
Evict from the cache.
|
protected List<AnnotationValue<CachePut>> |
putOperations(MethodInvocationContext context)
Saving inside the cache.
|
protected CacheKeyGenerator |
resolveKeyGenerator(Class<? extends CacheKeyGenerator> type)
Resolve the cache key generator from the give type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinterceptpublic static final int POSITION
public CacheInterceptor(CacheManager cacheManager, CacheErrorHandler errorHandler, AsyncCacheErrorHandler asyncCacheErrorHandler, @Named(value="io") ExecutorService ioExecutor, BeanContext beanContext)
cacheManager - The cache managererrorHandler - Cache error handlerasyncCacheErrorHandler - Async cache error handlersioExecutor - The executor to create tasksbeanContext - The bean context to allow DIpublic int getOrder()
public Object intercept(MethodInvocationContext<Object,Object> context)
MethodInterceptorMethodInterceptor.intercept(InvocationContext) method that accepts a MethodInvocationContext.intercept in interface MethodInterceptor<Object,Object>context - The contextprotected Object interceptSync(MethodInvocationContext context, ReturnType returnTypeObject, Class returnType)
context - Contains information about method invocationreturnTypeObject - The return type of the method in MicronautreturnType - The return type classprotected Object interceptCompletableFuture(MethodInvocationContext<Object,Object> context, ReturnType<?> returnTypeObject, Class returnType)
context - Contains information about method invocationreturnTypeObject - The return type of the method in MicronautreturnType - The return type classprotected List<AnnotationValue<CachePut>> putOperations(MethodInvocationContext context)
context - Contains information about method invocationprotected List<AnnotationValue<CacheInvalidate>> invalidateOperations(MethodInvocationContext context)
context - Extended version of InvocationContext for MethodInterceptor instancesprotected CacheKeyGenerator resolveKeyGenerator(Class<? extends CacheKeyGenerator> type)
type - The key generator