<?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:p="http://www.springframework.org/schema/p"
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/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">
<description>Spring公共配置文件</description>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:oracle:thin:@000.000.000.000:1521:test"/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
<property name="properties">
<ref bean="mesDatasourcePropertiesFactory" />
</property>
</bean>
<!-- c3p0数据源的一个专有属性,只可以存放密码和用户名 -->
<bean id="mesDatasourcePropertiesFactory" class="com.ccc.db.impl.DatasourcePropertiesFactory" factory-method="getProperties">
<!-- userName-->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<!-- password -->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<!-- 生产环境模式 ,才特殊处理加密密码-->
<constructor-arg type="java.lang.String">
<value>true</value>
</constructor-arg>
</bean>
<bean id="dataSourcePdm" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:oracle:thin:@000.000.000.000:1521:test"/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
<property name="properties">
<ref bean="ptcDatasourcePropertiesFactory" />
</property>
</bean>
<bean id="ptcDatasourcePropertiesFactory" class="com.ccc.db.impl.DatasourcePropertiesFactory" factory-method="getProperties">
<!-- userName-->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<!-- password -->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<constructor-arg type="java.lang.String">
<value>true</value>
</constructor-arg>
</bean>
<bean id="dataSourceProxy"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"
p:targetDataSource-ref="dataSource"/>
<!-- 对web包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能-->
<context:component-scan base-package="com.ccc,com.*"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"
p:order="0" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourceProxy"/>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<!-- mes API 使用的class -->
<aop:config>
<aop:pointcut id="allManagerMethodCCC" expression="execution(* com.test..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodCCC" advice-ref="txAdvice"/>
</aop:config>
<aop:config>
<aop:pointcut id="allManagerMethodETS" expression="execution(* com.test..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodETS" advice-ref="txAdvice"/>
</aop:config>
<bean id="transactionManagerPdm" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourcePdm"/>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvicePdm" transaction-manager="transactionManagerPdm">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allManagerMethodPdm" expression="execution(* com.test..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodPdm" advice-ref="txAdvicePdm"/>
</aop:config>
<!-- ibatis插件 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:dataSource-ref="dataSourceProxy">
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
<!-- 配置要拦截的url,防止2次提交或做其他數據統計用
<bean id="doubleSubmitInterceptor" class="com.ccc.filter.DoubleSubmitInterceptor">
<property name="mappingURL" value=".html" />
<property name="viewURL" value=".html" />
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" p:order="0">
<property name="interceptors">
<list>
<ref bean="doubleSubmitInterceptor"/>
</list>
</property>
</bean>
-->
<!-- JDBC template注入及事務配置 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource"><ref bean="dataSourceProxy"/></property>
</bean>
</beans>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
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/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">
<description>Spring公共配置文件</description>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:oracle:thin:@000.000.000.000:1521:test"/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
<property name="properties">
<ref bean="mesDatasourcePropertiesFactory" />
</property>
</bean>
<!-- c3p0数据源的一个专有属性,只可以存放密码和用户名 -->
<bean id="mesDatasourcePropertiesFactory" class="com.ccc.db.impl.DatasourcePropertiesFactory" factory-method="getProperties">
<!-- userName-->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<!-- password -->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<!-- 生产环境模式 ,才特殊处理加密密码-->
<constructor-arg type="java.lang.String">
<value>true</value>
</constructor-arg>
</bean>
<bean id="dataSourcePdm" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:oracle:thin:@000.000.000.000:1521:test"/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
<property name="properties">
<ref bean="ptcDatasourcePropertiesFactory" />
</property>
</bean>
<bean id="ptcDatasourcePropertiesFactory" class="com.ccc.db.impl.DatasourcePropertiesFactory" factory-method="getProperties">
<!-- userName-->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<!-- password -->
<constructor-arg type="java.lang.String">
<value>test</value>
</constructor-arg>
<constructor-arg type="java.lang.String">
<value>true</value>
</constructor-arg>
</bean>
<bean id="dataSourceProxy"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"
p:targetDataSource-ref="dataSource"/>
<!-- 对web包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能-->
<context:component-scan base-package="com.ccc,com.*"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"
p:order="0" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourceProxy"/>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<!-- mes API 使用的class -->
<aop:config>
<aop:pointcut id="allManagerMethodCCC" expression="execution(* com.test..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodCCC" advice-ref="txAdvice"/>
</aop:config>
<aop:config>
<aop:pointcut id="allManagerMethodETS" expression="execution(* com.test..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodETS" advice-ref="txAdvice"/>
</aop:config>
<bean id="transactionManagerPdm" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourcePdm"/>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvicePdm" transaction-manager="transactionManagerPdm">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allManagerMethodPdm" expression="execution(* com.test..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodPdm" advice-ref="txAdvicePdm"/>
</aop:config>
<!-- ibatis插件 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:dataSource-ref="dataSourceProxy">
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
<!-- 配置要拦截的url,防止2次提交或做其他數據統計用
<bean id="doubleSubmitInterceptor" class="com.ccc.filter.DoubleSubmitInterceptor">
<property name="mappingURL" value=".html" />
<property name="viewURL" value=".html" />
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" p:order="0">
<property name="interceptors">
<list>
<ref bean="doubleSubmitInterceptor"/>
</list>
</property>
</bean>
-->
<!-- JDBC template注入及事務配置 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource"><ref bean="dataSourceProxy"/></property>
</bean>
</beans>