@Singleton
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 |
---|---|
int |
getOrder() |
java.lang.Object |
intercept(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context) |
protected java.lang.Object |
interceptCompletableFuture(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context,
io.micronaut.core.type.ReturnType<?> returnTypeObject,
java.lang.Class returnType)
Intercept the async method invocation.
|
protected java.lang.Object |
interceptSync(io.micronaut.aop.MethodInvocationContext context,
io.micronaut.core.type.ReturnType returnTypeObject,
java.lang.Class 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 returnTypeObject, java.lang.Class returnType)
context
- Contains information about method invocationreturnTypeObject
- The return type of the method in MicronautreturnType
- The return type classprotected java.lang.Object interceptCompletableFuture(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context, io.micronaut.core.type.ReturnType<?> returnTypeObject, java.lang.Class returnType)
context
- Contains information about method invocationreturnTypeObject
- The return type of the method in MicronautreturnType
- 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 generator