spring 标签

 

<!-- 下面的是不涉及事务的 -->

 

<aop:config>

  <aop:aspect>

    <aop:pointcut  id="add"   expressio="(* com.test.shop.service.*.add*(..))"   / >

    <aop:pointcut   id="del"  expression="(* com.test.shop.service.*.del*(..))" / >

    <aop:before  method="addAdvice" pointcut-ref="add"    />

    <aop:after     method="delAdvice"  pointcut-ref="del"  />

  </aop:aspect>

</aop:config>

 

Aspect是advice方法的生存对象,advice作用到哪些类的哪些方法上,通过规则pointcut来规范,逻辑上来说,advice  ,pointcut应该在同一个对象上出现,这也是在采用注解时,Aspect位于类名上,pointcut在无意义方法上,而Before、After(即Advice)在真正要用的方法上。


 

<!-- 下面的是涉及事务的 -->

<tx:advice  transaction-manager="transactionManager">
  <tx:attributes>
    <tx:method name="" propagation="REQUIRED" />
    <tx:method name="" propagation="REQUIRED" />
  </tx:attributes>
</tx:advice>

<aop:config>

   <aop:pointcut expression="" id=""/>

   <aop:advisor advice-ref="" pointcut-ref=""/>

</aop:config>

涉及事务的指的是要调用transactionManager。

 

posted @ 2015-09-08 13:19  java资料收集  阅读(135)  评论(0编辑  收藏  举报