All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spring.data-source.xml Maven / Gradle / Ivy

The newest version!
<?xml version="1.0" encoding="UTF-8" ?>
<!--
    Cloud Foundry
    Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.

    This product is licensed to you under the Apache License, Version 2.0 (the "License").
    You may not use this product except in compliance with the License.

    This product includes a number of subcomponents with
    separate copyright notices and license terms. Your use of these
    subcomponents is subject to the terms and conditions of the
    subcomponent's license, as noted in the LICENSE file.

-->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://www.springframework.org/schema/beans"
       xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

    <bean id="databaseUrlModifier" class="org.cloudfoundry.identity.uaa.db.DatabaseUrlModifier">
        <constructor-arg name="databaseType" value="#{@platform}"/>
        <constructor-arg name="url" value="${database.url}"/>
        <property name="connectTimeoutSeconds" value="${database.connecttimeout:10}"/>
    </bean>

    <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
        <property name="driverClassName" value="${database.driverClassName}" />
        <property name="url" value="#{@databaseUrlModifier.getUrl()}" />
        <property name="username" value="${database.username}" />
        <property name="password" value="${database.password}" />
        <property name="validationInterval" value="5000" />
        <property name="validationQuery" value="#{@validationQuery}" />
        <property name="testOnBorrow" value="true" />
        <property name="minIdle" value="${database.minidle:0}"/>
        <property name="maxActive" value="${database.maxactive:100}"/>
        <property name="maxIdle" value="${database.maxidle:10}"/>
        <property name="initialSize" value="${database.initialsize:10}"/>
        <property name="validationQueryTimeout" value="${database.validationquerytimeout:10}"/>
        <property name="removeAbandoned" value="${database.removeabandoned:false}"/>
        <property name="logAbandoned" value="${database.logabandoned:true}"/>
        <property name="removeAbandonedTimeout" value="${database.abandonedtimeout:300}"/>
        <property name="timeBetweenEvictionRunsMillis" value="${database.evictionintervalms:15000}"/>
        <property name="jdbcInterceptors" value="org.cloudfoundry.identity.uaa.metrics.QueryFilter(threshold=3000)"/>
    </bean>

    <bean id="dataSourceAccessor" class="org.cloudfoundry.identity.uaa.db.DataSourceAccessor" depends-on="dataSource">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate" depends-on="dataSourceAccessor">
        <property name="baselineOnMigrate" value="true" />
        <property name="dataSource" ref="dataSource" />
        <property name="locations" value="classpath:org/cloudfoundry/identity/uaa/db/#{@scripts}/" />
        <property name="baselineVersion">
            <bean class="org.flywaydb.core.api.MigrationVersion" factory-method="fromVersion">
                <constructor-arg value="#{@scriptsversion}"/>
            </bean>
        </property>
        <property name="target">
            <bean class="org.flywaydb.core.api.MigrationVersion" factory-method="fromVersion">
                <constructor-arg value="${db.target:9223372036854775807}"/>
            </bean>
        </property>
        <property name="validateOnMigrate" value="false"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>

    <bean class="org.springframework.jmx.export.MBeanExporter">
        <property name="server" ref="mbeanServer" />
        <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING" />
        <property name="beans">
            <map>
                <entry key="spring.application:type=DataSource,name=dataSource" value-ref="dataSource" />
            </map>
        </property>
        <property name="assembler">
            <bean class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler">
                <property name="methodMappings">
                    <map>
                        <entry key="spring.application:type=DataSource,name=dataSource" value="getMaxIdle,getMaxActive,getNumIdle,getNumActive" />
                    </map>
                </property>
            </bean>
        </property>
    </bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" depends-on="flyway">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="jdbcPagingListFactory" class="org.cloudfoundry.identity.uaa.resources.jdbc.JdbcPagingListFactory">
        <constructor-arg ref="jdbcTemplate" />
        <constructor-arg ref="limitSqlAdapter" />
    </bean>

    <bean id="useCaseInsensitiveQueries" class="java.lang.Boolean" factory-method="valueOf">
        <constructor-arg value="#{ (@platform eq 'mysql' and '${database.caseinsensitive:true}') ? true : '${database.caseinsensitive:false}'}"/>
    </bean>
</beans>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy