Class PropertyProvider

java.lang.Object
de.aristaflow.adept2.base.configuration.PropertyProvider
Direct Known Subclasses:
ConfigurationPropertyProvider

public abstract class PropertyProvider extends Object
This class provides global properties that are needed for the whole AristaFlow-platform. These properties are needed for initialising the configuration framework which is why they are parsed very early when bootstrapping. This also includes global properties (starting with arflow.confVar) which will be injected into the configuration framework allowing to reference this properties in service configurations.
This interface encapsulates the concrete representation of the global properties. For instance, these may stem from the system properties or from a servlet context, depending on the execution context of the AristaFlow-platform.

This class may be extended to reflect specific requirements (that is specific global properties) needed by a configuration manager.

This class parses the following properties from the designated map (in parentheses the default value that will apply if the property is not set):

  • arflow.logdir (default: ./logs, referring either to the current or user home directory, the one which can be written)
  • arflow.datadir (default: ./data, referring either to the current or user home directory, the one which can be read)
  • arflow.libdir (default: ./lib, referring either to the current or user home directory, the one which can be written)
  • arflow.useSunSecProvider (default: false)
  • arflow.totalMemPerthousandStreamThreshold (default: 40)
  • arflow.skipClosing (default: false)
  • arflow.confVar.*
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final Map<String,List<String>>
    The property names for retrieving the base directories which are the program/installation directory and the user home/workspace directory.
    protected final Logger
    The logger for property providers.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new PropertyProvider and parses all corresponding global properties from the designated map and/or sets the properties appropriately.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static List<File>
    Gets the base directories which are used as parents for the default directories for configuration, logs, libraries and data.
    Usually the first one is the directory providing the running application (osgi.install.area or user.dir), the second one is a subdirectory of the user home (osgi.instance.area or user.home/.<companyname>/<applicationname>).
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Do only use if absolutely required.
    Gets an unmodifiable map containing all substitutions (interpolation) that need to be applied to all configurations.
    int
    Gets the portion (per thousand) of the total memory available for the JVM that is used as threshold to switch between holding (temporary) data in a stream in main memory or storing it in a file.
    static File
    Gets the base directory below the user home which is used as default base for the instance area (workspace) and the other default directories.
    boolean
    Gets whether the Sun providers should be used for the security API.
    protected void
    Initialises, checks and sets the values of the global properties as well as the substituted variables.
    static String
    Gets the value of the designated configuration variable resolved by the designated configuration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DIRECTORY_PROPERTY_NAMES

      protected static final Map<String,List<String>> DIRECTORY_PROPERTY_NAMES
      The property names for retrieving the base directories which are the program/installation directory and the user home/workspace directory. user is for the directories from the standard system properties, osgi is for the OSGi specific directories.
    • logger

      protected final Logger logger
      The logger for property providers. It is protected for extensibility.
  • Constructor Details

    • PropertyProvider

      protected PropertyProvider(Map<String,String> properties) throws ConfigurationException
      Creates a new PropertyProvider and parses all corresponding global properties from the designated map and/or sets the properties appropriately.
      Parameters:
      properties - A map providing all required global properties and values for substituted variables.
      Throws:
      ConfigurationException - If there are problems retrieving a required global property or a substituted variables from the designated map, a ConfigurationException will be thrown.
  • Method Details

    • getSubstitutedVariables

      public Map<String,String> getSubstitutedVariables()
      Gets an unmodifiable map containing all substitutions (interpolation) that need to be applied to all configurations. If a key of this map is found in a configuration, it will be replaced with the corresponding value from the map. The key needs to have the appropriate prefix in the configuration, for instance, ${arflow:key} will be replaced by value.
      Returns:
      An unmodifiable map containing the keys which will be replaced by the corresponding values from the map if they are found in a configuration.
    • getUseSunSecurityProviders

      public boolean getUseSunSecurityProviders()
      Gets whether the Sun providers should be used for the security API. This prevents using other registered security providers like from Apache or Bouncy Castle.
      Returns:
      Whether the Sun providers should be used for the security API. This prevents using other registered security providers like from Apache or Bouncy Castle.
    • getTotalMemPerthousandStreamThreshold

      public int getTotalMemPerthousandStreamThreshold()
      Gets the portion (per thousand) of the total memory available for the JVM that is used as threshold to switch between holding (temporary) data in a stream in main memory or storing it in a file. Data with a size below this threshold is kept in memory, bigger data will be stored in a temporary file.
      Returns:
      The portion (per thousand) of the total memory available for the JVM used as threshold to switch between holding stream data in memory or file storage.
    • getSkipClosing

      @Deprecated(since="15.0.0", forRemoval=true) public boolean getSkipClosing()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Do only use if absolutely required. This will be removed as soon as closing works reliable.
      Gets whether to skip closing introduced with 15.0.0. This helps in case of buggy closing, e. early or inappropriate closing.
      Returns:
      Whether to skip closing introduced with 15.0.0.
    • initialiseProperties

      protected void initialiseProperties(Map<String,String> properties) throws ConfigurationException
      Initialises, checks and sets the values of the global properties as well as the substituted variables. The following properties are parsed from the designated map (with a default value where appropriate):
      • arflow.logdir (default: ./logs, referring either to the current or user home directory, the one which can be written)
      • arflow.datadir (default: ./data, referring either to the current or user home directory, the one which can be read)
      • arflow.libdir (default: ./lib, referring either to the current or user home directory, the one which can be written)
      • arflow.useSunSecProvider (default: false)
      • arflow.totalMemPerthousandStreamThreshold (default: 40)
      • arflow.skipClosing (default: false)
      • arflow.confVar.*
      The substituted variables will contain:
      • arflow.logdir (default: ./logs, referring either to the current or user home directory, the one which can be written)
      • arflow.datadir (default: ./data, referring either to the current or user home directory, the one which can be read)
      • arflow.libdir (default: ./lib, referring either to the current or user home directory, the one which can be written)
      Parameters:
      properties - The properties which to parse.
      Throws:
      ConfigurationException - If the user dir for the log dir is not a valid directory or the default data directory could not be created, a ConfigurationException will be thrown.
    • getBaseForDefaultDirs

      protected static List<File> getBaseForDefaultDirs(Logger logger)
      Gets the base directories which are used as parents for the default directories for configuration, logs, libraries and data.
      Usually the first one is the directory providing the running application (osgi.install.area or user.dir), the second one is a subdirectory of the user home (osgi.instance.area or user.home/.<companyname>/<applicationname>). When running in an Eclipse/OSGi platform, the corresponding directories will be preferred.
      Parameters:
      logger - The logger to which to log problems when determining the base directories.
      Returns:
      The base directories which are used as parents for the default directories for configuration, logs, libraries and data. The list is unmodifiable and may contain null entries.
    • getUserHomeBaseDir

      public static File getUserHomeBaseDir()
      Gets the base directory below the user home which is used as default base for the instance area (workspace) and the other default directories. This is the "user" fall-back used by getBaseForDefaultDirs(Logger) for the instance area (pos == 1), that is user.home/.<companyname>/<applicationname> (the company and the product name only being appended if available). It does not take the OSGi osgi.instance.area into account.
      Returns:
      The user home based base directory or null if user.home is not set.
    • resolveConfVar

      public static String resolveConfVar(String confVar, Configuration conf)
      Gets the value of the designated configuration variable resolved by the designated configuration. The configuration needs to accept the adding of a temporarily entry. This allows to get globally configured variables like the data directory.
      Parameters:
      confVar - The value of the configuration variable to which to apply the variable resolution of the designated configuration.
      Note that depending on the delimiter of the designated configuration, this value may be subject of list handling. In this case only the first list value will be returned.
      conf - The configuration to determine the designated configuration variable. This needs to be writable.
      Returns:
      The value returned by the designated configuration when reading a property with the designated value. Usually, this applies the variable resolution part of the designated configuration. Note that this will be the designated string in case no resolution is applied to it, or even null in case it is replaced completely.