Package io.micronaut.aop
Interface Interceptor<T,R>
-
- Type Parameters:
T- The intercepted typeR- The result type
- All Superinterfaces:
io.micronaut.core.order.Ordered
- All Known Subinterfaces:
ConstructorInterceptor<T>,MethodInterceptor<T,R>
@Indexed(Interceptor.class) public interface Interceptor<T,R> extends io.micronaut.core.order.Ordered
An Interceptor intercepts the execution of a method allowing cross cutting behaviour to be applied to a method's execution.
All implementations should be thread safe beans
In the case of
Aroundadvice the interceptor should invokeInvocationContext.proceed()to proceed with the method invocationIn the case of
Introductionadvice the interceptor should invokeInvocationContext.proceed()if it is unable to implement the method. The last call toInvocationContext.proceed()will produce aUnsupportedOperationExceptionindicating the method cannot be implemented. This mechanism allows multiple possible interceptors to participate in method implementation.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static io.micronaut.core.type.Argument<Interceptor<?,?>>ARGUMENTstatic java.lang.CharSequenceCACHEABLE_LAZY_TARGETTheAround.cacheableLazyTarget()setting.static java.lang.CharSequenceHOTSWAPTheAround.hotswap()setting.static java.lang.CharSequenceLAZYTheAround.lazy()setting.static java.lang.CharSequencePROXY_TARGETTheAround.proxyTarget()setting.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Rintercept(InvocationContext<T,R> context)Intercepts an execution from a declaredAroundadvice.
-
-
-
Field Detail
-
ARGUMENT
static final io.micronaut.core.type.Argument<Interceptor<?,?>> ARGUMENT
-
PROXY_TARGET
static final java.lang.CharSequence PROXY_TARGET
TheAround.proxyTarget()setting.
-
HOTSWAP
static final java.lang.CharSequence HOTSWAP
TheAround.hotswap()setting.
-
LAZY
static final java.lang.CharSequence LAZY
TheAround.lazy()setting.
-
CACHEABLE_LAZY_TARGET
static final java.lang.CharSequence CACHEABLE_LAZY_TARGET
TheAround.cacheableLazyTarget()setting.
-
-
Method Detail
-
intercept
R intercept(InvocationContext<T,R> context)
Intercepts an execution from a declaredAroundadvice. The implementation can either callInvocationContext.proceed()to return the original value or provide a replacement value- Parameters:
context- The interception context- Returns:
- result type
-
-