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 TypeMethodDescriptionvoidaddConfigSource(ConfigSource source) Add a config source.voidgatherConfigForPath(String path, Map<String, String> config) Put all configuration data for the specified handle path into the supplied map.voidgatherConfigPaths(Set<String> paths) Put all available config bean handle paths into the supplied set.voidgatherOptionsForPath(String path, Map<String, String> options) Put all option data for the specified handle path into the supplied map.voidgatherOptionsPaths(Set<String> paths) Put all available option bean handle paths into the supplied set.voidgetConfigValue(String path, String attr, ConfigValue value) Populate the specified value bean with the effective value of the specified attribute from this source.intgetRank()Returns the rank of the source, which is used to order sources.voidloadXmlConfigSource(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.voidloadXmlConfigSource(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, waitMethods 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:ConfigSourceReturns the rank of the source, which is used to order sources. Sources with higher ranks override sources with lower ranks.- Specified by:
getRankin interfaceConfigSource
-
gatherConfigPaths
Description copied from interface:ConfigSourcePut all available config bean handle paths into the supplied set.- Specified by:
gatherConfigPathsin interfaceConfigSource
-
gatherConfigForPath
Description copied from interface:ConfigSourcePut 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:
gatherConfigForPathin interfaceConfigSource- Parameters:
path- the handle path to return data forconfig- map to hold the resulting config data
-
getConfigValue
Description copied from interface:ConfigSourcePopulate the specified value bean with the effective value of the specified attribute from this source.- Specified by:
getConfigValuein 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:ConfigSourcePut all available option bean handle paths into the supplied set. Most sources don't support this so by default it does nothing.- Specified by:
gatherOptionsPathsin interfaceConfigSource
-
gatherOptionsForPath
Description copied from interface:ConfigSourcePut 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:
gatherOptionsForPathin interfaceConfigSource- Parameters:
path- the handle path to return data foroptions- map to put the options into
-