• Spring xml中的tx:advice标签


    官方文档:

    The concept of "advisors" is brought forward from the AOP support defined in Spring and does not have a direct equivalent in AspectJ. An advisor is like a small self-contained aspect that has a single piece of advice. The advice itself is represented by a bean, and must implement one of the advice interfaces described in Advice types in Spring. Advisors can take advantage of AspectJ pointcut expressions though.

    Spring supports the advisor concept with the <aop:advisor> element. You will most commonly see it used in conjunction with transactional advice, which also has its own namespace support in Spring. Here’s how it looks:

    简言之:advisors的概念来至于Spring aop,但是advisor在aspectj中并没有用一个等价概念。advisor类似一个切面。

        <aop:config>
            <aop:advisor id="tx-advisor" advice-ref="tx-advice"
                         pointcut="execution(public * com.javartisan.sf.*.*(*))"/>
        </aop:config>
    
        <tx:advice id="tx-advice" transaction-manager="transactionManager">
            <tx:attributes>
                <tx:method name="save*" propagation="REQUIRED" timeout="20000" isolation="READ_COMMITTED"
                           rollback-for="java.lang.RuntimeException" no-rollback-for="com.javartisan.CustomException"
                           read-only="false"/>
                <tx:method name="del*" propagation="REQUIRED" timeout="20000" isolation="READ_COMMITTED"
                           rollback-for="java.lang.RuntimeException" no-rollback-for="com.javartisan.CustomException"
                           read-only="false"/>
            </tx:attributes>
        </tx:advice>
      
    

      

  • 相关阅读:
    708. Insert into a Cyclic Sorted List
    24. Swap Nodes in Pairs
    877. Stone Game
    EOJ Monthly 2020.7 A. 打字机(前缀和+思维)
    EOJ Monthly 2020.7 B. 线上考试(排列组合)
    【JavaScript】Generator
    【JavaScript】Promise
    【JavaScript】throw 和 try...catch
    【JavaScript】JSON
    【JavaScript】WeakSet
  • 原文地址:https://www.cnblogs.com/leodaxin/p/12216833.html
Copyright © 2020-2023  润新知