本文转自:http://www.micmiu.com/j2ee/jta/jta-atomikos-cfg-tx/
在以前的一篇详细介绍 Atomikos+spring实现JTA 的文章中是利用声明式事务配置,以共享同一个代理bean的方法实现事务配置,本文介绍下利用tx标签配置拦截器的方式实现事务配置:
3 | < bean id = "atomikosTransactionManager" class = "com.atomikos.icatch.jta.UserTransactionManager" |
4 | init-method = "init" destroy-method = "close" > |
7 | < property name = "forceShutdown" > |
13 | < bean id = "atomikosUserTransaction" class = "com.atomikos.icatch.jta.UserTransactionImp" > |
14 | < property name = "transactionTimeout" > |
20 | < bean id = "springJTATransactionManager" |
21 | class = "org.springframework.transaction.jta.JtaTransactionManager" > |
23 | < property name = "transactionManager" > |
24 | < ref bean = "atomikosTransactionManager" /> |
26 | < property name = "userTransaction" > |
27 | < ref bean = "atomikosUserTransaction" /> |
31 | < tx:annotation-driven transaction-manager = "springJTATransactionManager" |
32 | proxy-target-class = "true" /> |
34 | < tx:advice id = "txAdvice" transaction-manager = "springJTATransactionManager" > |
36 | < tx:method name = "save*" propagation = "REQUIRED" /> |
37 | < tx:method name = "update*" propagation = "REQUIRED" /> |
38 | < tx:method name = "transfer*" propagation = "REQUIRED" |
39 | rollback-for = "Exception" /> |
40 | < tx:method name = "*" read-only = "true" /> |
44 | < aop:pointcut id = "serviceOperation" |
45 | expression = "execution(* com.micmiu.jta.demo.service.UserAccountService.*(..))" /> |
46 | < aop:advisor advice-ref = "txAdvice" pointcut-ref = "serviceOperation" /> |
50 | < bean id = "userInfoDao" class = "com.micmiu.jta.demo.dao.UserInfoDaoImpl" > |
51 | < property name = "sessionFactory" ref = "sessionFactory1" /> |
53 | < bean id = "bankAccountDao" class = "com.micmiu.jta.demo.dao.BankAccountDaoImpl" > |
54 | < property name = "sessionFactory" ref = "sessionFactory2" /> |
57 | < bean id = "userAccountService" class = "com.micmiu.jta.demo.service.UserAccountServiceImpl" > |
58 | < property name = "userInfoDao" ref = "userInfoDao" /> |
59 | < property name = "bankAccountDao" ref = "bankAccountDao" /> |
本文介绍到此结束@Michael Sun.