spring+atomikos+JTA完整例子


   
   
<? xml version="1.0" encoding="UTF-8" ?> <! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" > < beans default-autowire ="byName" > < bean id ="atomikosUserTransaction" class ="com.atomikos.icatch.jta.UserTransactionImp" > </ bean > < bean id ="atomikosTransactionManager" class ="com.atomikos.icatch.jta.UserTransactionManager" init-method ="init" destroy-method ="close" > <!-- when close is called, should we force transactions to terminate or not? --> < property name ="forceShutdown" >< value > true </ value ></ property > </ bean > < bean id ="txManager" class ="org.springframework.transaction.jta.JtaTransactionManager" > < property name ="transactionManager" >< ref bean ="atomikosTransactionManager" /></ property > < property name ="userTransaction" >< ref bean ="atomikosUserTransaction" /></ property > </ bean > < bean id ="auditDS" class ="com.atomikos.jdbc.AtomikosDataSourceBean" init-method ="init" destroy-method ="close" > < property name ="uniqueResourceName" >< value > mysql/cnaudit </ value ></ property > < property name ="xaDataSourceClassName" > < value > com.mysql.jdbc.jdbc2.optional.MysqlXADataSource </ value > </ property > < property name ="xaProperties" > < props > < prop key ="user" > XXX </ prop > < prop key ="password" > XXX </ prop > < prop key ="URL" > XXX </ prop > </ props > </ property > < property name ="poolSize" >< value > 50 </ value ></ property > </ bean > < bean id ="oracleDS" class ="com.atomikos.jdbc.AtomikosDataSourceBean" init-method ="init" destroy-method ="close" > < property name ="uniqueResourceName" >< value > oracle/cnaudit </ value ></ property > < property name ="xaDataSourceClassName" > < value > oracle.jdbc.xa.client.OracleXADataSource </ value > </ property > < property name ="xaProperties" > < props > < prop key ="user" > XXX </ prop > < prop key ="password" > XXX </ prop > < prop key ="URL" > XXX </ prop > </ props > </ property > </ bean > < bean id ="sqlMapClient" class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" > < property name ="configLocation" value ="classpath:ibatis/SqlMapConfig.xml" /> < property name ="dataSource" ref ="auditDS" /> </ bean > < bean id ="sqlMapClientTemplate" class ="org.springframework.orm.ibatis.SqlMapClientTemplate" /> < bean id ="oraSqlMapClient" class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" > < property name ="configLocation" value ="classpath:ibatis/SqlMapConfig-oracle.xml" /> < property name ="dataSource" ref ="oracleDS" /> </ bean > < bean id ="oraSqlMapClientTemplate" class ="org.springframework.orm.ibatis.SqlMapClientTemplate" > < property name ="sqlMapClient" ref ="oraSqlMapClient" /> </ bean > </ beans >

在配置一下事物管理,ok

   
   
<? xml version="1.0" encoding="UTF-8" ?> < beans xmlns ="http://www.springframework.org/schema/beans" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop ="http://www.springframework.org/schema/aop" xmlns:tx ="http://www.springframework.org/schema/tx" xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" default-autowire ="byName" default-lazy-init ="true" > <!-- 支持 @AspectJ 标记 --> < aop:aspectj-autoproxy /> < aop:config proxy-target-class ="true" > < aop:advisor pointcut ="execution(* *Facade.*(..))" advice-ref ="txAdvice" /> < aop:advisor pointcut ="execution(* *Manager.*(..))" advice-ref ="txAdvice" /> </ aop:config > < tx:advice id ="txAdvice" > < tx:attributes > < tx:method name ="get*" read-only ="true" /> < tx:method name ="find*" read-only ="true" /> < tx:method name ="has*" read-only ="true" /> < tx:method name ="locate*" read-only ="true" /> < tx:method name ="*" /> </ tx:attributes > </ tx:advice > </ beans >

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值