Package io.micronaut.cache.interceptor
Class CacheInterceptor
java.lang.Object
io.micronaut.cache.interceptor.CacheInterceptor
- All Implemented Interfaces:
 io.micronaut.aop.Interceptor<Object,,Object> io.micronaut.aop.MethodInterceptor<Object,,Object> io.micronaut.core.order.Ordered
@InterceptorBean(CacheAnnotation.class)
public class CacheInterceptor
extends Object
implements io.micronaut.aop.MethodInterceptor<Object,Object> 
An AOP MethodInterceptor implementation for the Cache annotations Cacheable,
 CachePut and CacheInvalidate.
- Since:
 - 1.0
 - Author:
 - Graeme Rocher
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe position on the interceptor in the chain.Fields inherited from interface io.micronaut.aop.Interceptor
ARGUMENT, CACHEABLE_LAZY_TARGET, HOTSWAP, LAZY, PROXY_TARGETFields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE - 
Constructor Summary
ConstructorsConstructorDescriptionCacheInterceptor(CacheManager cacheManager, CacheErrorHandler errorHandler, AsyncCacheErrorHandler asyncCacheErrorHandler, ExecutorService ioExecutor, io.micronaut.context.BeanContext beanContext) Create Cache Interceptor with given arguments. - 
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectdoContextProceed(io.micronaut.aop.MethodInvocationContext context) intgetOrder()protected CompletionStage<?>interceptAsCompletableFuture(io.micronaut.aop.MethodInvocationContext<Object, Object> context, Supplier<CompletionStage<?>> intercept, io.micronaut.core.type.ReturnType<?> returnTypeObject, io.micronaut.core.type.Argument<?> requiredType) Intercept the async method invocation.protected ObjectinterceptSync(io.micronaut.aop.MethodInvocationContext context, io.micronaut.core.type.ReturnType<?> returnType) Intercept the annotated method invocation with sync.protected List<io.micronaut.core.annotation.AnnotationValue<CacheInvalidate>>invalidateOperations(io.micronaut.inject.ExecutableMethod<?, ?> method) Evict from the cache.putOperations(io.micronaut.inject.ExecutableMethod<?, ?> method) Saving inside the cache.protected CacheKeyGeneratorresolveKeyGenerator(Class<? extends CacheKeyGenerator> type) Resolve the cache key generator from the give type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.aop.MethodInterceptor
intercept 
- 
Field Details
- 
POSITION
public static final int POSITIONThe position on the interceptor in the chain. 
 - 
 - 
Constructor Details
- 
CacheInterceptor
public CacheInterceptor(CacheManager cacheManager, CacheErrorHandler errorHandler, AsyncCacheErrorHandler asyncCacheErrorHandler, @Named("io") ExecutorService ioExecutor, io.micronaut.context.BeanContext beanContext) Create Cache Interceptor with given arguments.- Parameters:
 cacheManager- The cache managererrorHandler- Cache error handlerasyncCacheErrorHandler- Async cache error handlersioExecutor- The executor to create tasksbeanContext- The bean context to allow DI
 
 - 
 - 
Method Details
- 
getOrder
public int getOrder()- Specified by:
 getOrderin interfaceio.micronaut.core.order.Ordered
 - 
intercept
 - 
interceptSync
protected Object interceptSync(io.micronaut.aop.MethodInvocationContext context, io.micronaut.core.type.ReturnType<?> returnType) Intercept the annotated method invocation with sync.- Parameters:
 context- Contains information about method invocationreturnType- The return type class- Returns:
 - The value from the cache
 
 - 
interceptAsCompletableFuture
protected CompletionStage<?> interceptAsCompletableFuture(io.micronaut.aop.MethodInvocationContext<Object, Object> context, Supplier<CompletionStage<?>> intercept, io.micronaut.core.type.ReturnType<?> returnTypeObject, io.micronaut.core.type.Argument<?> requiredType) Intercept the async method invocation.- Parameters:
 context- Contains information about method invocationintercept- The intercepted resultreturnTypeObject- The return type of the method in MicronautrequiredType- The return type class- Returns:
 - The value from the cache
 
 - 
putOperations
protected List<io.micronaut.core.annotation.AnnotationValue<CachePut>> putOperations(io.micronaut.inject.ExecutableMethod<?, ?> method) Saving inside the cache.- Parameters:
 method- Contains information about method invocation- Returns:
 - The operations to cause the return value to be cached within the given cache name.
 
 - 
invalidateOperations
protected List<io.micronaut.core.annotation.AnnotationValue<CacheInvalidate>> invalidateOperations(io.micronaut.inject.ExecutableMethod<?, ?> method) Evict from the cache.- Parameters:
 method- Contains information about method invocation- Returns:
 - The operations to cause the eviction of the given caches
 
 - 
resolveKeyGenerator
Resolve the cache key generator from the give type.- Parameters:
 type- The key generator- Returns:
 - The cache key generator
 
 - 
doContextProceed
- Parameters:
 context- the method invocation context- Returns:
 - the proceed result
 
 
 -