Class ConfigService

java.lang.Object
com.kosdev.kos.commons.core.service.config.ConfigService

public final class ConfigService extends Object
System service that manages all configuration data and can apply configuration data on top of any ConfigAware object.

As of api version 10, most api's have been duplicated to add support for a src parameter. This value will be included in log output and allows developers to determine who is changing config values by simply reading the logs. The original methods have been marked deprecated in order to encourage the use of the src parameter while will maintaining backwards binary compatibility.

Since:
1
Version:
10
  • Field Details

  • Method Details

    • getNodeLocalSource

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

      @Deprecated public ConfigChanges configureUnconfigured(String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      Configure any ConfigAware bean that has not yet been configured.
      Parameters:
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
      Since:
      1
    • configureUnconfigured

      public ConfigChanges configureUnconfigured(String src, String tracker)
      Configure any ConfigAware bean that has not yet been configured. This includes an optional src which will be used to label the log entries.
      Parameters:
      src - the source of the change, included in logs
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
      Since:
      10
    • configurePath

      @Deprecated public ConfigChanges configurePath(String path, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • configurePath

      public ConfigChanges configurePath(String path, String src, 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
      src - the source of the change, included in logs
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
      Since:
      10
    • configurePath

      @Deprecated public ConfigChanges configurePath(Collection<String> paths, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • configurePath

      public ConfigChanges configurePath(Collection<String> paths, String src, 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
      src - the source of the change, included in logs
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
      Since:
      10
    • configureConfigAware

      @Deprecated public ConfigChanges configureConfigAware(ConfigAware<?> bean, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • configureConfigAware

      public ConfigChanges configureConfigAware(ConfigAware<?> bean, String src, String tracker)
      Configure a ConfigAware bean and tag the results with the specified tracker.
      Parameters:
      bean - the bean to configure
      src - the source of the change, included in logs
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
      Since:
      10
    • configureConfigAware

      @Deprecated public ConfigChanges configureConfigAware(Collection<ConfigAware<?>> beans, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • configureConfigAware

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

      @Deprecated public ConfigChanges configureBean(Object bean, String path, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • configureBean

      public ConfigChanges configureBean(Object bean, String path, String src, 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
      src - the source of the change, included in logs
      tracker - optional tracker to tag the changes
      Returns:
      the changes made
      Since:
      10
    • update

      @Deprecated public ConfigChanges update(ConfigAware<?> bean, String attr, Object val, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • update

      public ConfigChanges update(ConfigAware<?> bean, String attr, Object val, String src, 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)
      src - source of the change, included in logs
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the config
      Since:
      10
    • update

      @Deprecated public ConfigChanges update(ConfigAware<?> bean, Map<String,Object> attrs, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • update

      public ConfigChanges update(ConfigAware<?> bean, Map<String,Object> attrs, String src, 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
      src - source of the change, included in logs
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the config
      Since:
      10
    • update

      @Deprecated public ConfigChanges update(BeanUpdate beanUpdate, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • update

      public ConfigChanges update(BeanUpdate beanUpdate, String src, 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
      src - source of the change, included in logs
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the config
      Since:
      10
    • update

      @Deprecated public ConfigChanges update(Collection<BeanUpdate> beanUpdates, String tracker)
      Deprecated.
      Consider version with src parameter for improved logging
      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
      Since:
      1
    • update

      public ConfigChanges update(Collection<BeanUpdate> beanUpdates, String src, 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
      src - source of the changes, included in logs
      tracker - optional tracker to put in the changes
      Returns:
      the changes applied to the configs
      Since:
      10
    • 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
      Since:
      1
    • 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
      Since:
      1
    • 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
      Since:
      1
    • 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
      Since:
      1
    • 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
      Since:
      1
    • 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
      Since:
      1