Class ConfigService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.commons.core.service.config.ConfigService
- All Implemented Interfaces:
CtxEventListener
,ContextHandleAware
,HandleAware
,Ready
,ReadyListener
System service that manages all configuration data and can apply configuration data
on top of any ConfigAware object.
- Since:
- 1.0
- Version:
- 2023-03-06
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOptionsType
(String type, Class<? extends ConfigOptions> clazz) Register an options type for converting options json to options beans.configureBean
(Object bean, String path, String tracker) Configure an arbitrary bean using the settings associated with the specified handle path and tag the results with the specified tracker.configureConfigAware
(ConfigAware<?> bean, String tracker) Configure a ConfigAware bean and tag the results with the specified tracker.configureConfigAware
(Collection<ConfigAware<?>> beans, String tracker) Configure a collection of ConfigAware beans and tag the results with the specified tracker.configurePath
(String path, String tracker) Configure a ConfigAware bean identified by the specified handle path and tag the results with the specified tracker.configurePath
(Collection<String> paths, String tracker) Configure the list of ConfigAware bean identified by the specified handle paths and tag the results with the specified tracker.configureUnconfigured
(String tracker) Configure any ConfigAware bean that has not yet been configured.getConfigValueForScopedPath
(String scopedPath, String attr) Return the config value of an attribute from the scope implied by the path.getDefaultsForScopedPath
(String scopedPath) Return the default values for the specified scoped path.getMergedConfigForPath
(String path) Return the config data for the specified handle path.getMergedConfigValueForScopedPath
(String scopedPath, String attr) Return the merged config value of an attribute starting at the scope implied within the path.Get theDefaultConfigSource
for the local node scope.getOverridesForScopedPath
(String scopedPath) Return the overrides for the specified scoped path.void
Override of theReadyListener
interface.update
(BeanUpdate beanUpdate, String tracker) Update the ConfigAware bean referenced by the handle path in the updates with the values in the updates object.update
(ConfigAware<?> bean, String attr, Object val, String tracker) Update the specified attribute of the config for the specified bean to the specified value.Update the attributes of the config for the specified bean to the values specified in the map.update
(Collection<BeanUpdate> beanUpdates, String tracker) Update all the beans identified by the list of updates.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefix
Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onBeanReady
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.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Field Details
-
SCOPE_SEPARATOR
- See Also:
-
REVERT_VALUE
- See Also:
-
-
Method Details
-
onDependenciesReady
public void onDependenciesReady()Description copied from class:ReadyBean
Override of theReadyListener
interface. This will callonBeanReady()
and returning true will cause this bean to be marked ready. OverridingonBeanReady
is much safer as it explicitly indicates ready or not whereas overriding this method requires the caller to remember to callsuper.onDependenciesReady()
or explicitly callsetReady()
which is error prone.- Specified by:
onDependenciesReady
in interfaceReadyListener
- Overrides:
onDependenciesReady
in classReadyBean
-
getNodeLocalSource
Get theDefaultConfigSource
for the local node scope. This allows sources private to the node to be installed. -
configureUnconfigured
Configure any ConfigAware bean that has not yet been configured.- Parameters:
tracker
- optional tracker to tag the changes- Returns:
- the changes made
-
configurePath
Configure a ConfigAware bean identified by the specified handle path and tag the results with the specified tracker.- Parameters:
path
- handle path of the bean to configuretracker
- optional tracker to tag the changes- Returns:
- the changes made
-
configurePath
Configure the list of ConfigAware bean identified by the specified handle paths and tag the results with the specified tracker.- Parameters:
paths
- handle paths of the beans to configuretracker
- optional tracker to tag the changes- Returns:
- the changes made
-
configureConfigAware
Configure a ConfigAware bean and tag the results with the specified tracker.- Parameters:
bean
- the bean to configuretracker
- optional tracker to tag the changes- Returns:
- the changes made
-
configureConfigAware
Configure a collection of ConfigAware beans and tag the results with the specified tracker.- Parameters:
beans
- the beans to configuretracker
- optional tracker to tag the changes- Returns:
- the changes made
-
configureBean
Configure an arbitrary bean using the settings associated with the specified handle path and tag the results with the specified tracker.- Parameters:
bean
- bean to configurepath
- handle path to use for settingstracker
- optional tracker to tag the changes- Returns:
- the changes made
-
update
Update the specified attribute of the config for the specified bean to the specified value.- Parameters:
bean
- the bean to get the config fromattr
- the config attribute to updateval
- the new value (converted to simple type)tracker
- optional tracker to put in the changes- Returns:
- the changes applied to the config
-
update
Update the attributes of the config for the specified bean to the values specified in the map.- Parameters:
bean
- the bean to get the config fromattrs
- the attribute names / values to updatetracker
- optional tracker to put in the changes- Returns:
- the changes applied to the config
-
update
Update the ConfigAware bean referenced by the handle path in the updates with the values in the updates object.- Parameters:
beanUpdate
- identifies the handle path and contains the attributes / valuestracker
- optional tracker to put in the changes- Returns:
- the changes applied to the config
-
update
Update all the beans identified by the list of updates.- Parameters:
beanUpdates
- the list of beans to update along with attributes / values per beantracker
- optional tracker to put in the changes- Returns:
- the changes applied to the configs
-
getMergedConfigForPath
Return the config data for the specified handle path. This will start with the defaults and then apply the overrides on top.- Parameters:
path
- the handle path to return config data for- Returns:
- the config data
-
getOverridesForScopedPath
Return the overrides for the specified scoped path. On the primary node this can return data for scopes on other nodes.- Parameters:
scopedPath
- the scoped path to return overrides for- Returns:
- the overrides
-
getDefaultsForScopedPath
Return the default values for the specified scoped path. On the primary node this can return data for scopes on other nodes.- Parameters:
scopedPath
- the scoped path to return defaults for- Returns:
- the default values
-
getMergedConfigValueForScopedPath
Return the merged config value of an attribute starting at the scope implied within the path. This will apply all scope override rules to return a single effective value. If specifying a nodeType or global scope, no config bean defaults will be applied as config bean defaults are specific to a particular nodeId scope.- Parameters:
scopedPath
- the scope and path of the configattr
- the attribute of the config
-
getConfigValueForScopedPath
Return the config value of an attribute from the scope implied by the path. This will only examine values in the scope (defaults + overrides) and will not reflect data from any other scope.- Parameters:
scopedPath
- the scope and path of the configattr
- the attribute of the config
-
addOptionsType
Register an options type for converting options json to options beans.- Parameters:
type
- options typeclazz
- options class
-