1. 程式人生 > >spring aop expression支援多個表示式配置

spring aop expression支援多個表示式配置

<!-- 配置那些類的方法進行事務管理 --> 
<aop:config> 
<aop:pointcut id="allServiceMethod" expression="execution (* com.cms.sys.service.*.*(..))" /> 
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod" /> 
</aop:config> 

還有一個 
execution (* com.cms.art.service.*.*(..))" 

要怎麼寫? 

可以這樣寫:將execution分開寫。 
<aop:config> 
<aop:pointcut id="allServiceMethod" expression="(execution (* com.cms.sys.service.*.*(..))) or (execution (* com.cms.art.service.*.*(..)))" /> 
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod" /> 
</aop:config> 

老外喜歡吧邏輯運算子用or,and !寫

,國內一般用|| && !。 
參考E文詳細的資料: 
[url=http://www.jboss.org/file-access/default/members/jbossaop/freezone/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/annotated.html 
]http://www.jboss.org/file-access/default/members/jbossaop/freezone/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/annotated.html[/url]http://www.jboss.org/file-access/default/members/jbossaop/freezone/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/pointcuts.html