zoukankan      html  css  js  c++  java
  • Spring AOP Interceptor transaction is not working

    Problem

    The Spring AOP transaction is not working in following interceptors?

     <bean id="testAutoProxyCreator"
        class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    	<property name="interceptorNames">
    		<list>
    			<idref bean="urlInterceptorInsert" />
    			<idref bean="urlInterceptorCommit" />
    			<idref bean="urlInterceptorRelease" />
    			<idref bean="matchGenericTxInterceptor" />
    		</list>
    	</property>
    	<property name="beanNames">
    		<list>
    			<idref local="urlBo" />
    		</list>
    	</property>
    </bean>
    

    The “matchGenericTxInterceptor” transaction interceptor, suppose to intercept urlInterceptorInsert, urlInterceptorCommit,urlInterceptorRelease, but it’s not work as expected?

    Solution

    The 3 interceptors are executed before transaction manager interceptor (matchGenericTxInterceptor).

    To fix it, you have to change the sequence of the interceptor xml file like following (put matchGenericTxInterceptor on top).

     <bean id="testAutoProxyCreator"
            class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    	<property name="interceptorNames">
    		<list>
                            <idref bean="matchGenericTxInterceptor" />
    			<idref bean="urlInterceptorInsert" />
    			<idref bean="urlInterceptorCommit" />
    			<idref bean="urlInterceptorRelease" />
    		</list>
    	</property>
    	<property name="beanNames">
    		<list>
    			<idref local="urlBo" />
    		</list>
    	</property>
    </bean>
    

    Note
    The sequence of Spring AOP interceptors do affect the functionality.

  • 相关阅读:
    win7开启Administrator账户
    二叉树遍历
    使用NAnt提高工作效率(二)
    系统服务的最简单实现
    右键附加启动命令行
    C#开发奇技淫巧二:根据dll文件加载C++或者Delphi插件
    百度原CTO李一男经典语录
    Sql开发技巧
    使用NAnt提高工作效率(一)
    对获取config文件的appSettings节点简单封装
  • 原文地址:https://www.cnblogs.com/ghgyj/p/4751819.html
Copyright © 2011-2022 走看看