<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"
default-lazy-init="true">
<description>COMMON::WEB Spring Configuration</description>
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="com.runchain.joying,com.runchain.arch" />
<!-- oracle 数据源 -->
<bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close"
lazy-init="true">
<property name="uniqueResourceName">
<value>OracleXADataSource</value>
</property>
<property name="xaDataSourceClassName">
<value>oracle.jdbc.xa.client.OracleXADataSource</value>
</property>
<property name="xaProperties">
<props>
<prop key="URL">${jdbc.url}</prop>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
<property name="poolSize" value="1" />
<property name="maxPoolSize" value="30" />
<property name="testQuery" value="select 1 from dual" />
</bean>
<!-- sqlserver 数据源 -->
<bean id="dataSourceMssql" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close"
lazy-init="true">
<property name="uniqueResourceName">
<value>MssqlXADataSource</value>
</property>
<property name="xaDataSourceClassName">
<value>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</value>
</property>
<property name="xaProperties">
<props>
<prop key="URL">${mssql.jdbc.url}</prop>
<prop key="user">${mssql.jdbc.username}</prop>
<prop key="password">${mssql.jdbc.password}</prop>
</props>
</property>
<property name="poolSize" value="1" />
<property name="maxPoolSize" value="30" />
<property name="testQuery" value="select 1" />
</bean>
<!-- Hibernate配置 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache/ehcache-hibernate-local.xml</prop>
</props>
</property>
<property name="packagesToScan" value="${entities.packagesToScan}" />
</bean>
<!-- sqlserver session factory -->
<bean id="sessionFactoryMssql" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSourceMssql" />
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<!-- org.hibernate.dialect.SQLServerDialect 方言 -->
<props>
<prop key="hibernate.dialect">${mssql.hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${mssql.hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${mssql.hibernate.format_sql}</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
</props>
</property>
<property name="packagesToScan" value="com.runchain.arch.entity.checking" />
</bean>
<!-- 注入SpringContextHolder -->
<bean class="org.springside.modules.utils.spring.SpringContextHolder" lazy-init="false"></bean>
<!-- 事务管理器配置,单数据源事务 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" /> </bean> -->
<!-- 事务管理器配置,多数据源JTA事务 -->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init"
destroy-method="close">
<property name="forceShutdown">
<value>true</value>
</property>
<property name="startupTransactionService" value="true" />
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="300" />
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="userTransaction" ref="atomikosUserTransaction" />
</bean>
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
</beans>