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

    今日项目中用到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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值