ObjectNameAutoProxyCreatorMethodTest : Passed
Method:Validate开始执行
Method:Validate执行完毕
4.1.3 SdkRegularExpressionMethodPointcut 通过正则表达式来匹配需要执行的类或方法
- AOP 配置
- <object id="ValidatePointCut" type="Spring.Aop.Support.SdkRegularExpressionMethodPointcut, Spring.Aop">
- <property name="Pattern" value="UserValidate.Advance*"></property>
- </object>
- <aop:config>
- <aop:advisor advice-ref="RoundInterceptor" pointcut-ref="ValidatePointCut"/>
- </aop:config>
pattern 的属性 UserValidate.Advance* 表示 匹配 UserValidate 类中的以Advance开头的方法
4.1.4 DefaultAdvisorAutoProxyCreator+RegularExpressionMethodPointcutAdvisor 创建正则表达式AOP
- AOP 配置
- <object id="ProxyCreator" type="Spring.Aop.Framework.AutoProxy.DefaultAdvisorAutoProxyCreator, Spring.Aop"/> <object id="ValidateRegularExpressionPointCut" type="Spring.Aop.Support.RegularExpressionMethodPointcutAdvisor, Spring.Aop">
- <property name="advice" ref="RoundInterceptor"/>
- <property name="patterns">
- <list>
- <value>UserValidate.Advance*</value>
- </list>
- </property>
- </object>
4.1.5 特性Aop
可以通过Attribute类来实现AOP
- [AttributeUsage(AttributeTargets.Method)]
- public class AopAttribute:Attribute
- {
- }
- AOP 配置
- <object id="aroundAdvisor" type="Spring.Aop.Support.AttributeMatchMethodPointcutAdvisor, Spring.Aop">
- <property name="Advice" ref="RoundInterceptor"/>
- <property name="Attribute"
- value ="Stephen.SpringNet.AOPSample.Servcies.AopAttribute, Servcies" />
- </object>
- <object id="ValidateAttributeProxy" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
- <property name="proxyInterfaces" value="Stephen.SpringNet.AOPSample.Servcies.IValidateService"/>
- <property name="target" ref="UserValidateTarget"/>
- <property name="interceptorNames">
- <list>
- <value>aroundAdvisor</value>
- </list>
- </property>
- </object>
原