Spring JTA事务配置JOTM
来源:互联网 发布:广电网络倒闭 编辑:程序博客网 时间:2024/05/29 13:20
JTA可以在多个数据库上使用一个事务,weblogic等应用服务器提供了jta数据源的支持,可以直接被使用。但是tomcat本身并不支持这种特性。如果想在tomcat上使用jta就必须使用其它的工具。jotm就是一个独立的可以提供JTA功能的组件。
<?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:context="http://www.springframework.org/schema/context" 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.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <description>springJTA</description> <!--指定Spring配置中用到的属性文件 <bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> </bean> --> <!-- JOTM实例 --> <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"> <property name="defaultTimeout" value="500000"/> </bean> <!-- JTA事务管理器 --> <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="userTransaction" ref="jotm" /> </bean> <!-- 数据源A --> <bean id="dataSourceA" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown"> <property name="dataSource"> <bean class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown"> <property name="transactionManager" ref="jotm"/> <property name="driverName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/emp_mvc"/> </bean> </property> <property name="user" value="root"/> <property name="password" value="123456"/> </bean> <!-- 数据源B --> <bean id="dataSourceB" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown"> <property name="dataSource"> <bean class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown"> <property name="transactionManager" ref="jotm"/> <property name="driverName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/emp_mvc2"/> </bean> </property> <property name="user" value="root"/> <property name="password" value="123456"/> </bean> <bean id = "sessionFactoryA" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name = "dataSource" ref="dataSourceA"/> <property name="mappingResources"> <list> <value>com/ouku/JOTM/entity/Emp.hbm.xml</value> </list> </property> </bean> <bean id = "sessionFactoryB" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name = "dataSource" ref="dataSourceB"/> <property name="mappingResources"> <list> <value>com/ouku/JOTM/entity/Emp2.hbm.xml</value> </list> </property> </bean> <!-- 事务切面配置 --> <aop:config> <aop:pointcut id="pointCut" expression="execution(* com.ouku.JOTM..*.*(..))"/><!-- 包及其子包下的所有方法 --> <aop:advisor pointcut-ref="pointCut" advice-ref="txAdvice"/> <aop:advisor pointcut="execution(* *..ouku.JOTM.*.*(..))" advice-ref="txAdvice"/> </aop:config> <!-- 通知配置 --> <tx:advice id="txAdvice" transaction-manager="jtaTransactionManager"> <tx:attributes> <tx:method name="delete*" rollback-for="Exception"/> <tx:method name="save*" rollback-for="Exception"/> <tx:method name="update*" rollback-for="Exception"/> <tx:method name="find*" read-only="true" rollback-for="Exception"/> <tx:method name="*" read-only="true" rollback-for="Exception"/> </tx:attributes> </tx:advice> <bean id="genericDao" class="com.ouku.JOTM.DAO.GenericDaoImpl" autowire="byName"> <property name="sessionFactoryA" ref="sessionFactoryA"></property> <property name="sessionFactoryB" ref="sessionFactoryB"></property> </bean> <bean id="userService" class="com.ouku.JOTM.biz.UserServiceImpl" autowire="byName"> </bean> </beans>
本文出自 “点滴积累” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1744796
0 0
- Spring JTA事务配置JOTM
- Spring + hibernate + struts2 +jotm JTA事务
- Spring+iBatis+JOTM实现JTA事务
- Spring JTA应用之JOTM配置
- Spring JTA应用之JOTM配置
- JTA事务(Tomcat6+JOTM)
- Java事务(七) - 分布式事务 - spring + JTA + jotm
- 10005---Java事务(七) - 分布式事务 - spring + JTA + jotm
- Java事务(七) - 分布式事务 - spring + JTA + jotm
- java分布式事务1—— spring + JTA + jotm
- Spring JTA应用JOTM & Atomikos
- Spring JTA应用JOTM & Atomikos
- Spring JTA应用JOTM & Atomikos
- spring+hibernate+jotm分布式事务配置总结
- 分布式事务JTA 实现之 JOTM
- 分布式事务JTA实现之:SSM+JOTM
- ow2-jotm-dist + tomcat5.5+ mysql5.5 配置JDBC JTA事务
- JTA集成JOTM或Atomikos配置分布式事务(Tomcat应用服务器)
- eclipse导入myeclipse项目
- Struts2 <s:token>防止表单重复提交 %{}
- pyqt4文档阅读(10.1):QIntValidator-QDoubleValidator-QRegExpValidator
- J2EE中常见易混淆概念
- 轻松学习java可重入锁(ReentrantLock)的实现原理
- Spring JTA事务配置JOTM
- 递归的几个经典例子
- LinkedList模拟队列和堆栈
- Eclipse去除js错误
- solr查询语法
- Solr API例子详解
- url地址解码、保留小数点后面两位数字
- Ant自动化构建项目
- Count Primes