Class ConfigService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, Ready, ReadyListener

public final class ConfigService extends AbstractService
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 Details

  • Method Details

    • onDependenciesReady

      public void onDependenciesReady()
      Description copied from class: ReadyBean
      Override of the ReadyListener interface. This will call onBeanReady() and returning true will cause this bean to be marked ready. Overriding onBeanReady is much safer as it explicitly indicates ready or not whereas overriding this method requires the caller to remember to call super.onDependenciesReady() or explicitly call setReady() which is error prone.
      Specified by:
      onDependenciesReady in interface ReadyListener
      Overrides:
      onDependenciesReady in class ReadyBean
    • getNodeLocalSource

      public DefaultConfigSource getNodeLocalSource()
      Get the DefaultConfigSource for the local node scope. This allows sources private to the node to be installed.
    • configureUnconfigured

      public ConfigChanges configureUnconfigured(String tracker)
      Configure any ConfigAware bean that has not yet been configured.
      Parameters:
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
    • configurePath

      public ConfigChanges configurePath(String path, String tracker)
      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 configure
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
    • configurePath

      public ConfigChanges 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.
      Parameters:
      paths - handle paths of the beans to configure
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
    • configureConfigAware

      public ConfigChanges configureConfigAware(ConfigAware<?> bean, String tracker)
      Configure a ConfigAware bean and tag the results with the specified tracker.
      Parameters:
      bean - the bean to configure
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
    • configureConfigAware

      public ConfigChanges configureConfigAware(Collection<ConfigAware<?>> beans, String tracker)
      Configure a collection of ConfigAware beans and tag the results with the specified tracker.
      Parameters:
      beans - the beans to configure
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
    • configureBean

      public ConfigChanges 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.
      Parameters:
      bean - bean to configure
      path - handle path to use for settings
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
    • update

      public ConfigChanges update(ConfigAware<?> bean, String attr, Object val, String tracker)
      Update the specified attribute of the config for the specified bean to the specified value.
      Parameters:
      bean - the bean to get the config from
      attr - the config attribute to update
      val - the new value (converted to simple type)
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the config
    • update

      public ConfigChanges update(ConfigAware<?> bean, Map<String,Object> attrs, String tracker)
      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 from
      attrs - the attribute names / values to update
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the config
    • update

      public ConfigChanges update(BeanUpdate beanUpdate, String tracker)
      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 / values
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the config
    • update

      public ConfigChanges update(Collection<BeanUpdate> beanUpdates, String tracker)
      Update all the beans identified by the list of updates.
      Parameters:
      beanUpdates - the list of beans to update along with attributes / values per bean
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the configs
    • getMergedConfigForPath

      public Map<String,String> getMergedConfigForPath(String path)
      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

      public Map<String,String> getOverridesForScopedPath(String scopedPath)
      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

      public Map<String,String> getDefaultsForScopedPath(String scopedPath)
      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

      public ConfigValue getMergedConfigValueForScopedPath(String scopedPath, String attr)
      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 config
      attr - the attribute of the config
    • getConfigValueForScopedPath

      public ConfigValue getConfigValueForScopedPath(String scopedPath, String attr)
      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 config
      attr - the attribute of the config
    • addOptionsType

      public void addOptionsType(String type, Class<? extends ConfigOptions> clazz)
      Register an options type for converting options json to options beans.
      Parameters:
      type - options type
      clazz - options class