论坛首页 Java企业应用论坛

幼学琼林-对比Spring 1.0与2.0的事务配置方式

浏览 29747 次
该帖已经被评为精华帖
作者 正文
   发表时间:2006-10-14  
很像我型我秀的得第一那个。呵呵
0 请登录后投票
   发表时间:2006-10-14  
感谢楼主的文章,最近没时间看spring2.0.
代码层面上 AspectJ 非常优雅,可惜 bytecode 却易常丑陋,
如果 pointcut 没有设计好的话,效率也会降低。
这东西是个双刃剑。
0 请登录后投票
   发表时间:2006-10-15  
江南白衣 写道
但是1.0大家都习惯了用TransactionProxyFactoryBean,这种BeanNameAutoProxyCreator定义的pattern只有bean names,很玩火的阿。

而aspectj有execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern) throws-pattern?),N多严格定义的地方。


1.0 中用 BeanNameAutoProxyCreator 加上 TransactionAttributeSource 的方法同样可以达到 2.0 这种简便程度, 但不需要 acpectj 增强,  可以参考  http://www.iteye.com/topic/19317

使用基本没有任何难度, reference 中的描述
引用

8.5.2. BeanNameAutoProxyCreator, another declarative approach

TransactionProxyFactoryBean is very useful, and gives you full control when wrapping objects with a transactional proxy. Used with parent/child bean definitions and inner beans holding the target, and when Java 5 Annotations are not available as an option, it is generally the best choice for transactional wrapping. In the case that you need to wrap a number of beans in a completely identical fashion (for example, a boilerplate, 'make all methods transactional', using a BeanFactoryPostProcessor called BeanNameAutoProxyCreator can offer an alternative approach which can end up being even less verbose for this simplified use case.

0 请登录后投票
   发表时间:2006-10-15  
使用beanNameAutoProxyCreator的确能够实现部分aop:config的操作!
但是advice,不能像2.0的aop那样做到配置简洁!
往往1.0做到AOP时要3个步骤:

定义代理->设置切入点->配置通知

而2.0简化了前2步,做到:

定义某类代理切入点->配置通知

最主要的是静态织入!

---- 感谢楼主总结 ----
0 请登录后投票
   发表时间:2006-10-15  
楼主啊,在哪能看到整本的幼学琼林
0 请登录后投票
   发表时间:2006-10-15  
那为前辈能否推荐几本关于spring的好书?出了spring in actioin(中文版)这本,发到我的邮箱里roc19832004@yahoo.com.cn
谢谢了!!!!!!!!!!!!!!!!
0 请登录后投票
   发表时间:2006-10-17  
我在 ss 项目中,学到的太多了
0 请登录后投票
   发表时间:2006-12-27  
恩,不错。
对比得较清晰,加深理解了。
0 请登录后投票
   发表时间:2006-12-27  
受用了,这段时间正在用2.0做东西
0 请登录后投票
   发表时间:2006-12-28  
ss 项目 那里可以看啊?
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics