Class DatasourceConfiguration

  • All Implemented Interfaces:
    BasicJdbcConfiguration, java.lang.AutoCloseable, java.sql.Wrapper, javax.management.MBeanRegistration, javax.sql.CommonDataSource, javax.sql.DataSource, org.apache.commons.dbcp2.BasicDataSourceMXBean, org.apache.commons.dbcp2.DataSourceMXBean

    @Context
    @EachProperty(value="datasources",
                  primary="default")
    public class DatasourceConfiguration
    extends org.apache.commons.dbcp2.BasicDataSource
    implements BasicJdbcConfiguration
    Allows the configuration of Apache DBCP JDBC data sources. All properties on BasicDataSource are available to be configured. If the url, driver class, username, or password are missing, sensible defaults will be provided when possible. If no configuration beyond the datasource name is provided, an in memory datastore will be configured based on the available drivers on the classpath.
    Since:
    1.0
    Author:
    James Kleeh
    • Constructor Summary

      Constructors 
      Constructor Description
      DatasourceConfiguration​(java.lang.String name)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getConfiguredDriverClassName()  
      java.lang.String getConfiguredPassword()  
      java.lang.String getConfiguredUrl()  
      java.lang.String getConfiguredUsername()  
      java.lang.String getConfiguredValidationQuery()  
      java.lang.String getDriverClassName()  
      java.lang.String getName()
      Get the name of the bean.
      java.lang.String getPassword()  
      java.lang.String getUrl()  
      java.lang.String getUsername()  
      java.lang.String getValidationQuery()  
      void setDataSourceProperties​(java.util.Map<java.lang.String,​?> dsProperties)
      Sets the datasource properties.
      • Methods inherited from class org.apache.commons.dbcp2.BasicDataSource

        addConnectionProperty, close, createConnectionFactory, createConnectionPool, createDataSource, createDataSourceInstance, createObjectPool, createPoolableConnectionFactory, evict, getAbandonedLogWriter, getAbandonedUsageTracking, getAutoCommitOnReturn, getCacheState, getConnection, getConnection, getConnectionFactoryClassName, getConnectionInitSqls, getConnectionInitSqlsAsArray, getConnectionPool, getDefaultAutoCommit, getDefaultCatalog, getDefaultQueryTimeout, getDefaultReadOnly, getDefaultSchema, getDefaultTransactionIsolation, getDisconnectionSqlCodes, getDisconnectionSqlCodesAsArray, getDriver, getDriverClassLoader, getEnableAutoCommitOnReturn, getEvictionPolicyClassName, getFastFailValidation, getInitialSize, getJmxName, getLifo, getLogAbandoned, getLogExpiredConnections, getLoginTimeout, getLogWriter, getMaxConnLifetimeMillis, getMaxIdle, getMaxOpenPreparedStatements, getMaxTotal, getMaxWaitMillis, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getParentLogger, getRegisteredJmxName, getRemoveAbandonedOnBorrow, getRemoveAbandonedOnMaintenance, getRemoveAbandonedTimeout, getRollbackOnReturn, getSoftMinEvictableIdleTimeMillis, getTestOnBorrow, getTestOnCreate, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getValidationQueryTimeout, invalidateConnection, isAccessToUnderlyingConnectionAllowed, isClearStatementPoolOnReturn, isClosed, isPoolPreparedStatements, isWrapperFor, log, log, postDeregister, postRegister, preDeregister, preRegister, removeConnectionProperty, restart, setAbandonedLogWriter, setAbandonedUsageTracking, setAccessToUnderlyingConnectionAllowed, setAutoCommitOnReturn, setCacheState, setClearStatementPoolOnReturn, setConnectionFactoryClassName, setConnectionInitSqls, setConnectionProperties, setDefaultAutoCommit, setDefaultCatalog, setDefaultQueryTimeout, setDefaultReadOnly, setDefaultSchema, setDefaultTransactionIsolation, setDisconnectionSqlCodes, setDriver, setDriverClassLoader, setDriverClassName, setEnableAutoCommitOnReturn, setEvictionPolicyClassName, setFastFailValidation, setInitialSize, setJmxName, setLifo, setLogAbandoned, setLogExpiredConnections, setLoginTimeout, setLogWriter, setMaxConnLifetimeMillis, setMaxIdle, setMaxOpenPreparedStatements, setMaxTotal, setMaxWaitMillis, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setPassword, setPoolPreparedStatements, setRemoveAbandonedOnBorrow, setRemoveAbandonedOnMaintenance, setRemoveAbandonedTimeout, setRollbackOnReturn, setSoftMinEvictableIdleTimeMillis, setTestOnBorrow, setTestOnCreate, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setUrl, setUsername, setValidationQuery, setValidationQueryTimeout, start, startPoolMaintenance, unwrap, validateConnectionFactory
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.sql.CommonDataSource

        createShardingKeyBuilder
      • Methods inherited from interface javax.sql.DataSource

        createConnectionBuilder
    • Constructor Detail

      • DatasourceConfiguration

        public DatasourceConfiguration​(@Parameter
                                       java.lang.String name)
        Constructor.
        Parameters:
        name - name configured from properties
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the name of the bean.
        Specified by:
        getName in interface BasicJdbcConfiguration
        Returns:
        name
      • getDriverClassName

        public java.lang.String getDriverClassName()
        Specified by:
        getDriverClassName in interface BasicJdbcConfiguration
        Specified by:
        getDriverClassName in interface org.apache.commons.dbcp2.DataSourceMXBean
        Overrides:
        getDriverClassName in class org.apache.commons.dbcp2.BasicDataSource
        Returns:
        The driver class name to be used by the data source
      • getUrl

        public java.lang.String getUrl()
        Specified by:
        getUrl in interface BasicJdbcConfiguration
        Specified by:
        getUrl in interface org.apache.commons.dbcp2.DataSourceMXBean
        Overrides:
        getUrl in class org.apache.commons.dbcp2.BasicDataSource
        Returns:
        The URL to be used by the data source
      • getUsername

        public java.lang.String getUsername()
        Specified by:
        getUsername in interface BasicJdbcConfiguration
        Specified by:
        getUsername in interface org.apache.commons.dbcp2.DataSourceMXBean
        Overrides:
        getUsername in class org.apache.commons.dbcp2.BasicDataSource
        Returns:
        The username to be used by the data source
      • getPassword

        public java.lang.String getPassword()
        Specified by:
        getPassword in interface org.apache.commons.dbcp2.BasicDataSourceMXBean
        Specified by:
        getPassword in interface BasicJdbcConfiguration
        Overrides:
        getPassword in class org.apache.commons.dbcp2.BasicDataSource
        Returns:
        The password to be used by the data source
      • getValidationQuery

        public java.lang.String getValidationQuery()
        Specified by:
        getValidationQuery in interface BasicJdbcConfiguration
        Specified by:
        getValidationQuery in interface org.apache.commons.dbcp2.DataSourceMXBean
        Overrides:
        getValidationQuery in class org.apache.commons.dbcp2.BasicDataSource
        Returns:
        The validation query to be used by the data source
      • setDataSourceProperties

        public void setDataSourceProperties​(@MapFormat(transformation=FLAT,keyFormat=RAW)
                                            java.util.Map<java.lang.String,​?> dsProperties)
        Description copied from interface: BasicJdbcConfiguration
        Sets the datasource properties.
        Specified by:
        setDataSourceProperties in interface BasicJdbcConfiguration
        Parameters:
        dsProperties - The properties