在一个类拦截一个或多个自定义特性,我会。但是如果我想拦截多个类,多个属性怎么配置?配置如下,我还想拦截ProductService里的一些挂有自定义特性的方法,怎么试都不行。。。难道只能每个类还得配置一个ProxyFactoryObject?
个人觉得,既然是代理工厂,应该可以生成很多类的代理吧,不可能需要每个类一个工厂,那就不是工厂了吧。请高手指教一下。
<object id="aroundAdvisor" type="Spring.Aop.Support.AttributeMatchMethodPointcutAdvisor, Spring.Aop">
<property name="Advice" ref="aroundAdvice2"/>
<property name="Attribute" value="AOP_SpringNetTest.PointcutAdvisorAttribute, AOP_SpringNetTest" />
</object>
<object id="aroundAdvisor2" type="Spring.Aop.Support.AttributeMatchMethodPointcutAdvisor, Spring.Aop">
<property name="Advice" ref="aroundAdvice2"/>
<property name="Attribute" value="AOP_SpringNetTest.PointcutAdvisor2Attribute, AOP_SpringNetTest" />
</object>
<object id="proxyFactoryObject" type="Spring.Aop.Framework.ProxyFactoryObject">
<property name="Target">
<!-- <list>
<object type="AOP_SpringNetTest.Service.CategoryService,AOP_SpringNetTest" />
<object type="AOP_SpringNetTest.Service.ProductService,AOP_SpringNetTest" />
</list>-->
<object type="AOP_SpringNetTest.Service.CategoryService,AOP_SpringNetTest" />
</property>
<property name="InterceptorNames">
<list>
<value>aroundAdvisor </value>
<value>aroundAdvisor2 </value>
</list>
</property>
</object>
<object id="aroundAdvice2" type="AOP_SpringNetTest.Aspects.AroundAdvice2, AOP_SpringNetTest"/>
ProxyFactoryObject对象是不支持这样的,此种情况,应该使用自动代理类
<!--动态代理-->
<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>attributeMatchMethodPointcutAdvisor</value>
</list>
</property>
</object>