@InterceptorBean(value=CacheAnnotation.class) public class CacheInterceptor extends java.lang.Object implements io.micronaut.aop.MethodInterceptor<java.lang.Object,java.lang.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.
|
Constructor and Description |
---|
CacheInterceptor(CacheManager cacheManager,
CacheErrorHandler errorHandler,
AsyncCacheErrorHandler asyncCacheErrorHandler,
java.util.concurrent.ExecutorService ioExecutor,
io.micronaut.context.BeanContext beanContext)
Create Cache Interceptor with given arguments.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
doContextProceed(io.micronaut.aop.MethodInvocationContext context) |
int |
getOrder() |
java.lang.Object |
intercept(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context) |
protected java.util.concurrent.CompletionStage<?> |
interceptAsCompletableFuture(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context,
java.util.function.Supplier<java.util.concurrent.CompletionStage<?>> intercept,
io.micronaut.core.type.ReturnType<?> returnTypeObject,
io.micronaut.core.type.Argument<?> requiredType)
Intercept the async method invocation.
|
protected java.lang.Object |
interceptSync(io.micronaut.aop.MethodInvocationContext context,
io.micronaut.core.type.ReturnType<?> returnType)
Intercept the annotated method invocation with sync.
|
protected java.util.List<io.micronaut.core.annotation.AnnotationValue<CacheInvalidate>> |
invalidateOperations(io.micronaut.inject.ExecutableMethod<?,?> method)
Evict from the cache.
|
protected java.util.List<io.micronaut.core.annotation.AnnotationValue<CachePut>> |
putOperations(io.micronaut.inject.ExecutableMethod<?,?> method)
Saving inside the cache.
|
protected CacheKeyGenerator |
resolveKeyGenerator(java.lang.Class<? extends CacheKeyGenerator> type)
Resolve the cache key generator from the give type.
|
public static final int POSITION
public CacheInterceptor(CacheManager cacheManager, CacheErrorHandler errorHandler, AsyncCacheErrorHandler asyncCacheErrorHandler, @Named(value="io") java.util.concurrent.ExecutorService ioExecutor, io.micronaut.context.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()
getOrder
in interface io.micronaut.core.order.Ordered
public java.lang.Object intercept(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context)
intercept
in interface io.micronaut.aop.MethodInterceptor<java.lang.Object,java.lang.Object>
protected java.lang.Object interceptSync(io.micronaut.aop.MethodInvocationContext context, io.micronaut.core.type.ReturnType<?> returnType)
context
- Contains information about method invocationreturnType
- The return type classprotected java.util.concurrent.CompletionStage<?> interceptAsCompletableFuture(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context, java.util.function.Supplier<java.util.concurrent.CompletionStage<?>> intercept, io.micronaut.core.type.ReturnType<?> returnTypeObject, io.micronaut.core.type.Argument<?> requiredType)
context
- Contains information about method invocationintercept
- The intercepted resultreturnTypeObject
- The return type of the method in MicronautrequiredType
- The return type classprotected java.util.List<io.micronaut.core.annotation.AnnotationValue<CachePut>> putOperations(io.micronaut.inject.ExecutableMethod<?,?> method)
method
- Contains information about method invocationprotected java.util.List<io.micronaut.core.annotation.AnnotationValue<CacheInvalidate>> invalidateOperations(io.micronaut.inject.ExecutableMethod<?,?> method)
method
- Contains information about method invocationprotected CacheKeyGenerator resolveKeyGenerator(java.lang.Class<? extends CacheKeyGenerator> type)
type
- The key generatorprotected java.lang.Object doContextProceed(io.micronaut.aop.MethodInvocationContext context)
context
- the method invocation context