Interface Interceptor<T,​R>

  • Type Parameters:
    T - The intercepted type
    R - 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 Around advice the interceptor should invoke InvocationContext.proceed() to proceed with the method invocation

    In the case of Introduction advice the interceptor should invoke InvocationContext.proceed() if it is unable to implement the method. The last call to InvocationContext.proceed() will produce a UnsupportedOperationException indicating the method cannot be implemented. This mechanism allows multiple possible interceptors to participate in method implementation.

    Since:
    1.0
    • Field Detail

      • ARGUMENT

        static final io.micronaut.core.type.Argument<Interceptor<?,​?>> ARGUMENT
      • HOTSWAP

        static final java.lang.CharSequence HOTSWAP
        The Around.hotswap() setting.
      • LAZY

        static final java.lang.CharSequence LAZY
        The Around.lazy() setting.
    • Method Detail

      • intercept

        R intercept​(InvocationContext<T,​R> context)
        Intercepts an execution from a declared Around advice. The implementation can either call InvocationContext.proceed() to return the original value or provide a replacement value
        Parameters:
        context - The interception context
        Returns:
        result type