Class ConfigurationPropertyProvider
- Direct Known Subclasses:
ServletConfigurationPropertyProvider,SystemPropertyProvider
PropertyProvider to support configuration directories as
URLs to load configuration files from, a directory to write configurations changed at runtime to,
a directory to write the logs to and boolean flags for whether to load configuration files from
bundles (jar-files containing the AristaFlow-components), whether to use debug logging while
bootstrapping and whether to keep the registered log handlers. For the configuration directories, one may either specify normal directories via
arflow.confdir or a mixture of directories and URLs via arflow.confurl.
If arflow.confurl is specified, arflow.confdir will be ignored. Note
that arflow.confurl expects ";" as separator for the URLs while
arflow.confdir expects the platform-dependent path separator
(File.pathSeparator).
The configuration directories (or URLs) may contain a reference to the configuration provided
when bootstrapping
("$").
The provided configuration will apply at the corresponding place relative to the other
configuration directories. This effectively splits the configuration directories into 2 parts:
directories before the provided configuration and directories after the provided configuration.
If no position is defined for the provided configuration, it will apply before the configuration
directories. However, the first configuration to apply is the runtime configuration which
persists configuration values set from within the platform (at runtime).
This class parses the following property from the designated map (in parentheses the default value that will apply if the property is not set):
arflow.confurlarflow.confdir(applies only if arflow.confurl not set, optional default:./conf, referring either to the current or user home directory, the one which can be read)arflow.configuration.runtime.defaultdatasource(default:false)arflow.confdir.runtime(default: "rtConf/" below arflow.datadir)arflow.configuration.bundle(default:false)arflow.debug.configuration(default:false)
This property enables debug logging. First, there will be a console handler forALLwill log all log messages while logging is being initialised. It will stop after logging has been successfully established. Second, the complete configuration including all referenced configuration files will be printed to aFINElog message in the loggerde.aristaflow.adept2.base.configuration.ConfigurationManager. So configure this logger appropriately if you want to have the configuration logged.arflow.logging.keephandler(default:false)
This property keeps the existing log handlers. Otherwise it removes all existing ones and only registers the ones configured for AristaFlow. This is necessary since the existing log handlers are usually rather inappropriate. For instance there is log handler picking allWARNINGlogs from all libraries which may be rather irrelevant.
-
Field Summary
Fields inherited from class de.aristaflow.adept2.base.configuration.PropertyProvider
DIRECTORY_PROPERTY_NAMES, logger -
Constructor Summary
ConstructorsConstructorDescriptionConfigurationPropertyProvider(Map<String, String> properties) Creates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately.ConfigurationPropertyProvider(Map<String, String> properties, boolean useDefaultConfDir, boolean defaultDsForRtConf) Creates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately.ConfigurationPropertyProvider(Map<String, String> properties, boolean useDefaultConfDir, String bundleConfigSubdir, boolean defaultDsForRtConf) Creates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately.ConfigurationPropertyProvider(Map<String, String> properties, String bundleConfigSubdir) Creates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately.ConfigurationPropertyProvider(Map<String, String> properties, String bundleConfigSubdir, boolean defaultDsForRtConf) Creates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately. -
Method Summary
Modifier and TypeMethodDescriptionGets the configuration directories that apply after the provided configuration.Gets the configuration directories that apply before the provided configuration.Gets whether a file-based configuration manager should load a configuration from a bundle (that is a jar-file containing a configuration) and if so, from which subdirectory belowconf/in the jar-file.Gets (an unmodifiable list containing) the configuration directory/directories of AristaFlow.booleanGets the global property which allows to enable the logging of the initialisation of the configuration.booleanGets the global property which allows to keep already registered log handlers in the logger hierarchy.Gets the configuration directory for runtime configurations, that is configurations that may be changed at runtime.booleanGets whether to use the default data source for the runtime configuration.protected voidinitialiseProperties(Map<String, String> properties) Initialises, checks and sets the values of the global properties as well as the substituted variables.injectDefaultConfDir(boolean useDefaultConfDir, Map<String, String> properties) Checks for whether the designated properties contain configuration URLs or configuration directories and adds the default configuration directory/directories./conf(referring either to the current and/or user home directory, the one(s) which can be read) if neither are set and the default should be used.parseConfDirs(String[] confs) Parses the designated configuration directories and splits them appropriately based on the position of the provided configuration.Methods inherited from class de.aristaflow.adept2.base.configuration.PropertyProvider
getBaseForDefaultDirs, getSkipClosing, getSubstitutedVariables, getTotalMemPerthousandStreamThreshold, getUserHomeBaseDir, getUseSunSecurityProviders, resolveConfVar
-
Constructor Details
-
ConfigurationPropertyProvider
Creates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf(referring either to the current or user home directory, the one which can be read) will be used.- Parameters:
properties- A map providing all required global properties and values for substituted variables.- Throws:
ConfigurationException- If the default configuration directory is to be used but cannot be accessed or there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationExceptionwill be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String, String> properties, String bundleConfigSubdir) throws ConfigurationExceptionCreates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf(referring either to the current or user home directory, the one which can be read) will be used.- Parameters:
properties- A map providing all required global properties and values for substituted variables.bundleConfigSubdir- The subdirectory belowconf/in the bundle configuration. This will only be used if the designated properties activate bundle configuration loading.- Throws:
ConfigurationException- If the default configuration directory is to be used but cannot be accessed or there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationExceptionwill be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String, String> properties, String bundleConfigSubdir, boolean defaultDsForRtConf) throws ConfigurationExceptionCreates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf(referring either to the current or user home directory, the one which can be read) will be used.- Parameters:
properties- A map providing all required global properties and values for substituted variables.bundleConfigSubdir- The subdirectory belowconf/in the bundle configuration. This will only be used if the designated properties activate bundle configuration loading.defaultDsForRtConf- The default value for whether to use the default data source for runtime configurations. This will ignored if present in the designated properties.- Throws:
ConfigurationException- If the default configuration directory is to be used but cannot be accessed or there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationExceptionwill be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String, String> properties, boolean useDefaultConfDir, boolean defaultDsForRtConf) throws ConfigurationExceptionCreates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf(referring either to the current or user home directory, the one which can be read) will be used or not depending on the designated flag.- Parameters:
properties- A map providing all required global properties and values for substituted variables.useDefaultConfDir- Whether./confshould be used as default configuration directory in case no other configuration directory or URL is set.defaultDsForRtConf- The default value for whether to use the default data source for runtime configurations. This will ignored if present in the designated properties.- Throws:
ConfigurationException- If the default configuration directory is to be used but cannot be accessed or there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationExceptionwill be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String, String> properties, boolean useDefaultConfDir, String bundleConfigSubdir, boolean defaultDsForRtConf) throws ConfigurationExceptionCreates a newConfigurationPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf(referring either to the current or user home directory, the one which can be read) will be used or not depending on the designated flag.- Parameters:
properties- A map providing all required global properties and values for substituted variables.useDefaultConfDir- Whether./confshould be used as default configuration directory in case no other configuration directory or URL is set.bundleConfigSubdir- The subdirectory belowconf/in the bundle configuration. This will only be used if the designated properties activate bundle configuration loading.defaultDsForRtConf- The default value for whether to use the default data source for runtime configurations. This will ignored if present in the designated properties.- Throws:
ConfigurationException- If the default configuration directory is to be used but cannot be accessed or there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationExceptionwill be thrown.
-
-
Method Details
-
getConfDirs
Gets (an unmodifiable list containing) the configuration directory/directories of AristaFlow. If this is the empty list, it will mean to only use the provided configuration.
Previous directories take precedence over later directories, that is configurations from previous directories will overwrite configurations (configuration values) from later ones.- Returns:
- The configuration directory/directories of AristaFlow. If this is the empty list, it will mean to only use the provided configuration. Previous directories take precedence over later directories.
-
getBeforeConfDirs
Gets the configuration directories that apply before the provided configuration. This list may be empty.- Returns:
- The configuration directories that apply before the provided configuration. This list will be empty if the provided configuration applies before other configuration directories.
-
getAfterConfDirs
Gets the configuration directories that apply after the provided configuration. This list may be empty.- Returns:
- The configuration directories that apply after the provided configuration. This list will be empty if the provided configuration applies after other configuration directories.
-
getUseDefDsForRtConf
public boolean getUseDefDsForRtConf()Gets whether to use the default data source for the runtime configuration. Runtime configurations will be stored within the appropriate tables in the configured default data source.- Returns:
- Whether to use the default data source for the runtime configuration.
-
getRuntimeConfDir
Gets the configuration directory for runtime configurations, that is configurations that may be changed at runtime. If this is not explicitly set, the subdirectory "rtConf" belowarflow.datadirwill be used.- Returns:
- The configuration directory for runtime configurations, that is configurations that may be changed at runtime.
-
getBundleConfigSubdir
Gets whether a file-based configuration manager should load a configuration from a bundle (that is a jar-file containing a configuration) and if so, from which subdirectory belowconf/in the jar-file.nullindicates to not load the bundle configuration.- Returns:
- Whether a file-based configuration manager should load a configuration from a
configuration bundle (that is a jar-file containing a configuration) or not (
null) and from where belowconf/in the jar-file.
-
getDebugConfig
public boolean getDebugConfig()Gets the global property which allows to enable the logging of the initialisation of the configuration.
This property is needed before theGlobalPropertieshave been initialised.- Returns:
- Whether to log the initialisation of the configuration.
-
getKeepLogHandler
public boolean getKeepLogHandler()Gets the global property which allows to keep already registered log handlers in the logger hierarchy. Per default all log handlers are removed due to a bad default of the JVMs.
This property is needed before theGlobalPropertieshave been initialised.- Returns:
- Whether to keep the log handlers that are registered before bootstrapping.
-
initialiseProperties
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.*
- 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.confurl
- arflow.confdir (applies only if arflow.confurl not set)
- arflow.configuration.runtime.defaultdatasource (default:
false) - arflow.confdir.runtime (default: "rtConf/" below arflow.datadir)
- arflow.configuration.bundle (default:
false) - arflow.debug.configuration (default:
false) - arflow.logging.keephandler (default:
false)
- Overrides:
initialisePropertiesin classPropertyProvider- Parameters:
properties- The properties which to parse.- Throws:
ConfigurationException- Besides the overridden method, this method will throw aConfigurationExceptionif there are problems with the directory for the runtime configurations, for instance, it is not a directory or it can not be written to.
- arflow.logdir (default:
-
parseConfDirs
Parses the designated configuration directories and splits them appropriately based on the position of the provided configuration. This position is removed from the returned list. The split information is set in the corresponding fields of this provider. All lists are in the appropriate order (reverse to the user provided order) and unmodifiable.- Parameters:
confs- The configuration directories or URLs as provided by the user.- Returns:
- The configuration directories or URLs as unmodifiable reversed URL list.
- See Also:
-
injectDefaultConfDir
protected static Map<String,String> injectDefaultConfDir(boolean useDefaultConfDir, Map<String, String> properties) throws ConfigurationExceptionChecks for whether the designated properties contain configuration URLs or configuration directories and adds the default configuration directory/directories./conf(referring either to the current and/or user home directory, the one(s) which can be read) if neither are set and the default should be used. A configuration in the user home directory will take precedence over the one from current directory.- Parameters:
useDefaultConfDir- Whether to add the default configuration directory in case neither configuration URLs nor configuration directories are in the designated properties.properties- The properties in which to inject the default configuration directory if appropriate.- Returns:
- The designated properties adapted appropriately. This may be a copy of the designated map!
- Throws:
ConfigurationException- If the configuration directory is not set, the default should be used, but the corresponding directory cannot be accessed, aConfigurationExceptionwill be thrown.
-