<?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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
	<!--数据库管理-连接信息的配置文件加载 -->
	<bean id="propertyConfig"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="classpath:/dbconfig.properties" />
	</bean>
	
	
<!-- 	<bean id="bonecpConfig"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="location" value="classpath:/bonecpconfig.properties" />
	</bean>
	数据库管理-数据源3定义(BoneCP连接池)
	<bean id="poolDataSource" class="com.jolbox.bonecp.BoneCPDataSource" >
		<property name="driverClass" value="${jdbc.driver}" /> 
  		<property name="jdbcUrl" value="${jdbc.url}" /> 
  		<property name="username" value="${jdbc.username}" /> 
  		<property name="password" value="${jdbc.password}" /> 
  		<property name="properties" ref="bonecpConfig"></property>
	</bean> -->
	
	
	<bean id="poolDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">  
        <property name="url" value="${jdbc.url}" /> 
        <property name="username" value="${jdbc.username}" /> 
        <property name="password" value="${jdbc.password}" /> 
        <property name="driverClassName" value="${jdbc.driver}" /> 
        <property name="filters" value="stat" />  
  
        <property name="maxActive" value="100" />
        <property name="initialSize" value="1" />
        <property name="maxWait" value="60000" />
  
        <property name="timeBetweenEvictionRunsMillis" value="60000" />  
        <property name="minEvictableIdleTimeMillis" value="300000" />  
  
        <property name="validationQuery" value="SELECT 'x' FROM DUAL" />  
        <property name="testWhileIdle" value="true" />  
        <property name="testOnBorrow" value="false" />  
        <property name="testOnReturn" value="false" />  
        <property name="maxOpenPreparedStatements" value="100" />
    </bean>

    <bean id="secondaryDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
        <property name="url" value="${jdbc.secondary.url}" />
        <property name="username" value="${jdbc.secondary.username}" />
        <property name="password" value="${jdbc.secondary.password}" />
        <property name="driverClassName" value="${jdbc.secondary.driver}" />
        <property name="filters" value="stat" />

        <property name="maxActive" value="100" />
        <property name="initialSize" value="1" />
        <property name="maxWait" value="60000" />
        <property name="timeBetweenEvictionRunsMillis" value="60000" />
        <property name="minEvictableIdleTimeMillis" value="300000" />

        <property name="validationQuery" value="SELECT 'x' FROM DUAL" />
        <property name="testWhileIdle" value="true" />
        <property name="testOnBorrow" value="false" />
        <property name="testOnReturn" value="false" />
        <property name="maxOpenPreparedStatements" value="100" />
    </bean>

    <bean id="dataSource" class="com.rtrh.projects.web.util.DynamicDataSource">
        <property name="targetDataSources">
            <map>
                <entry key="primary" value-ref="poolDataSource" />
                <entry key="secondary" value-ref="secondaryDataSource" />
            </map>
        </property>
        <property name="defaultTargetDataSource" ref="poolDataSource" />
    </bean>


</beans>