<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:jee="http://www.springframework.org/schema/jee" 
	xmlns:p="http://www.springframework.org/schema/p"
	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:cache="http://www.springframework.org/schema/cache"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
			http://www.springframework.org/schema/beans 
			http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
			http://www.springframework.org/schema/aop 
			http://www.springframework.org/schema/aop/spring-aop-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/jee 
			http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
			http://www.springframework.org/schema/tx 
			http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

	<description>Spring Config - DATABASE</description>
	
	<bean id="propertyConfigurer" class="com.tom.util.config.CustomPropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:config.properties</value>
			</list>
		</property>
	</bean>
	
	<context:component-scan base-package="com.tom">   
	    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
	</context:component-scan>  
	
	<!-- 数据源配置,使用应用内的C3P0数据库连接池 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" >
		<property name="driverClass" value="${jdbc.driver}" />
		<property name="jdbcUrl" value="${jdbc.url}" />
		<property name="user" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
		<property name="initialPoolSize" value="${jdbc.initialSize}" />
		<property name="minPoolSize" value="${jdbc.minPoolSize}" />
		<property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
		<property name="maxIdleTime" value="${jdbc.maxIdle}" />
		<property name="acquireIncrement" value="${jdbc.acquireIncrement}" />
		<property name="maxStatements" value="${jdbc.maxStatements}" />
		<property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}" />
		<property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}" />
		<property name="acquireRetryDelay" value="${jdbc.acquireRetryDelay}" />
		<property name="breakAfterAcquireFailure" value="${jdbc.breakAfterAcquireFailure}" />
		<property name="testConnectionOnCheckout" value="${jdbc.testConnectionOnCheckout}" />
		<property name="preferredTestQuery" value="${jdbc.preferredTestQuery}" />
	</bean>
	
	<!-- JDBCtemplate -->
	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
       <property name="dataSource"><ref bean="dataSource"/></property>
    </bean>
    
    <!-- JDBC事务管理器 -->
	<bean id="jdbcTransactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	
	<!-- 指定处理此数据的类   -->
	 <bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" abstract="false" lazy-init="true" autowire="default">
	 </bean>
	
	<!-- 1、编程式事务管理 -->
	<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
		<property name="transactionManager" ref="jdbcTransactionManager"></property>
	</bean>
	
	<!-- 2、注解形式的事务管理 -->
	<tx:annotation-driven transaction-manager="jdbcTransactionManager"/>
	
</beans>