public final class ResourceConfig extends Object
A standard approach to configuration is provided by this class. Any configuration information provided by this library can be overridden or added to by applications.
By default, there are three groups of recognized configuration directories:
Each group consists of ten directories using a numeric suffix:
com/opengamma/strata/config/base
com/opengamma/strata/config/base1
com/opengamma/strata/config/base2
com/opengamma/strata/config/base9
com/opengamma/strata/config/library
com/opengamma/strata/config/library1
com/opengamma/strata/config/library9
com/opengamma/strata/config/application
com/opengamma/strata/config/application1
com/opengamma/strata/config/application9
The search strategy looks for the same file name in each of the thirty directories. All the files that are found are then merged, with directories lower down the list taking priorty. Thus, any configuration file in the 'application9' directory will override the same file in the 'appication1' directory, which will override the same file in the 'library' group, which will further override the same file in the 'base' group.
The 'base' group is reserved for Strata. The 'library' group is reserved for libraries built directly on Strata.
The set of configuration directories can be changed using the system property 'com.opengamma.strata.config.directories'. This must be a comma separated list, such as 'base,base1,base2,override,application'.
In general, the configuration managed by this class will be in INI format.
The combinedIniFile(String) method is the main entry point, returning a single
INI file merged from all available configuration files.
| Modifier and Type | Field and Description |
|---|---|
static String |
RESOURCE_DIRS_PROPERTY
The system property defining the comma separated list of groups.
|
| Modifier and Type | Method and Description |
|---|---|
static IniFile |
combinedIniFile(List<ResourceLocator> resources)
Returns a combined INI file formed by merging the specified INI files.
|
static IniFile |
combinedIniFile(String resourceName)
Returns a combined INI file formed by merging INI files with the specified name.
|
static List<ResourceLocator> |
orderedResources(String resourceName)
Obtains an ordered list of resource locators.
|
public static final String RESOURCE_DIRS_PROPERTY
public static IniFile combinedIniFile(String resourceName)
This finds the all files with the specified name in the configuration directories.
Each file is loaded, with the result being formed by merging the files into one.
See combinedIniFile(List) for more details on the merge process.
resourceName - the resource nameUncheckedIOException - if an IO exception occursIllegalStateException - if there is a configuration errorpublic static IniFile combinedIniFile(List<ResourceLocator> resources)
The result of this method is formed by merging the specified files together. The files are combined in order forming a chain. The first file in the list has the lowest priority. The last file in the list has the highest priority.
The algorithm starts with all the sections and properties from the highest priority file. It then adds any sections or properties from subsequent files that are not already present.
The algorithm can be controlled by providing a '[chain]' section. Within the 'chain' section, if 'chainNextFile' is 'false', then processing stops, and lower priority files are ignored. If the 'chainRemoveSections' property is specified, the listed sections are ignored from the files lower in the chain.
resources - the INI file resources to readUncheckedIOException - if an IO error occursIllegalArgumentException - if the configuration is invalidpublic static List<ResourceLocator> orderedResources(String resourceName)
This finds the all files with the specified name in the configuration directories. The result is ordered from the lowest priority (base) file to the highest priority (application) file. The result will always contain at least one file, but it may contain more than one.
resourceName - the resource nameUncheckedIOException - if an IO exception occursIllegalStateException - if there is a configuration errorCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.