Class DatasourceConfiguration

  • All Implemented Interfaces:
    com.zaxxer.hikari.HikariConfigMXBean, BasicJdbcConfiguration

    @EachProperty(value="datasources",
                  primary="default")
    public class DatasourceConfiguration
    extends com.zaxxer.hikari.HikariConfig
    implements BasicJdbcConfiguration
    Allows the configuration of Hikari JDBC data sources. All properties on HikariConfig 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 Deprecated 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 getJndiName()
      Get Jndi name.
      java.lang.String getName()  
      java.lang.String getPassword()  
      java.lang.String getUrl()  
      java.lang.String getUsername()  
      java.lang.String getValidationQuery()  
      boolean isAutomaticValidationQuery()  
      void setAutomaticValidationQuery​(boolean automaticValidationQuery)
      Set to true if the validation query should be set with an appropriate default value if not set manually.
      void setDataSourceProperties​(java.util.Map<java.lang.String,​?> dsProperties)
      Sets the data source properties.
      void setDataSourceProperties​(java.util.Properties dsProperties)
      Deprecated.
      void setJndiName​(java.lang.String jndiName)
      Setter.
      void setUrl​(java.lang.String url)
      Setter.
      void setValidationQuery​(java.lang.String validationQuery)
      Setter.
      • Methods inherited from class com.zaxxer.hikari.HikariConfig

        addDataSourceProperty, addHealthCheckProperty, copyStateTo, getCatalog, getConnectionInitSql, getConnectionTestQuery, getConnectionTimeout, getDataSource, getDataSourceClassName, getDataSourceJNDI, getDataSourceProperties, getExceptionOverrideClassName, getHealthCheckProperties, getHealthCheckRegistry, getIdleTimeout, getInitializationFailTimeout, getJdbcUrl, getKeepaliveTime, getLeakDetectionThreshold, getMaximumPoolSize, getMaxLifetime, getMetricRegistry, getMetricsTrackerFactory, getMinimumIdle, getPoolName, getScheduledExecutor, getSchema, getThreadFactory, getTransactionIsolation, getValidationTimeout, isAllowPoolSuspension, isAutoCommit, isIsolateInternalQueries, isReadOnly, isRegisterMbeans, setAllowPoolSuspension, setAutoCommit, setCatalog, setConnectionInitSql, setConnectionTestQuery, setConnectionTimeout, setDataSource, setDataSourceClassName, setDataSourceJNDI, setDriverClassName, setExceptionOverrideClassName, setHealthCheckProperties, setHealthCheckRegistry, setIdleTimeout, setInitializationFailTimeout, setIsolateInternalQueries, setJdbcUrl, setKeepaliveTime, setLeakDetectionThreshold, setMaximumPoolSize, setMaxLifetime, setMetricRegistry, setMetricsTrackerFactory, setMinimumIdle, setPassword, setPoolName, setReadOnly, setRegisterMbeans, setScheduledExecutor, setSchema, setThreadFactory, setTransactionIsolation, setUsername, setValidationTimeout, validate
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DatasourceConfiguration

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

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface BasicJdbcConfiguration
        Returns:
        A user provided name to identify the datasource
      • getUrl

        public java.lang.String getUrl()
        Specified by:
        getUrl in interface BasicJdbcConfiguration
        Returns:
        The URL to be used by the data source
      • setUrl

        public void setUrl​(java.lang.String url)
        Setter.
        Specified by:
        setUrl in interface BasicJdbcConfiguration
        Parameters:
        url - url of connection
      • getDriverClassName

        public java.lang.String getDriverClassName()
        Specified by:
        getDriverClassName in interface BasicJdbcConfiguration
        Overrides:
        getDriverClassName in class com.zaxxer.hikari.HikariConfig
        Returns:
        The driver class name to be used by the data source
      • getUsername

        public java.lang.String getUsername()
        Specified by:
        getUsername in interface BasicJdbcConfiguration
        Overrides:
        getUsername in class com.zaxxer.hikari.HikariConfig
        Returns:
        The username to be used by the data source
      • getPassword

        public java.lang.String getPassword()
        Specified by:
        getPassword in interface BasicJdbcConfiguration
        Overrides:
        getPassword in class com.zaxxer.hikari.HikariConfig
        Returns:
        The password to be used by the data source
      • setValidationQuery

        public void setValidationQuery​(java.lang.String validationQuery)
        Setter.
        Parameters:
        validationQuery - string of query
      • getJndiName

        public java.lang.String getJndiName()
        Get Jndi name.
        Returns:
        jndiName
      • setJndiName

        public void setJndiName​(java.lang.String jndiName)
        Setter.
        Parameters:
        jndiName - jndi name
      • setDataSourceProperties

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

        @Deprecated
        public void setDataSourceProperties​(java.util.Properties dsProperties)
        Deprecated.
        Overrides:
        setDataSourceProperties in class com.zaxxer.hikari.HikariConfig
        Parameters:
        dsProperties - The data source properties
      • isAutomaticValidationQuery

        public boolean isAutomaticValidationQuery()
        Returns:
        True if the validation query should be set automatically
      • setAutomaticValidationQuery

        public void setAutomaticValidationQuery​(boolean automaticValidationQuery)
        Set to true if the validation query should be set with an appropriate default value if not set manually.
        Parameters:
        automaticValidationQuery - Whether to auto set the validation query