com.holonplatform.jdbc.spring.boot

## Class DataSourcesAutoConfiguration

- java.lang.Object
- - com.holonplatform.jdbc.spring.boot.DataSourcesAutoConfiguration

-     @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

  Spring boot auto-configuration to register `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:

  1. If the HikariCP dependecy is present in classpath, the `com.zaxxer.hikari.HikariDataSource` type will be used;
  2. If the Apache Commons DBCP2 dependecy is present in classpath, the `org.apache.commons.dbcp2.BasicDataSource` type will be used;
  3. If the Tomcat JDBC dependecy is present in classpath, the `org.apache.tomcat.jdbc.pool.DataSource` type will be used;
  4. Otherwise, the `com.holonplatform.jdbc.BasicDataSource` type is used as fallback
  Since:
    5.0.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataSourcesAutoConfiguration()`

  - ### Method Summary

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DataSourcesAutoConfiguration

          public DataSourcesAutoConfiguration()

Copyright © 2019 The Holon Platform. All rights reserved.