@Configuration @ConditionalOnClass(value=javax.sql.DataSource.class) @AutoConfigureBefore(value={org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration.class}) @Import(value=DataSourcesAutoConfigurationRegistrar.class) public class DataSourcesAutoConfiguration extends Object
DataSource
beans using holon.datasource.*
configuration properties.
This auto-configuration supports multiple DataSource registration using different data context id names. The data
context id of every DataSource to register must be specified right after holon.datasource.
and before
DataSourceConfigProperties
configuration properties. For example, to register two DataSources, bound to
one
and two
data context ids:
holon.datasource.one.url=...
holon.datasource.two.url=...
To every registered DataSource
bean is assigned a qualifier with the same name of the DataSource data context
id.
The actual DataSource
implementation to be used can be specified using a symbolic type name, specified
through the DataSourceConfigProperties.TYPE
configuration property. By default, the following types are
supported:
com.holonplatform.jdbc.BasicDataSource
: Create BasicDataSource
instances, to be used
typically for testing purposes. It is a simple DataSource implementation, using the DriverManager
class and returning a new Connection
from every getConnection
call.com.zaxxer.hikari.HikariDataSource
: Create HikariCP connection pooling DataSource instances. The
HikariCP library dependency must be available in classpath. All default configuration properties are supported, and
additional Hikari-specific configuration properties can be specified using the hikari
prefix before the
actual property name, for example: holon.datasource.hikari.connectionTimeout=50000
org.apache.commons.dbcp2.BasicDataSource
: Create DBCP2 connection pooling DataSource instances. The
Apache Commons DBCP 2 library dependency must be available in classpath. All default configuration properties are
supported, and additional DBCP-specific configuration properties can be specified using the dbcp
prefix
before the actual property name, for example: holon.datasource.dbcp.maxWaitMillis=3000
org.apache.tomcat.jdbc.pool.DataSource
: Create Tomcat JDBC connection pooling DataSource instances.
The tomcat-jdbc library dependency must be available in classpath. All default configuration properties are
supported, and additional Tomcat-specific configuration properties can be specified using the tomcat
prefix before the actual property name, for example: holon.datasource.tomcat.maxAge=5000
JNDI
: Obtain a DataSource using JNDI. The jndi-name
configuration property is required
to specify the JNDI name to which the DataSource is bound in the JNDI context.
When the DataSourceConfigProperties.TYPE
configuration property is not specified, the default DataSource type
selection strategy is defined as follows:
com.zaxxer.hikari.HikariDataSource
type will
be used;org.apache.commons.dbcp2.BasicDataSource
type will be used;org.apache.tomcat.jdbc.pool.DataSource
type will be used;com.holonplatform.jdbc.BasicDataSource
type is used as fallbackCopyright © 2020 The Holon Platform. All rights reserved.