关于Appfuse2.0框架的AOP的备注

本文探讨了AppFuse2.0框架中AOP事务控制的配置细节,特别是transaction-manager属性在Spring2.0环境下如何被隐式处理,并分析了这种处理方式可能带来的理解困难。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    今日项目中用到Appfuse2.0作为框架,对这个框架做了些分析。
    关于其他方面,就不多说了,网上资料比较全。但在分析AOP事务控制部分时,碰到一点小的疑惑:在applicationContext-service.xml中,advice配置如下:
    <tx:advice id="txAdvice">
        <tx:attributes>
            <!-- Read-only commented out to make things easier for end-users -->
            <!-- http://issues.appfuse.org/browse/APF-556 -->
            <!--tx:method name="get*" read-only="true"/-->
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>
    在<tx:advice id="txAdvice">中,为什么没有transaction-manager属性啊(在1.9中还有的)?advice是怎么知道用哪个transaction-manager来控制事务?
    查了spring2.0 reference(http://static.springframework.org/spring/docs/2.0.x/reference/transaction.html)以后才明白:Tip:
You can actually omit the 'transaction-manager' attribute in the transactional advice (<tx:advice/>) if the bean name of the PlatformTransactionManager that you want to wire in has the name 'transactionManager'. If the PlatformTransactionManager bean that you want to wire in has any other name, then you have to be explicit and use the 'transaction-manager' attribute as in the example above.
    原来transaction-manager名称是transactionManager(在applicationContext-dao.xml里面定义),在<tx:advice id="txAdvice">中就省略不写了。也算是spring2.0的新“特性”吧。
    个人认为这样虽然方便,但容易造成疑惑。就和autowire一样,省略的多了很可能带来理解上的困难。
    特此备注。
    AndyZ


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值