Class ConfigurationPropertyProvider
- java.lang.Object
-
- de.aristaflow.adept2.base.configuration.PropertyProvider
-
- de.aristaflow.adept2.base.configuration.ConfigurationPropertyProvider
-
- Direct Known Subclasses:
ServletConfigurationPropertyProvider
,SystemPropertyProvider
public class ConfigurationPropertyProvider extends PropertyProvider
This provider extends a normalPropertyProvider
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 viaarflow.confdir
or a mixture of directories and URLs viaarflow.confurl
. Ifarflow.confurl
is specified,arflow.confdir
will be ignored. Note thatarflow.confurl
expects ";" as separator for the URLs whilearflow.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.confurl
arflow.confdir
(applies only if arflow.confurl not set, optional default./conf
)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 forALL
will 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 aFINE
log 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 allWARNING
logs from all libraries which may be rather irrelevant.
-
-
Field Summary
-
Fields inherited from class de.aristaflow.adept2.base.configuration.PropertyProvider
logger
-
-
Constructor Summary
Constructors Constructor Description ConfigurationPropertyProvider(Map<String,String> properties)
Creates a newConfigurationPropertyProvider
and 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 newConfigurationPropertyProvider
and 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 newConfigurationPropertyProvider
and parses all corresponding global properties from the designated map and/or sets the properties appropriately.ConfigurationPropertyProvider(Map<String,String> properties, String bundleConfigSubdir)
Creates a newConfigurationPropertyProvider
and 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 newConfigurationPropertyProvider
and parses all corresponding global properties from the designated map and/or sets the properties appropriately.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<URL>
getAfterConfDirs()
Gets the configuration directories that apply after the provided configuration.List<URL>
getBeforeConfDirs()
Gets the configuration directories that apply before the provided configuration.String
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.List<URL>
getConfDirs()
Gets (an unmodifiable list containing) the configuration directory/directories of AristaFlow.boolean
getDebugConfig()
Gets the global property which allows to enable the logging of the initialisation of the configuration.boolean
getKeepLogHandler()
Gets the global property which allows to keep already registered log handlers in the logger hierarchy.File
getRuntimeConfDir()
Gets the configuration directory for runtime configurations, that is configurations that may be changed at runtime.boolean
getUseDefDsForRtConf()
Gets whether to use the default data source for the runtime configuration.protected void
initialiseProperties(Map<String,String> properties)
Initialises, checks and sets the values of the global properties as well as the substituted variables.protected static Map<String,String>
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.
protected List<URL>
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
getSkipClosing, getSubstitutedVariables, getTotalMemPerthousandStreamThreshold, getUsePre300Security, getUseSunSecurityProviders
-
-
-
-
Constructor Detail
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String,String> properties) throws ConfigurationException
Creates a newConfigurationPropertyProvider
and parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf
will be used.- 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, aConfigurationException
will be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String,String> properties, String bundleConfigSubdir) throws ConfigurationException
Creates a newConfigurationPropertyProvider
and parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf
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 there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationException
will be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String,String> properties, String bundleConfigSubdir, boolean defaultDsForRtConf) throws ConfigurationException
Creates a newConfigurationPropertyProvider
and parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf
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 there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationException
will be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String,String> properties, boolean useDefaultConfDir, boolean defaultDsForRtConf) throws ConfigurationException
Creates a newConfigurationPropertyProvider
and parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf
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./conf
should 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 there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationException
will be thrown.
-
ConfigurationPropertyProvider
public ConfigurationPropertyProvider(Map<String,String> properties, boolean useDefaultConfDir, String bundleConfigSubdir, boolean defaultDsForRtConf) throws ConfigurationException
Creates a newConfigurationPropertyProvider
and parses all corresponding global properties from the designated map and/or sets the properties appropriately. If no configuration directory or URL is specified,./conf
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./conf
should 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 there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationException
will be thrown.
-
-
Method Detail
-
getConfDirs
public List<URL> 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
public List<URL> 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
public List<URL> 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
public File 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.datadir
will be used.- Returns:
- The configuration directory for runtime configurations, that is configurations that may be changed at runtime.
-
getBundleConfigSubdir
public String 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.null
indicates 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 theGlobalProperties
have 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 theGlobalProperties
have been initialised.- Returns:
- Whether to keep the log handlers that are registered before bootstrapping.
-
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
) - arflow.datadir (default:
./examples
) - arflow.libdir (default:
./lib
) - arflow.useSunSecProvider (default:
false
) - arflow.totalMemPerthousandStreamThreshold (default:
40
) - arflow.skipClosing (default:
false
) - arflow.confVar.*
- arflow.logdir (default:
./logs
) - arflow.datadir (default:
./examples
) - arflow.libdir (default:
./lib
) - arflow.confVar.*
- 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:
initialiseProperties
in classPropertyProvider
- Parameters:
properties
- The properties which to parse.- Throws:
ConfigurationException
- Besides the overridden method, this method will throw aConfigurationException
if 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
protected List<URL> parseConfDirs(String[] confs)
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:
ConfigurationConstants.CONFIG_PROVIDED_POSITION
-
injectDefaultConfDir
protected static Map<String,String> 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./conf
if neither are set and the default should be used.- 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!
-
-