public class ConfigurationLoader extends Object
PROPKEY_CUSTOM_CONFIGURATION
property in the default settings. The name of the local settings file (unitils-local.propeties) is defined
by the PROPKEY_LOCAL_CONFIGURATION in the custom or default settings. If these properties are set to
null or empty, the corresponding property file will not be loaded.
A runtime exception is thrown when the default properties cannot be loaded.
A warning is logged when the custom propreties cannot be loaded.
A debug message is logged when the local properties cannot be loaded.
Ant-like property place holders, e.g. ${holder} will be expanded if needed all property place holders to actual values.
For example suppose you have a property defined as follows: root.dir=/usr/home
Expanding following ${root.dir}/somesubdir
will then give following result: /usr/home/somesubdir| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_PROPERTIES_FILE_NAME
Name of the fixed configuration file that contains all defaults
|
static String |
PROPKEY_CUSTOM_CONFIGURATION
Property in the defaults configuration file that contains the name of the custom configuration file
|
static String |
PROPKEY_LOCAL_CONFIGURATION
Property in the defaults and/or custom configuration file that contains the name of
the user local configuration file
|
| Constructor and Description |
|---|
ConfigurationLoader() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
expandPropertyValues(Properties properties)
Expands all property place holders to actual values.
|
protected String |
getConfigurationFileName(String propertyName,
Properties properties)
Gets the configuration file name from the system properties or if not defined, from the given loaded properties.
|
Properties |
loadConfiguration()
Creates and loads all configuration settings.
|
protected void |
loadCustomConfiguration(Properties properties)
Load the custom project level configuration file (unitils.properties)
|
protected void |
loadDefaultConfiguration(Properties properties)
Load the default properties file that is distributed with unitils (unitils-default.properties)
|
protected void |
loadLocalConfiguration(Properties properties)
Load the local configuration file from the user home, or from the classpath
|
protected void |
loadSystemProperties(Properties properties)
Load the environment properties.
|
public static final String DEFAULT_PROPERTIES_FILE_NAME
public static final String PROPKEY_CUSTOM_CONFIGURATION
public static final String PROPKEY_LOCAL_CONFIGURATION
public Properties loadConfiguration()
protected void loadDefaultConfiguration(Properties properties)
properties - The instance to add to loaded properties to, not nullprotected void loadCustomConfiguration(Properties properties)
properties - The instance to add to loaded properties to, not nullprotected void loadLocalConfiguration(Properties properties)
properties - The instance to add to loaded properties to, not nullprotected void loadSystemProperties(Properties properties)
properties - The instance to add to loaded properties to, not nullprotected void expandPropertyValues(Properties properties)
properties - The properties, not nullprotected String getConfigurationFileName(String propertyName, Properties properties)
propertyName - The name of the property that defines the local/custom file name, not nullproperties - The propertis that were already loaded, not nullCopyright © 2016. All Rights Reserved.