聲明式事務,多個execution鏈接方法: java
expression="execution(* pp.business.*.*(..)) or execution(* pp.business.impl.*.*(..))"spring
spring的幫助手冊裏有關於execution的鏈接方式的一句話:express
Pointcut expressions can be combined using '&&', '||' and '!'..net
可是我寫上&&就會報錯。很鬱悶。。。code
||和or的做用相同:在符合* pp.business.*.*(..)和* pp.business.impl.*.*(..)方法上都加上事務性。xml
<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes > <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="insert*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <aop:config proxy-target-class="true"> <aop:pointcut id="allManagerMethod" expression="execution(* pp.business.*.*(..)) or execution(* pp.business.impl.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/> </aop:config>
在aspect中使用方法:事務
<aop:config> <aop:aspect id="myLogAspect" ref="logAspect"> <aop:pointcut id="logPointCut" expression="execution(* com.alimama.controller.*.*(..)) || execution(* com.alimama.service.IInstanceService.get*(..))"/> <aop:before method="logStart" pointcut-ref="logPointCut"/> <aop:after method="logEnd" pointcut-ref="logPointCut"/> </aop:aspect> </aop:config>