原文地址 http://lavasoft.blog.51cto.com/62575/172292
下面給出一個常見是示例:
<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* *..service*..*(..))"/>
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="delete*" rollback-for="Exception"/>
<tx:method name="save*" rollback-for="Exception"/>
<tx:method name="update*" rollback-for="Exception"/>
<tx:method name="*" read-only="true" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
這個還不夠細,如果要寫更爲詳細的控制,就需要研究AspectJ切點配置的語法了,其實研究這些標準,還不如拿幾個例子看看,解決實際問題就行了。就像寫正則表達式一樣,標準明擺着,要寫好卻不容易,從例子着手就能快速上手和領悟。