Spring JTA Transaction Configuration Jotm

Source: Internet
Author: User

JTA can use a transaction on multiple databases, WebLogic and other application servers provide JTA data source support, can be used directly. But Tomcat itself does not support this feature. If you want to use JTA on Tomcat, you must use a different tool. JOTM is a standalone component that can provide JTA functionality.


<?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>         <!--Specify the properties file used in the spring configuration          <bean id= "Propertyconfig"                  class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >             <property name= "Locations" >                 <list>                      <value>classpath:jdbc.properties</value>                 </list>            </ property>        </bean>            -->    <!-- jotm Instances  -->       <bean id= "Jotm"  class= "Org.springframework.transaction.jta.JotmFactoryBean" >             <property name= "DefaultTimeout " value=" 500000 "/>      </bean>         <!--&NBSP;JTA transaction manager  -->      <bean id= " Jtatransactionmanager " class=" Org.springframework.transaction.jta.JtaTransactionManager ">       &Nbsp;       <property name= "UserTransaction"  ref= "Jotm"  / >          </bean>         <!--  Data source 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"/>               &nbSp;    <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>          <!--  Data source 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>              <!--  Transaction facets configuration  -->        <aop:config>             <aop:pointcut id= "Pointcut"                    expression= "Execution (*&NBSP;COM.OUKU.JOTM. *.*(..))" />< all methods under!--  Package and its sub-packages &NBSP;--&GT;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBsp;   <aop:advisor pointcut-ref= "Pointcut"  advice-ref= "Txadvice"/>                        <aop:advisor pointcut= "Execution (* *. Ouku. Jotm.*.* (..)) "  advice-ref= "Txadvice"/>      </aop:config>           <!--  Notification configuration  -->         <tx:advice id= "Txadvice"  transaction-manager= "Jtatransactionmanager" >            <tx:attributes>               <tx:method name= "delete*"  rollback-for= " Exception "/&GT;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&LT;TX: Method name= "save*"  rollback-for= "Exception"/>&nbSp;             <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=" ></property>           "Sessionfactorya"    <property name= "Sessionfactoryb"  ref= "Sessionfactoryb" ></property>      </bean>        <bean id= " UserService "                 class= "Com.ouku.JOTM.biz.UserServiceImpl"  autowire= "ByName" >      </ Bean>    </beans>





This article is from the "bit accumulation" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1744796

Spring JTA Transaction Configuration Jotm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.