Spring AOP Proxy AutoProxy

AOP
Advice: action taken by an aspect at a particular join point. Different types of advice include "around,"
"before" and "after" advice. (Advice types are discussed below.) Many AOP frameworks, including
Spring, model an advice as an interceptor, maintaining a chain of interceptors around the join point.
Advice types in Spring:
Interception around advice-->org.aopalliance.intercept.MethodInterceptor
Before advice-->MethodBeforeAdvice
Throws advice-->ThrowsAdvice
After Returning advice-->AfterReturningAdvice
Introduction advice-->IntroductionInterceptor extends MethodInterceptor


Note the advisor and the interceptor order in the chain !

ProxyFactory factory = new ProxyFactory(myBusinessInterfaceImpl);
factory.addAdvice(myMethodInterceptor);
factory.addAdvisor(myAdvisor);
MyBusinessInterface tb = (MyBusinessInterface) factory.getProxy();

<aop:config>
<aop:aspectj-autoproxy />
当使用<aop:config>配置时自动注册AspectJAwareAdvisorAutoProxyCreator,
而使用<aop:aspectj-autoproxy>时会自动注册AnnotationAwareAspectJAutoProxyCreator。

你可能感兴趣的:(spring aop)