Class ConfigurationManager

  • Direct Known Subclasses:
    UrlConfigurationManager

    public abstract class ConfigurationManager
    extends Object
    This configuration manager handles configurations for components and services of the AristaFlow-System. Configurations are based on Configuration, for instance (properties files, XML files, properties from a database table, ...
    For managing the configurations, this manager needs some global (system) properties which need to be provided in the constructor. These properties include for instance the directories to use for logging or where to load libraries from. Since the properties may stem from arbitrary sources, for instance system properties or a servlet context, they are encapsulated via the separate interface ConfigurationPropertyProvider.

    Since a configuration manager provides all configurations for components and services, it needs to be initialised before the registry is initialised. How the boot configuration manager is initialised depends on the concrete implementation of the configuration manager. The bootstrapping has to be implemented appropriately. Usually the boot configuration manager is provided its root configuration as file reference or directly as a configuration object. This information needs to be handled by the bootstrapping.

    The contents of a configuration depends mainly on the corresponding component/service. This should declare all needed configuration values as ConfigurationDescription in the implementing class. Besides this configuration values, there are a few configuration entries needed for the management of the component, for instance, singleton or multi-instances, and arbitrary entries for the component itself. These entries can be found in the documentation of a class requiring the configuration and the registries.

    Components have a type and an instance name which identify them. They are created by adding the following information to a (parent) configuration: their interface ( Component.<ComponentType> = <InterfaceClass>), an implementation ( <ComponentType>.Implementation = <ImplementationClass> ), instances ( <ComponentType>.Instances = <InstanceName1>, <InstanceName2> ), and instance implementations supporting the interface of the corresponding component type ( <InstanceName>.Implementation = <ImplementationClass> ).
    Each named instance of a component may have its own configuration. This is either a separate configuration (for instance in a separate file and loaded via the information found in the parent configuration), or it is contained in the current configuration. However, the latter requires the configuration entries to have the instance name as prefix. Otherwise there may be naming conflicts between different component instances having the same name. This in turn requires the instance names to be unique with respect to a (parent) configuration.
    A file name used as configuration for a specific component is searched for in several configuration directories and therefore needs to be a relative file. They stem from a ConfigurationPropertyProvider and are usually provided as parameter when bootstrapping. The configuration directories define an order in which they are searched for the configuration file. Note that the prefixes for the component (instance) in the separate file need to be omitted.

    All instances of one component type share a common configuration, which is called the type configuration. This differs from a normal instance just by having the component type instead of the instance name (as prefix). This component type configuration is also used for the " anonymous instance", which will be an implicit declared instance if there no component instances declared explicitly. This anonymous instance is treated as if it had the the component type name as instance name (that is, it has the component type name twice). Each can have its own external configuration file which will all be merged:
    <ComponentType>.ConfigFile = <RelativePathOfConfigFile> or <InstanceName>.ConfigFile = <RelativePathOfConfigFile>
    Besides the shared configuration each component instance has its own runtime configuration that is separated from other component instances. It differs from the normal configuration by its ability to change configuration values at runtime and persist them. This requires a place to store data, for instance as properties file or in a database. For a component instance there is no difference between a normal and a runtime configuration; it gets just one merged configuration in which configuration values may be changed.

    Configuration files can also be provided in configuration bundles (in JAR-files). Such a configuration bundle has to have a file "conf/ADEPT2.properties". The file itself may be empty. If one configuration bundle is found, it will be added to the configuration directories. If several configuration bundles are found, they will need to have a defined order via the provided configuration URLs ("arflow.confurl"). Otherwise initialisation will abort.

    The configuration directories not only define the order on how to search for externally referenced configuration files and configuration bundles but also the order of the root configuration if provided as file name. Additionally one can set the position (and therefore the priority) of the provided configuration (if provided at all). This splits the configuration directories in 2 parts: the part before the provided configuration and the part after the provided configuration. The runtime configuration always applies at first since these values have the highest priority (especially when changed at runtime).

    This configuration manager usually loads all configurations lazily, except the root configuration. All other configurations are loaded as needed and then stored internally for faster subsequent retrieval. If required, for instance when changing the root configuration before bootstrapping or when dumping the root configuration, a complete root configuration will be created. That is all externally referenced configuration files will be incorporated and the reference will be removed from the configuration. Note that this rather complex and should only be done in special cases.

    All configuration entries may use variables in their values. They have the form ${arflow:arflow.<VarName>} or ${arflow:confVar.<VarName>}. The first refers to pre-defined values set as system properties (see PropertyProvider), which are usually various directories. The second allows to refer to variables which are declared inside the root configuration (usually "conf/ADEPT2.properties" and/or the provided configuration) or also via PropertyProvider. Configuration variables provided by a PropertyProvider will take precedence over one with the same name from a configuration file. The declaration is a configuration entry: ConfigurationManager.confVar.<VarName> = <VarValue> or a (system) property: arflow.confVar.<VarName> = <VarValue>. Therefore they may even use other variables. A cycle in the declaration will abort bootstrapping.

    This class parses the following properties from a configuration:

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Logger logger
      The logger for configuration managers.
      protected org.apache.commons.configuration2.Configuration providedConfiguration
      The configuration provided when bootstrapping.
      protected static String REFERENCED_CONFIG_FILE_SUFFIX
      The suffix of configuration entries referring to external configuration files.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ConfigurationManager​(String rootConfFileName, org.apache.commons.configuration2.Configuration providedConfiguration, boolean eager, ConfigurationPropertyProvider provider, LoggerManager loggerManager)
      Creates a new configuration manager using the configuration properties of the designated provider and either a root configuration loaded from the designated file name, or the designated provided configuration or a mixture of both respecting the order of the configurations and configuration directories from the provider.
      protected ConfigurationManager​(org.apache.commons.configuration2.Configuration rootConfiguration, org.apache.commons.configuration2.Configuration providedConfiguration, ConfigurationManager parent)
      Creates a new configuration manager having the designated root and provided configuration and the fields of the designated parent configuration manager.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.commons.configuration2.Configuration cloneConfiguration​(org.apache.commons.configuration2.Configuration conf)
      Clones the designated configuration by iterating all keys and storing the corresponding property to a new BaseConfiguration.
      static void copyConfiguration​(org.apache.commons.configuration2.Configuration from, org.apache.commons.configuration2.Configuration to, String prefix)
      Gets all entries from the first configuration and stores it with the designated prefix in the second configuration.
      abstract ConfigurationManager createChild​(String instanceName, String componentType)
      Creates a new configuration manager having all fields set to the same values as this configuration manager.
      void dumpConfiguration()
      Dumps the root configuration to the log of this configuration manager with log level Level.FINE.
      protected org.apache.commons.configuration2.Configuration getConfiguration​(String instanceName)
      Gets a configuration for the designated instance name which is a new Configuration-object.
      org.apache.commons.configuration2.Configuration getConfiguration​(String instanceName, String componentType)
      Loads the configuration of the designated instance of the designated component type.
      protected org.apache.commons.configuration2.Configuration getMergedRootConfiguration()
      Gets the root configuration as composite of the currently loaded root configurations from each configuration directory separately including the provided configuration an the right place.
      protected Collection<Pair<String,​String>> getReferencedConfigurationFiles​(org.apache.commons.configuration2.Configuration conf)
      Gets all configuration entries that refer to external configuration files in the designated configuration.
      org.apache.commons.configuration2.Configuration getRootConfiguration()
      Gets the root configuration of this configuration manager, that is the entry point for configurations.
      protected abstract org.apache.commons.configuration2.Configuration getRuntimeConfiguration​(String instanceName)
      Gets a runtime configuration for the designated instance name which is a Configuration-object that allows for storing the configuration values, for instance as file or in a database.
      <C extends org.apache.commons.configuration2.Configuration>
      C
      initConfiguration​(C conf)
      Initialises the designated configuration, for instance, setting the variable replacement.
      protected org.apache.commons.configuration2.Configuration initRootConfiguration​(String rootConfFileName, boolean eager, ConfigurationPropertyProvider provider)
      Loads the root configuration from the configuration directories, initialises the logging based on this configuration and the logger manager of this configuration manager and dumps the configuration if desired.
      protected org.apache.commons.configuration2.Configuration loadAndDump​(org.apache.commons.configuration2.Configuration conf, boolean eager, boolean debug)
      Loads the designated configuration completely, that is the externally referenced configuration files will be integrated appropriately in the designated configuration.
      protected org.apache.commons.configuration2.CompositeConfiguration loadConfigurationFromFile​(String instanceName, String fileName, boolean root)
      Loads configuration values out of the configuration directories including the runtime and the provided configuration in the specified order into a newly created composite configuration.
      protected org.apache.commons.configuration2.Configuration loadFromConfDir​(String instanceName, String fileName, URL confDir)
      Loads the designated file for the designated instance from the designated configuration directory.
      protected void loadFromConfDirs​(String instanceName, String fileName, org.apache.commons.configuration2.CompositeConfiguration conf, List<URL> confDirs, boolean root)
      Loads configuration values out of the designated configuration directories in the specified order into the designated composite configuration.
      protected org.apache.commons.configuration2.Configuration loadReferencedConfigurations​(org.apache.commons.configuration2.Configuration rootConf)
      Eagerly loads all referenced configuration files and puts them in the root configurations per configuration directory using the appropriate prefix.
      protected boolean loadToRootConfigurations​(String prefix, String fileName, List<URL> confDirs)
      Loads the configuration referred to by the designated file name from the designated configuration directories and stores them with the designated prefix in the appropriate root configurations.
      void replaceVariables​(List<String> classPath)
      Replaces variables with their appropriate values.
      protected void setConfigurationDirectories​(ConfigurationPropertyProvider provider)
      Sets the configuration directories so that configurations are loaded in the appropriate order, that is, configuration directories before and after the provided configuration.
      void terminate()
      Signals the termination which allows clean-up for instance resetting all created and configured loggers.
    • Field Detail

      • REFERENCED_CONFIG_FILE_SUFFIX

        protected static final String REFERENCED_CONFIG_FILE_SUFFIX
        The suffix of configuration entries referring to external configuration files.
        See Also:
        Constant Field Values
      • providedConfiguration

        protected final org.apache.commons.configuration2.Configuration providedConfiguration
        The configuration provided when bootstrapping. This may either be a complete root configuration (without additional configuration directories), a delta configuration complementing or overriding the configurations from the configuration directories or even null. If this is null, only configurations from the configuration directories will be used.
      • logger

        protected final Logger logger
        The logger for configuration managers. It is protected for extensibility.
        It may be null for usages of the configuration manager without the AristaFlow platform.
    • Constructor Detail

      • ConfigurationManager

        public ConfigurationManager​(String rootConfFileName,
                                    org.apache.commons.configuration2.Configuration providedConfiguration,
                                    boolean eager,
                                    ConfigurationPropertyProvider provider,
                                    LoggerManager loggerManager)
                             throws ConfigurationException
        Creates a new configuration manager using the configuration properties of the designated provider and either a root configuration loaded from the designated file name, or the designated provided configuration or a mixture of both respecting the order of the configurations and configuration directories from the provider.
        Parameters:
        rootConfFileName - The file name (relative to the configuration directory/directories) of the root configuration for which to create a UrlConfigurationManager. This may be null but then a configuration has to be provided ( providedConfiguration).
        providedConfiguration - The configuration provided when bootstrapping. This may either be a complete root configuration (without additional configuration directories), a delta configuration complementing or overriding the configurations from the configuration directories or even null. If this is null, only configurations from the configuration directories will be used but this requires a valid rootConfFileName.
        eager - Whether to (transitively) load all referenced configuration files for the root configuration when initialising.
        provider - The provider for configuration properties. Whether they stem from system properties or some configuration depends on the implementation of the provider.
        loggerManager - The logger manager providing and configuring the loggers for the platform. Logging is initialised right after the root configuration has been initialised. For the rare usages of a configuration manager without the AristaFlow platform, this may be null.
        Throws:
        ConfigurationException - If
        • there is no root configuration file name and no valid provided configuration,
        • there is no valid provided configuration and no configuration directory has been set,
        • one of the configuration directories cannot be accessed,
        • the configuration bundle order is not defined,
        • the designated root configuration file name could not be found in any of the searched configuration directories,
        • the directory for storing the logs can not be created or it is a file or
        • there are problems eagerly loading the externally referenced configuration files,
        a ConfigurationException will be thrown.
      • ConfigurationManager

        protected ConfigurationManager​(org.apache.commons.configuration2.Configuration rootConfiguration,
                                       org.apache.commons.configuration2.Configuration providedConfiguration,
                                       ConfigurationManager parent)
        Creates a new configuration manager having the designated root and provided configuration and the fields of the designated parent configuration manager. This is used for creating child configuration managers.
        Parameters:
        rootConfiguration - The root configuration to be used by the newly created configuration manager. Usually this is a subset of the root configuration of the designated ConfigurationManager.
        providedConfiguration - The provided configuration to be used by the newly created configuration manager. Usually this is a subset of the provided configuration of the designated ConfigurationManager.
        parent - The parent ConfigurationManager to retrieve all further fields from.
    • Method Detail

      • getRootConfiguration

        public org.apache.commons.configuration2.Configuration getRootConfiguration()
        Gets the root configuration of this configuration manager, that is the entry point for configurations. This configuration may reference configurations which may be handled by this configuration manager.
        This method is only needed to allow bootstrapping components to also retrieve a configuration since they are not initialised by the registry.
        Returns:
        The root configuration for this configuration manager containing all configurations (maybe by referencing them) for this configuration manager.
      • terminate

        public void terminate()
        Signals the termination which allows clean-up for instance resetting all created and configured loggers.
      • setConfigurationDirectories

        protected void setConfigurationDirectories​(ConfigurationPropertyProvider provider)
                                            throws ConfigurationException
        Sets the configuration directories so that configurations are loaded in the appropriate order, that is, configuration directories before and after the provided configuration. This also adds the URL of a configuration bundle with the least priority if appropriate.
        This method may not rely on the existence of a root configuration since it is obviously required for reading the root configuration.
        Parameters:
        provider - The provider having the configuration directories and the position of the provided configuration to set. Previous directories take precedence over later directories.
        Throws:
        ConfigurationException - If one of the configuration directories cannot be accessed or the configuration bundle should be used, but there are several configuration bundles of which the order cannot be determined, a ConfigurationException will be thrown.
      • initRootConfiguration

        protected org.apache.commons.configuration2.Configuration initRootConfiguration​(String rootConfFileName,
                                                                                        boolean eager,
                                                                                        ConfigurationPropertyProvider provider)
                                                                                 throws ConfigurationException
        Loads the root configuration from the configuration directories, initialises the logging based on this configuration and the logger manager of this configuration manager and dumps the configuration if desired.
        Parameters:
        rootConfFileName - The name of the configuration file containing the root configuration. This name is a relative path with file extension. If this is null, only the provided configuration will be used.
        eager - Whether the root configuration should be loaded eagerly, that is all externally referenced configuration files will be loaded.
        provider - The provider whether to debug log, that is, load the complete root configuration and log it.
        Returns:
        The root configuration loaded from the configuration directories and having the provided configuration integrated.
        Throws:
        ConfigurationException - If
        • the designated (non-null) file name could not be found in any of the searched configuration directories,
        • the directory for storing the logs can not be created or it is a file or
        • there are problems loading the externally referenced configuration files,
        a ConfigurationException will be thrown.
      • loadAndDump

        protected org.apache.commons.configuration2.Configuration loadAndDump​(org.apache.commons.configuration2.Configuration conf,
                                                                              boolean eager,
                                                                              boolean debug)
                                                                       throws ConfigurationException
        Loads the designated configuration completely, that is the externally referenced configuration files will be integrated appropriately in the designated configuration. This will only apply for eager loading or if a dump is required and the log level of the log manager is set to at least Level.FINE.
        Parameters:
        conf - The configuration in which to find externally referenced configuration files and load them.
        eager - Whether to lead eagerly, that is whether to load the externally referenced configuration files independent from whether to log the configuration or not.
        debug - Whether to log the complete configuration if the log manager is configured appropriately. If so, this obviously will require all externally referenced configurations and therefore will load them eagerly.
        Returns:
        A new configuration having all externally referenced configuration file loaded. Usually this has to be used as new root configuration.
        Throws:
        ConfigurationException - If there are problems loading the externally referenced configuration files, a ConfigurationException will be thrown.
      • loadReferencedConfigurations

        protected org.apache.commons.configuration2.Configuration loadReferencedConfigurations​(org.apache.commons.configuration2.Configuration rootConf)
                                                                                        throws ConfigurationException
        Eagerly loads all referenced configuration files and puts them in the root configurations per configuration directory using the appropriate prefix. The configuration entry referring to the external configuration file will be removed. After all referenced configuration files have been loaded, the root configuration will be merged from the root configurations per configuration directory and the provided configuration. This merged configuration will be returned and should be the new root configuration.
        Loading externally referenced configuration involves several steps and therefore may take some time. So use it carefully, for instance only when logging the complete configuration or retrieving it for manipulation when bootstrapping.
        Parameters:
        rootConf - The root configuration for which to (transitively) load all referenced configuration files from the configuration directories.
        Returns:
        The root configuration having all externally referenced configuration files resolved and stored under the corresponding prefix.
        Throws:
        ConfigurationException - If a referenced file name could not be found in any of the searched configuration directories, a ConfigurationException will be thrown.
      • loadToRootConfigurations

        protected boolean loadToRootConfigurations​(String prefix,
                                                   String fileName,
                                                   List<URL> confDirs)
        Loads the configuration referred to by the designated file name from the designated configuration directories and stores them with the designated prefix in the appropriate root configurations. This builds complete root configurations per configuration directory by incorporating externally referenced configuration files.
        Parameters:
        prefix - The prefix of the key in the configuration including the component instance name but without ".ConfigFile".
        fileName - The name of the configuration file to load with extension (relative path). This must not be null.
        confDirs - The configuration directories from which to load the configuration file if found.
        Returns:
        Whether the file could at least be loaded from one configuration directory.
      • getMergedRootConfiguration

        protected org.apache.commons.configuration2.Configuration getMergedRootConfiguration()
        Gets the root configuration as composite of the currently loaded root configurations from each configuration directory separately including the provided configuration an the right place. This is used for eagerly loading which requires replacing the externally referenced configuration files to be replaced per configuration directory before merging the configurations.
        Returns:
        The root configuration as configuration merged from the separate root configurations for each configuration directory including the provided configuration an the right place.
      • getReferencedConfigurationFiles

        protected Collection<Pair<String,​String>> getReferencedConfigurationFiles​(org.apache.commons.configuration2.Configuration conf)
        Gets all configuration entries that refer to external configuration files in the designated configuration.
        Parameters:
        conf - The configuration which to search for externally referenced configuration files.
        Returns:
        The configuration entries (keys and values) referring to external configuration files.
      • getConfiguration

        public org.apache.commons.configuration2.Configuration getConfiguration​(String instanceName,
                                                                                String componentType)
                                                                         throws ConfigurationException
        Loads the configuration of the designated instance of the designated component type. If the configuration is already loaded, it will be returned, otherwise new Configuration will be created and the contents loaded. The instance configuration will have the corresponding type configuration as defaults. The configuration will be stored for faster subsequent requests. If there is no reference to a separate file, the relevant entries from the root configuration will be returned.
        To retrieve the configuration for an anonymous instance, provide the component type name twice. If one configuration of a type is loaded, the configuration for the anonymous instance will also already be loaded.
        The runtime configuration for component type, anonymous instance as well as the designated instance will be appropriately integrated.
        Parameters:
        instanceName - The name of the instance for which to retrieve the configuration. In case of the anonymous instance this equals the component type name.
        componentType - The name of the component type to retrieve the configuration of the designated instances.
        Returns:
        The configuration of the designated component type.
        Throws:
        ConfigurationException - If the (runtime) configuration for the designated instance can not be retrieved or it does not contain required entries, a ConfigurationException will be thrown.
        ConfigurationException - If
        • the configured configuration file for the component type, the anonymous instance or the designated instance could not be found in any of the searched configuration directories including the runtime and provided configuration or
        • the runtime configuration cannot be retrieved,
        a ConfigurationException will be thrown.
      • getConfiguration

        protected org.apache.commons.configuration2.Configuration getConfiguration​(String instanceName)
                                                                            throws ConfigurationException
        Gets a configuration for the designated instance name which is a new Configuration-object. The configuration is loaded from a separate file referenced in the root configuration via loadConfigurationFromFile(String, String, boolean) or the relevant entries from the root configuration in case it does not reference a separate file for the designated name. The prefixes of the entries for the component will be removed in this case.
        Parameters:
        instanceName - The simple name of the component to get the configuration for.
        Returns:
        A new Configuration-object containing either the configurations loaded from a referenced separate file or having the relevant entries from the root configuration.
        Throws:
        ConfigurationException - If
        • no configuration can be found for the designated instance or
        • the runtime configuration cannot be retrieved,
        a ConfigurationException will be thrown.
      • loadConfigurationFromFile

        protected org.apache.commons.configuration2.CompositeConfiguration loadConfigurationFromFile​(String instanceName,
                                                                                                     String fileName,
                                                                                                     boolean root)
                                                                                              throws ConfigurationException
        Loads configuration values out of the configuration directories including the runtime and the provided configuration in the specified order into a newly created composite configuration. If there are problems loading the file from one of the directories, this will be logged. If the file cannot be loaded from any of the directories including the runtime and provided configuration, a ConfigurationException will be thrown.
        The memory configuration (the one to store written values) is the runtime configuration of the designated instance.
        Parameters:
        instanceName - The simple name of the component to get the configuration for or null for the bootstrapping. null indicates that no runtime configuration will be used.
        fileName - The name of the configuration file to load with extension (relative path). If this is null, only the runtime and the provided configuration will be used.
        root - Whether to load a root configuration which does not include the runtime configuration.
        Returns:
        The (composite) configuration which contains the loaded configurations from the configuration directories as well as the runtime and provided configuration.
        Throws:
        ConfigurationException - If
        • there are problems retrieving the runtime configuration or
        • no configuration can be found for the designated instance and file name,
        a ConfigurationException will be thrown.
      • loadFromConfDirs

        protected void loadFromConfDirs​(String instanceName,
                                        String fileName,
                                        org.apache.commons.configuration2.CompositeConfiguration conf,
                                        List<URL> confDirs,
                                        boolean root)
        Loads configuration values out of the designated configuration directories in the specified order into the designated composite configuration. If there are problems loading the file from one of the directories, this will be logged.
        For a root configuration, this will also initialise the separate root configurations for each configuration directory.
        Parameters:
        instanceName - The simple name of the component instance to get the configuration for or null for the bootstrapping. This is only for logging purpose.
        fileName - The name of the configuration file to load with extension (relative path). This must not be null.
        conf - The composite configuration in which to load the found configurations.
        confDirs - The configuration directories from which to load the configuration file if found.
        root - Whether to initialise the root configurations or not.
      • loadFromConfDir

        protected org.apache.commons.configuration2.Configuration loadFromConfDir​(String instanceName,
                                                                                  String fileName,
                                                                                  URL confDir)
        Loads the designated file for the designated instance from the designated configuration directory. This is just plain loading, no merging, no composition of configurations.
        Parameters:
        instanceName - The simple name of the component instance for which to load a configuration file. This is only for logging purpose and may be null.
        fileName - The name of the configuration file to load with extension (relative path) from the designated configuration directory. This must not be null.
        confDir - The configuration directory from which to load the configuration from the designated file.
        Returns:
        The configuration loaded from the designated file from the designated directory or null in case the configuration file cannot be loaded.
      • getRuntimeConfiguration

        protected abstract org.apache.commons.configuration2.Configuration getRuntimeConfiguration​(String instanceName)
                                                                                            throws ConfigurationException
        Gets a runtime configuration for the designated instance name which is a Configuration-object that allows for storing the configuration values, for instance as file or in a database. How the configuration is retrieved and where it is stored depends on the implementing subclass.
        The returned configuration must not have unnecessary prefixes for its entries, for instance there must not be the instance name as prefix. This would render the returned configuration unusable by the component instance since this does not know its instance name and therefore does not find the expected configuration entries.
        Parameters:
        instanceName - The simple name of the component to get the runtime configuration for.
        Returns:
        A new Configuration-object allowing to store configuration values for the designated instance.
        Throws:
        ConfigurationException - If the runtime configuration for the designated instance can not be retrieved or created, a ConfigurationException will be thrown.
        See Also:
        getConfiguration(String)
      • dumpConfiguration

        public void dumpConfiguration()
                               throws ConfigurationException
        Dumps the root configuration to the log of this configuration manager with log level Level.FINE. This will load the externally referenced configuration files before.
        Use this method carefully since eagerly loading the externally referenced configuration files is rather expensive.

        This will also change the root configuration, for instance, in case references to external configuration files have changed.

        Throws:
        ConfigurationException - If there are problems loading the externally referenced configuration files, a ConfigurationException will be thrown.
      • replaceVariables

        public void replaceVariables​(List<String> classPath)
        Replaces variables with their appropriate values. All provided variables will be replaced. Note that the designated list has to be changeable!

        Example: A property, specified in a configuration as:
        JDBCDataSource.ConnectionURL = jdbc:derby:${arflow:arflow.datadir}/Derby/DefaultDb;create=true
        will have ${arflow:arflow.datadir} replaced with the value of the global data dir, e.g.:
        jdbc:derby:./examples/Derby/DefaultDb;create=true.

        Parameters:
        classPath - The configuration as a changeable list in which to replace all system variables.
      • createChild

        public abstract ConfigurationManager createChild​(String instanceName,
                                                         String componentType)
                                                  throws ConfigurationException
        Creates a new configuration manager having all fields set to the same values as this configuration manager. The root configuration will be the configuration of the designated instance, the provided configuration will be the appropriate subset of the provided configuration of this configuration manager.
        If the instance name is null the anonymous instance having the component type name will be used. If the component type name is also null, the created configuration manager will have the same root and provided configuration as this configuration manager.
        Parameters:
        instanceName - The simple name of the instance for which to retrieve the configuration. In case of the anonymous instance this equals the component type name. Use null for the bootstrap registry.
        componentType - The name of the component type to retrieve the configuration of the designated instances. Use null for the bootstrap registry.
        Returns:
        A new configuration manager having the root and provided configuration appropriate for the designated instance or the same as this configuration manager.
        Throws:
        ConfigurationException - If the configuration for the designated instance cannot be retrieved, a ConfigurationException will be thrown.
      • cloneConfiguration

        public org.apache.commons.configuration2.Configuration cloneConfiguration​(org.apache.commons.configuration2.Configuration conf)
        Clones the designated configuration by iterating all keys and storing the corresponding property to a new BaseConfiguration. Changes made later to the new configuration will obviously not be reflected in the old configuration and vice versa. But the lookup map will be the same, that is, changes to one will also affect the other configuration.
        Parameters:
        conf - The configuration which to clone.
        Returns:
        A new configuration containing the same keys and properties like the designated configuration.
      • copyConfiguration

        public static void copyConfiguration​(org.apache.commons.configuration2.Configuration from,
                                             org.apache.commons.configuration2.Configuration to,
                                             String prefix)
        Gets all entries from the first configuration and stores it with the designated prefix in the second configuration. Existing values with the same key in the second configuration will be overwritten.
        Parameters:
        from - The configuration from which to copy all entries from.
        to - The configuration to copy all the entries to.
        prefix - The prefix for the entries copied from the first to the second configuration. This must not be null or the empty string!
      • initConfiguration

        public <C extends org.apache.commons.configuration2.Configuration> C initConfiguration​(C conf)
        Initialises the designated configuration, for instance, setting the variable replacement. Call this method for every newly created configuration.
        Parameters:
        conf - The configuration which to initialise.
        Returns:
        The designated configuration.