Class DatasourceConfiguration

  • All Implemented Interfaces:
    BasicJdbcConfiguration, AutoCloseable, Wrapper, MBeanRegistration, CommonDataSource, 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String getConfiguredDriverClassName()  
      String getConfiguredPassword()  
      String getConfiguredUrl()  
      String getConfiguredUsername()  
      String getConfiguredValidationQuery()  
      String getDriverClassName()  
      String getName()
      Get the name of the bean.
      String getPassword()  
      String getUrl()  
      String getUsername()  
      String getValidationQuery()  
      void setDataSourceProperties​(Map<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
    • Constructor Detail

      • DatasourceConfiguration

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

      • getDriverClassName

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