Class DatasourceConfiguration

java.lang.Object
org.apache.tomcat.jdbc.pool.PoolProperties
io.micronaut.configuration.jdbc.tomcat.DatasourceConfiguration
All Implemented Interfaces:
BasicJdbcConfiguration, Serializable, Cloneable, org.apache.tomcat.jdbc.pool.PoolConfiguration

@EachProperty(value="datasources", primary="default") public class DatasourceConfiguration extends org.apache.tomcat.jdbc.pool.PoolProperties implements BasicJdbcConfiguration
Allows the configuration of Tomcat JDBC data sources. All properties on PoolProperties 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 datasource will be configured based on the available drivers on the classpath.
Since:
1.0
Author:
James Kleeh
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.tomcat.jdbc.pool.PoolProperties

    org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition, org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty
  • Field Summary

    Fields inherited from class org.apache.tomcat.jdbc.pool.PoolProperties

    DEFAULT_MAX_ACTIVE, poolCounter

    Fields inherited from interface io.micronaut.jdbc.BasicJdbcConfiguration

    PREFIX

    Fields inherited from interface org.apache.tomcat.jdbc.pool.PoolConfiguration

    PKG_PREFIX
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Methods inherited from class org.apache.tomcat.jdbc.pool.PoolProperties

    clone, getAbandonWhenPercentageFull, getCommitOnReturn, getConnectionProperties, getDataSource, getDataSourceJNDI, getDbProperties, getDefaultAutoCommit, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getInitialSize, getInitSQL, getJdbcInterceptors, getJdbcInterceptorsAsArray, getLogValidationErrors, getMaxActive, getMaxAge, getMaxIdle, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getName, getNumTestsPerEvictionRun, getPoolCounter, getPoolName, getPropagateInterruptState, getProperties, getRemoveAbandonedTimeout, getRollbackOnReturn, getSuspectTimeout, getTimeBetweenEvictionRunsMillis, getUseDisposableConnectionFacade, getUseLock, getUseStatementFacade, getValidationInterval, getValidationQueryTimeout, getValidator, getValidatorClassName, isAccessToUnderlyingConnectionAllowed, isAlternateUsernameAllowed, isDefaultAutoCommit, isDefaultReadOnly, isFairQueue, isIgnoreExceptionOnPreLoad, isJmxEnabled, isLogAbandoned, isPoolSweeperEnabled, isRemoveAbandoned, isTestOnBorrow, isTestOnConnect, isTestOnReturn, isTestWhileIdle, isUseEquals, setAbandonWhenPercentageFull, setAccessToUnderlyingConnectionAllowed, setAlternateUsernameAllowed, setCommitOnReturn, setConnectionProperties, setDataSource, setDataSourceJNDI, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDriverClassName, setFairQueue, setIgnoreExceptionOnPreLoad, setInitialSize, setInitSQL, setJdbcInterceptors, setJmxEnabled, setLogAbandoned, setLogValidationErrors, setMaxActive, setMaxAge, setMaxIdle, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setName, setNumTestsPerEvictionRun, setPassword, setPropagateInterruptState, setRemoveAbandoned, setRemoveAbandonedTimeout, setRollbackOnReturn, setSuspectTimeout, setTestOnBorrow, setTestOnConnect, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setUrl, setUseDisposableConnectionFacade, setUseEquals, setUseLock, setUsername, setUseStatementFacade, setValidationInterval, setValidationQuery, setValidationQueryTimeout, setValidator, setValidatorClassName, toString

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.micronaut.jdbc.BasicJdbcConfiguration

    getName, setDriverClassName, setPassword, setUrl, setUsername
  • Constructor Details

    • DatasourceConfiguration

      public DatasourceConfiguration(@Parameter String name)
      Constructor.
      Parameters:
      name - name that comes from properties
  • Method Details

    • setDbProperties

      public void setDbProperties(@MapFormat(keyFormat=UNDER_SCORE_SEPARATED) Properties dbProperties)
      Specified by:
      setDbProperties in interface org.apache.tomcat.jdbc.pool.PoolConfiguration
      Overrides:
      setDbProperties in class org.apache.tomcat.jdbc.pool.PoolProperties
    • getDriverClassName

      public String getDriverClassName()
      Specified by:
      getDriverClassName in interface BasicJdbcConfiguration
      Specified by:
      getDriverClassName in interface org.apache.tomcat.jdbc.pool.PoolConfiguration
      Overrides:
      getDriverClassName in class org.apache.tomcat.jdbc.pool.PoolProperties
      Returns:
      The calculated driver class name
    • getConfiguredDriverClassName

      public String getConfiguredDriverClassName()
      Specified by:
      getConfiguredDriverClassName in interface BasicJdbcConfiguration
      Returns:
      The configured driver class name
    • getUrl

      public String getUrl()
      Specified by:
      getUrl in interface BasicJdbcConfiguration
      Specified by:
      getUrl in interface org.apache.tomcat.jdbc.pool.PoolConfiguration
      Overrides:
      getUrl in class org.apache.tomcat.jdbc.pool.PoolProperties
      Returns:
      The calculated URL
    • getConfiguredUrl

      public String getConfiguredUrl()
      Specified by:
      getConfiguredUrl in interface BasicJdbcConfiguration
      Returns:
      The configured URL
    • getUsername

      public String getUsername()
      Specified by:
      getUsername in interface BasicJdbcConfiguration
      Specified by:
      getUsername in interface org.apache.tomcat.jdbc.pool.PoolConfiguration
      Overrides:
      getUsername in class org.apache.tomcat.jdbc.pool.PoolProperties
      Returns:
      The calculated username
    • getConfiguredUsername

      public String getConfiguredUsername()
      Specified by:
      getConfiguredUsername in interface BasicJdbcConfiguration
      Returns:
      The configured username
    • getPassword

      public String getPassword()
      Specified by:
      getPassword in interface BasicJdbcConfiguration
      Specified by:
      getPassword in interface org.apache.tomcat.jdbc.pool.PoolConfiguration
      Overrides:
      getPassword in class org.apache.tomcat.jdbc.pool.PoolProperties
      Returns:
      The calculated password
    • getConfiguredPassword

      public String getConfiguredPassword()
      Specified by:
      getConfiguredPassword in interface BasicJdbcConfiguration
      Returns:
      The configured password
    • getValidationQuery

      public String getValidationQuery()
      Specified by:
      getValidationQuery in interface BasicJdbcConfiguration
      Specified by:
      getValidationQuery in interface org.apache.tomcat.jdbc.pool.PoolConfiguration
      Overrides:
      getValidationQuery in class org.apache.tomcat.jdbc.pool.PoolProperties
      Returns:
      The calculated validation query
    • setDataSourceProperties

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

      public String getConfiguredValidationQuery()
      Specified by:
      getConfiguredValidationQuery in interface BasicJdbcConfiguration
      Returns:
      The configured validation query
    • getJndiName

      public String getJndiName()
      Returns:
      The JNDI name
    • setJndiName

      public void setJndiName(String jndiName)
      Parameters:
      jndiName - Set the JDNI name