类 ExposeInvocationInterceptor

java.lang.Object
infra.aop.interceptor.ExposeInvocationInterceptor
所有已实现的接口:
infra.core.Ordered, Serializable, Advice, Interceptor, MethodInterceptor

public final class ExposeInvocationInterceptor extends Object implements MethodInterceptor, infra.core.Ordered, Serializable
Interceptor that exposes the current MethodInvocation as a thread-local object. We occasionally need to do this; for example, when a pointcut (e.g. an AspectJ expression pointcut) needs to know the full invocation context.

Don't use this interceptor unless this is really necessary. Target objects should not normally know about AOP, as this creates a dependency on API. Target objects should be plain POJOs as far as possible.

If used, this interceptor will normally be the first in the interceptor chain.

从以下版本开始:
3.0
作者:
Rod Johnson, Juergen Hoeller, TODAY 2021/2/3 23:40
另请参阅:
  • 字段详细资料

    • INSTANCE

      public static final ExposeInvocationInterceptor INSTANCE
      Singleton instance of this class.
    • ADVISOR

      public static final Advisor ADVISOR
      Singleton advisor for this class. Use in preference to INSTANCE when using AOP, as it prevents the need to create a new Advisor to wrap the instance.
    • invocation

      private static final ThreadLocal<MethodInvocation> invocation
  • 构造器详细资料

    • ExposeInvocationInterceptor

      private ExposeInvocationInterceptor()
      Ensures that only the canonical instance can be created.
  • 方法详细资料

    • currentInvocation

      public static MethodInvocation currentInvocation() throws IllegalStateException
      Return the AOP Alliance MethodInvocation object associated with the current invocation.
      返回:
      the invocation object associated with the current invocation
      抛出:
      IllegalStateException - if there is no AOP invocation in progress, or if the ExposeInvocationInterceptor was not added to this interceptor chain
    • invoke

      public Object invoke(MethodInvocation mi) throws Throwable
      从接口复制的说明: MethodInterceptor
      Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invoke Joinpoint.proceed().
      指定者:
      invoke 在接口中 MethodInterceptor
      参数:
      mi - the method invocation joinpoint
      返回:
      the result of the call to Joinpoint.proceed(), might be intercepted by the interceptor.
      抛出:
      Throwable - if the interceptors or the target-object throws an exception.
    • getOrder

      public int getOrder()
      指定者:
      getOrder 在接口中 infra.core.Ordered
    • readResolve

      private Object readResolve()
      Required to support serialization. Replaces with canonical instance on deserialization, protecting Singleton pattern.

      Alternative to overriding the equals method.