Package org.spincast.plugins.config
Class ConfigFinder
java.lang.Object
org.spincast.plugins.config.ConfigFinder
- Direct Known Subclasses:
SpincastConfigDefault
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConfigFinder
(String classpathFilePath, String externalFilePath, List<String> environmentVariablesPrefixes, boolean environmentVariablesStripPrefix, List<String> systemPropertiesPrefixes, boolean systemPropertiesStripPrefix, boolean externalFileConfigsOverrideEnvironmentVariables, boolean throwExceptionIfSpecifiedClasspathConfigFileIsNotFound, boolean throwExceptionIfSpecifiedExternalConfigFileIsNotFound) This component is not part of the Guice context because you can very easily created circular dependencies with configurations since they are used everywhere. -
Method Summary
Modifier and TypeMethodDescriptionclearPrefixes
(List<String> prefixes) Parses the keys of the map as "dotted paths" and created an expanded Map from them.protected File
If the project is running from an executable .jar file, this will return the directory containing this .jar file.protected File
If the project is not running from an executable .jar file, this will return the root directory of the project on the file system.getBigDecimal
(String key) getBigDecimal
(String key, BigDecimal defaultValue) protected BigDecimal
getBigDecimalList
(String key) getBigDecimalList
(String key, List<BigDecimal> defaultValue) getBoolean
(String key) getBoolean
(String key, Boolean defaultValue) protected Boolean
getBooleanList
(String key) getBooleanList
(String key, List<Boolean> defaultValue) protected String
Gets an untype config from the config map.getConfigFromMap
(Map<String, Object> map, String dottedKey) Gets a config from the given Map.Gets a config from the given Map.getConfigList
(String key) getConfigList
(String key, List<?> defaultValue) protected Date
getDateFromElement
(Object date) getDateList
(String key) getDateList
(String key, List<Date> defaultValue) protected String
getInteger
(String key) getInteger
(String key, Integer defaultValue) protected Integer
getIntegerList
(String key) getIntegerList
(String key, List<Integer> defaultValue) protected Long
getLongFromElement
(Object val) getLongList
(String key) getLongList
(String key, List<Long> defaultValue) getMapList
(String key) getRawConfig
(String dottedKey) Gets a config from the raw Map.Get raw configs, as a MapgetStringList
(String key) getStringList
(String key, List<String> defaultValue) protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected void
loadYamlFileConfigs
(File configFile, org.yaml.snakeyaml.Yaml yaml) Merges two maps : The elements from the second map override the elements of the first map of the same path, except for Map elements which are merged.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
rawConfigs
-
configs
-
-
Constructor Details
-
ConfigFinder
protected ConfigFinder(String classpathFilePath, String externalFilePath, List<String> environmentVariablesPrefixes, boolean environmentVariablesStripPrefix, List<String> systemPropertiesPrefixes, boolean systemPropertiesStripPrefix, boolean externalFileConfigsOverrideEnvironmentVariables, boolean throwExceptionIfSpecifiedClasspathConfigFileIsNotFound, boolean throwExceptionIfSpecifiedExternalConfigFileIsNotFound) This component is not part of the Guice context because you can very easily created circular dependencies with configurations since they are used everywhere.
-
-
Method Details
-
clearPrefixes
-
configure
-
getClasspathFilePath
-
getExternalFilePath
-
getEnvironmentVariablesPrefixes
-
isEnvironmentVariablesStripPrefix
protected boolean isEnvironmentVariablesStripPrefix() -
getSystemPropertiesPrefixes
-
isSystemPropertiesStripPrefix
protected boolean isSystemPropertiesStripPrefix() -
isExternalFileConfigsOverrideEnvironmentVariables
protected boolean isExternalFileConfigsOverrideEnvironmentVariables() -
isThrowExceptionIfSpecifiedClasspathConfigFileIsNotFound
protected boolean isThrowExceptionIfSpecifiedClasspathConfigFileIsNotFound() -
isThrowExceptionIfSpecifiedExternalConfigFileIsNotFound
protected boolean isThrowExceptionIfSpecifiedExternalConfigFileIsNotFound() -
getConfigs
-
getRawConfigs
Get raw configs, as a Map -
loadYamlFileConfigs
-
getEnvironmentVariables
-
getEnvironmentVariablesConfigs
-
getSystemPropertiesConfigs
-
expandMap
Parses the keys of the map as "dotted paths" and created an expanded Map from them. -
mergeMaps
Merges two maps : The elements from the second map override the elements of the first map of the same path, except for Map elements which are merged. -
getRawConfig
Gets a config from the raw Map. The dotted key will be parsed as the path to use. -
getConfigFromMap
Gets a config from the given Map. The dotted key will be parsed as the path to use.- Returns:
- the config value or
null
if not found.
-
getConfigFromMap
Gets a config from the given Map. The dotted key will be parsed as the path to use.- Returns:
- the config value or the default value if not found.
-
getConfig
-
getConfig
Gets an untype config from the config map. If the config isn't there, we'll try to get it from the raw configs map.If the resulting config is
null
, the default value will be returned. -
getConfigList
-
getConfigList
-
getMap
-
getMap
-
getMapList
-
getMapList
-
getString
-
getString
-
getStringList
-
getStringList
-
getBooleanFromElement
-
getBoolean
-
getBoolean
-
getBooleanList
-
getBooleanList
-
getIntegerFromElement
-
getInteger
-
getInteger
-
getIntegerList
-
getIntegerList
-
getLongFromElement
-
getLong
-
getLong
-
getLongList
-
getLongList
-
getBigDecimalFromElement
-
getBigDecimal
-
getBigDecimal
-
getBigDecimalList
-
getBigDecimalList
-
getDateFromElement
-
getDate
-
getDate
-
getDateList
-
getDateList
-
getAppJarDirectory
If the project is running from an executable .jar file, this will return the directory containing this .jar file.- Returns:
- the directory path or
null
if the application is not running from an executable .jar file.
-
getAppRootDirectoryNoJar
If the project is not running from an executable .jar file, this will return the root directory of the project on the file system.- Returns:
- the directory path or
null
if the application is running from an executable .jar file.
-