`

spring AOP

 
阅读更多
DefaultAopProxyFactory.createAopProxy(AdvisedSupport config)
{...
    return new JdkDynamicAopProxy(config);
...}


JdkDynamicAopProxy(config).getProxy()
...return Proxy.newProxyInstance(classLoader, proxiedInterfaces, this);...

....

invoke(Object proxy, Method method, Object[] args)
...List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass);...
invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain);
// Proceed to the joinpoint through the interceptor chain.
retVal = invocation.proceed();



AdvisorAdapterRegistry registry = GlobalAdvisorAdapterRegistry.getInstance();

MethodInterceptor[] interceptors = registry.getInterceptors(advisor);


public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException {
List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>(3);
Advice advice = advisor.getAdvice();
if (advice instanceof MethodInterceptor) {
interceptors.add((MethodInterceptor) advice);
}
for (AdvisorAdapter adapter : this.adapters) {
if (adapter.supportsAdvice(advice)) {
interceptors.add(adapter.getInterceptor(advisor));
}
}
if (interceptors.isEmpty()) {
throw new UnknownAdviceTypeException(advisor.getAdvice());
}
return interceptors.toArray(new MethodInterceptor[interceptors.size()]);
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics