Spring源码-Aspect-内置Advisor与Interceptor

总结摘要
Spring AOP 内置Advisor与Interceptor

ExposeInvocationInterceptor

将 MethodInvocation 存储到 ThreadLocal 变量中。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
public final class ExposeInvocationInterceptor implements MethodInterceptor, PriorityOrdered, Serializable {
	private static final ThreadLocal<MethodInvocation> invocation =
			new NamedThreadLocal<>("Current AOP method invocation");
	public static MethodInvocation currentInvocation() throws IllegalStateException {
		MethodInvocation mi = invocation.get();
        //...
    }
	@Override
	@Nullable
	public Object invoke(MethodInvocation mi) throws Throwable {
		MethodInvocation oldInvocation = invocation.get();
		invocation.set(mi);
		try {
			return mi.proceed();
		}
		finally {
			invocation.set(oldInvocation);
		}
	}
}

END