Class DefaultConfigSource
java.lang.Object
com.tccc.kos.commons.core.service.config.DefaultConfigSource
- All Implemented Interfaces:
ConfigSource
ConfigSource that provides a sorted stack of sources. This is typically used
to construct a stack of default values that come from various sources. This
supports adding / removing sources as well as loading xml files as sources.
- Version:
- 2022-05-23
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfigSource
(ConfigSource source) Add a config source.void
gatherConfigForPath
(String path, Map<String, String> config) Put all configuration data for the specified handle path into the supplied map.void
gatherConfigPaths
(Set<String> paths) Put all available config bean handle paths into the supplied set.void
gatherOptionsForPath
(String path, Map<String, String> options) Put all option data for the specified handle path into the supplied map.void
gatherOptionsPaths
(Set<String> paths) Put all available option bean handle paths into the supplied set.void
getConfigValue
(String path, String attr, ConfigValue value) Populate the specified value bean with the effective value of the specified attribute from this source.int
getRank()
Returns the rank of the source, which is used to order sources.void
loadXmlConfigSource
(String name, int rank, String file, ResourceLoader loader) Load an xml file as a ConfigSource and add the source to the stack with the specified name and rank.void
loadXmlConfigSource
(String name, int rank, String file, ResourceLoader loader, String basePath) Load an xml file as a ConfigSource and add the source to the stack with the specified name and rank.removeConfigSource
(String name) Remove a config source by name.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.service.config.ConfigSource
getName
-
Method Details
-
loadXmlConfigSource
Load an xml file as a ConfigSource and add the source to the stack with the specified name and rank.- Parameters:
name
- name of the sourcerank
- rank of the sourcefile
- the xml file to loadloader
- optional resource loader to use if FileResourceLoader isn't sufficient
-
loadXmlConfigSource
public void loadXmlConfigSource(String name, int rank, String file, ResourceLoader loader, String basePath) Load an xml file as a ConfigSource and add the source to the stack with the specified name and rank.- Parameters:
name
- name of the sourcerank
- rank of the sourcefile
- the xml file to loadloader
- optional resource loader to use if FileResourceLoader isn't sufficientbasePath
- the base path to apply to all handle paths
-
addConfigSource
Add a config source.- Parameters:
source
- the source to add
-
removeConfigSource
Remove a config source by name.- Parameters:
name
- name of the source to remove
-
getRank
public int getRank()Description copied from interface:ConfigSource
Returns the rank of the source, which is used to order sources. Sources with higher ranks override sources with lower ranks.- Specified by:
getRank
in interfaceConfigSource
-
gatherConfigPaths
Description copied from interface:ConfigSource
Put all available config bean handle paths into the supplied set.- Specified by:
gatherConfigPaths
in interfaceConfigSource
-
gatherConfigForPath
Description copied from interface:ConfigSource
Put all configuration data for the specified handle path into the supplied map. The keys in the map are bean attribute names in dotted notation, and the values are the corresponding values for the attributes.- Specified by:
gatherConfigForPath
in interfaceConfigSource
- Parameters:
path
- the handle path to return data forconfig
- map to hold the resulting config data
-
getConfigValue
Description copied from interface:ConfigSource
Populate the specified value bean with the effective value of the specified attribute from this source.- Specified by:
getConfigValue
in interfaceConfigSource
- Parameters:
path
- the handle path to return data forattr
- the attribute of the config to returnvalue
- the value to populate
-
gatherOptionsPaths
Description copied from interface:ConfigSource
Put all available option bean handle paths into the supplied set. Most sources don't support this so by default it does nothing.- Specified by:
gatherOptionsPaths
in interfaceConfigSource
-
gatherOptionsForPath
Description copied from interface:ConfigSource
Put all option data for the specified handle path into the supplied map. The keys in the map are bean attribute names in dotted notation, and the values are the corresponding options for the attributes. Map, list and array bean attributes will contain*
wildcards as all values in the map, list or array are assumed to be the same type. Most sources don't suppor this so by default it does nothing.- Specified by:
gatherOptionsForPath
in interfaceConfigSource
- Parameters:
path
- the handle path to return data foroptions
- map to put the options into
-