Interface MethodInterceptor

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Provides method interception such that logic can be provided both before and after method invocation.

MethodInterceptor instances are provided by AspectProvider.interceptor(Method, Annotation).

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    invoke(Invocation invocation)
    Implementation can perform before and after invocation logic.
  • Method Details

    • invoke

      void invoke(Invocation invocation) throws Throwable
      Implementation can perform before and after invocation logic.

      If a method interceptor wants to replace the result it does this via Invocation.result(Object). This is a little different to traditional method interceptors (i.e. org.org.aopalliance.intercept.MethodInterceptor). It is done this way to handle implied generic return types in the generated source code.

      Parameters:
      invocation - The invocation being intercepted
      Throws:
      Throwable - If the interception or underlying invocation throws an exception