<?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" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-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/context
http://www.springframework.org/schema/context/spring-context-2.0.xsd">
<!-- <bean class="com.common.processor.PrivilegetHandler"></bean>
-->
<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" />
<bean id="txManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction" ref="jotm"></property>
</bean>
<bean id="abstractTransactionProxy" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributeSource">
<bean
class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
</property>
</bean>
<bean id="abstractTmsSessionProxy" abstract="true">
<property name="sessionFactory" ref="tmsSessionFactory" />
</bean>
<bean id="abstractWmsSessionProxy" abstract="true">
<property name="sessionFactory" ref="wmsSessionFactory" />
</bean>
<bean id="abstractFmsSessionProxy" abstract="true">
<property name="sessionFactory" ref="fmsSessionFactory" />
</bean>
<!-- WMS data source -->
<bean id="innerDataSourceA" class="org.enhydra.jdbc.standard.StandardXADataSource"
destroy-method="shutdown">
<property name="transactionManager">
<ref local="jotm" />
</property>
<property name="driverName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://192.168.1.110:3306/test1?autoReconnect=true&zeroDateTimeBehavior=convertToNull&characterEncoding=utf-8</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<bean id="dataSourceA" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
destroy-method="shutdown">
<property name="dataSource">
<ref local="innerDataSourceA" />
</property>
<property name="transactionManager">
<ref local="jotm" />
</property>
<property name="maxSize">
<value>10</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<bean id="sessionFactoryA"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceA" />
<property name="mappingResources">
<list>
<value>com/systemmr/bean/hbm/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.springframework.orm.hibernate3.LocalTransactionManagerLookup</prop>
<prop key="jta.UserTransaction">java:comp/UserTransaction</prop>
</props>
</property>
<property name="jtaTransactionManager">
<ref bean="jotm" />
</property>
</bean>
<!--TMS data source -->
<bean id="innerDateSourceB" class="org.enhydra.jdbc.standard.StandardXADataSource"
destroy-method="shutdown">
<property name="transactionManager">
<ref local="jotm" />
</property>
<property name="driverName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://192.168.1.110:3306/test2?autoReconnect=true&zeroDateTimeBehavior=convertToNull&characterEncoding=utf-8</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<bean id="dataSourceB" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
destroy-method="shutdown">
<property name="dataSource">
<ref local="innerDateSourceB" />
</property>
<property name="transactionManager">
<ref local="jotm" />
</property>
<property name="maxSize">
<value>10</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<bean id="sessionFactoryB"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceB" />
<property name="mappingResources">
<list>
<value>com/systemmr/bean/hbm/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.springframework.orm.hibernate3.LocalTransactionManagerLookup</prop>
<prop key="jta.UserTransaction">java:comp/UserTransaction</prop>
</props>
</property>
<property name="jtaTransactionManager">
<ref bean="jotm" />
</property>
</bean>
<!-- 定义事务管理器,使用适用于Hibernte的事务管理器 -->
<!-- <bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
HibernateTransactionManager bean需要依赖注入一个SessionFactory bean的引用
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean> -->
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="txManager" />
<property name="transactionAttributes">
<props>
<!-- 其他方法,采用required的事务策略 -->
<!-- <prop key="insert*">PROPAGATION_REQUIRED</prop> -->
<!-- <prop key="update*">PROPAGATION_REQUIRED</prop> -->
<!-- <prop key="save*">PROPAGATION_REQUIRED</prop> -->
<!-- <prop key="add*">PROPAGATION_REQUIRED</prop> -->
<!-- <prop key="edit*">PROPAGATION_REQUIRED</prop> -->
<!-- <prop key="create*">PROPAGATION_REQUIRED</prop> -->
<!-- <prop key="delete*">PROPAGATION_REQUIRED</prop> -->
<!-- 所有以find开头的方法,采用required的事务策略,并且只读 -->
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="doQuery*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<value>*Service</value>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
<!-- 此处增加新的Interceptor -->
</list>
</property>
</bean>
<!-- 定义DAO bean的事务代理 -->
<!-- <bean id="personDao" -->
<!-- class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> -->
<!-- 为事务代理bean注入事务管理器 -->
<!-- <property name="transactionManager"> -->
<!-- <ref bean="transactionManager" /> -->
<!-- </property> -->
<!-- 设置事务属性 -->
<!-- <property name="transactionAttributes"> -->
<!-- <props> -->
<!-- 所有以find开头的方法,采用required的事务策略,并且只读 -->
<!-- <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> -->
<!-- <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> -->
<!-- <prop key="doQuery*">PROPAGATION_REQUIRED,readOnly</prop> -->
<!-- <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop> -->
<!-- <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop> -->
<!-- 其他方法,采用required的事务策略 -->
<!-- <prop key="*">PROPAGATION_REQUIRED</prop> -->
<!-- </props> -->
<!-- </property> -->
<!-- 为事务代理bean设置目标bean -->
<!-- <property name="target"> -->
<!-- <ref local="basicDao" /> -->
<!-- </property> -->
<!-- </bean> -->
<!-- Autowired -->
<bean
class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
<bean id="hibernateTemplateA" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactoryA" />
</property>
</bean>
<bean id="hibernateTemplateB" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactoryB" />
</property>
</bean>
<bean id="testUserService" class="com.systemmr.service.impl.TestUserServiceImpl">
<property name="hibernateTemplateA" ref="hibernateTemplateA"></property>
<property name="hibernateTemplateB" ref="hibernateTemplateB"></property>
</bean>
</beans>