在学习刘冬的spring.net AOP文章过程中,总结如下几点:
1、只能对实现接口的类进行拦截。(Java的ssh不用这么复杂)
2、对某个类实行拦截
<object id="myServiceObject" type="Spring.Aop.Framework.ProxyFactoryObject">
<!--拦截点-->
<property name="Target">
<object id="myServiceObjectTarget" type="AOPHelloWorld.ServiceCommand"/>
</property>
<!--织入功能-->
<property name="InterceptorNames">
<list>
<value>ExceptionIntercept</value>
<value>LogIntercept</value>
<value>PermissionIntercept</value>
<value>TransationIntercept</value>
</list>
</property>
</object>
3、自动代理--对某一批类或方法实行拦截
3.1对某一批类实行拦截
<object id="ProxyCreator" type="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator, Spring.Aop">
<property name="ObjectNames">
<list>
<value>*Service*</value>
</list>
</property>
<property name="InterceptorNames">
<list>
<value>ExceptionIntercept</value>
<value>LogInterceptor</value>
<value>PermissionIntercept</value>
<value>TransationIntercept</value>
<value>LogInterceptor</value>
</list>
</property>
</object>
3.2对某些方法实行拦截
<object id="LogIntercept" type="AOPHelloWorld.LogIntercept"/>
<object id="LogInterceptor" type="Spring.Aop.Support.NameMatchMethodPointcutAdvisor, Spring.Aop">
<property name="Advice" ref="LogIntercept"/>
<property name="MappedNames">
<list>
<value>Find*</value>
</list>
</property>
</object>
3.3对属性实行拦截
<object id="LogIntercept" type="AOPHelloWorld.LogIntercept"/>
<object id="LogInterceptor" type="Spring.Aop.Support.AttributeMatchMethodPointcutAdvisor, Spring.Aop">
<property name="Advice" ref="LogIntercept"/>
<property name="Attribute" value="AOPHelloWorld.Attribute.ConsoleDebugAttribute, AOPHelloWorld"/>
</object>