Class UCPServiceConfigurationProvider

    • Method Detail

      • getPrefix

        public String getPrefix()
        Returns the prefix with which relevant property names will start.

        This method never returns null.

        Overrides of this method must not return null.

        The default implementation of this method returns javax.sql.DataSource.

        Undefined behavior will result if the return value of an override of this method is empty.

        Returns:
        the non-null prefix with which relevant property names will start
      • appliesTo

        protected boolean appliesTo​(Properties properties,
                                    System system,
                                    Properties coordinates)
        Returns true if this UCPServiceConfigurationProvider is relevant in the configuration space described by the supplied properties, System and coordinates.

        The default implementation of this method:

        1. Looks for a property named ucp.dataSourceNames. The value of this property is a comma-separated String whose components are names of data sources that will ultimately have Hikari connection pools set up for them.
        2. If that property is not found, then all property names found in the supplied properties, system and coordinates are scanned for those starting with javax.sql.DataSource., and for all names in that subset, the next period-separated component of the name is taken to be a data source name. For example, a property named javax.sql.DataSource.test.dataSourceClassName will yield a data source name of test.
        3. For each such data source name discovered, the installDataSourceProperties(Properties, System, Properties, String) method is called with the parameters supplied to this method and the data source name.
        4. After this installation step, a property named according to the following pattern is sought: javax.sql.DataSource.dataSourceName .dataSourceClassName.
        5. If that yields a class name and the corresponding class can be loaded, then true is returned.
        6. If that does not yield a class name, then a property named according to the following pattern is sought: javax.sql.DataSource.dataSourceName .jdbcUrl.
        7. If that yields a non-null String then it is passed to the DriverManager.getDriver(String) method. If that method invocation results in a non-null return value, then true is returned.
        8. In all other cases, false is returned.
        Parameters:
        properties - a Properties instance that may be used later by the create(Properties, System, Properties) method as the basis of a UCPServiceConfiguration implementation; must not be null
        system - a System determined to be in effect; may, strictly speaking, be null but ordinarily is non- null and enabled
        coordinates - a Properties instance representing the meta-properties in effect; may be null
        Returns:
        true if this UCPServiceConfigurationProvider applies to the configuration space implied by the supplied parameters; false otherwise
        Throws:
        NullPointerException - if properties is null
      • installDataSourceProperties

        protected void installDataSourceProperties​(Properties target,
                                                   System system,
                                                   Properties coordinates,
                                                   String dataSourceName)
        Installs any discoverable properties that might exist that pertain to the data source identified by the supplied dataSourceName into the supplied target Properties object, optionally using the supplied system and coordinates objects in the process.

        The default implementation of this method:

        1. Looks for a property named ucp. dataSourceName.propertiesPath. If it is found, then it will be converted to a Path via the Paths.get(String, String...) method.
        2. If the resulting Path identifies a readable file, then the file is read into a temporary Properties object via the Properties.load(Reader) method.
        3. target will now contain a property named javax.sql.DataSource.dataSourceName .explicitlyConfigured with a String value of true.
        4. Every property that the temporary Properties object contains as a result of reading the file will be added to target, prefixed with javax.sql.DataSource. dataSourceName..

        If the supplied dataSourceName is null or empty, or if the property being read out of the temporary Properties object already starts with javax.sql.DataSource., then it is copied into target without any prefix or modification.

        Parameters:
        target - the Properties into which data source properties will be installed; must not be null
        system - a System determined to be in effect; may, strictly speaking, be null but ordinarily is non- null and enabled
        coordinates - a Properties instance representing the meta-properties in effect; may be null
        dataSourceName - the name of the data source for which properties should be installed; may be null
        Throws:
        NullPointerException - if target is null
      • getDataSourceProperty

        protected final String getDataSourceProperty​(Properties properties,
                                                     System system,
                                                     Properties coordinates,
                                                     String dataSourceName,
                                                     String unprefixedPropertyName)
        Returns the value of a property found in the properties parameter value, or, failing that, in the supplied System's properties, or, failing that, in the supplied coordinates parameter value, that applies to the data source identified by the supplied dataSourceName parameter, taking into account the prefix.

        This method may return null.

        Parameters:
        properties - the Properties to check first; must not be null
        system - a System determined to be in effect; may, strictly speaking, be null but ordinarily is non- null and enabled
        coordinates - a Properties instance representing the meta-properties in effect; may be null
        dataSourceName - the name of a data source; may be null
        unprefixedPropertyName - the "simple" property name being sought; must not be null
        Returns:
        the value of the property, or null if no such property exists
        Throws:
        NullPointerException - if properties or unprefixedPropertyName is null