Class ConfigReader

java.lang.Object
org.pipservices3.components.config.ConfigReader
All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable, IConfigReader
Direct Known Subclasses:
FileConfigReader

public abstract class ConfigReader extends Object implements org.pipservices3.commons.config.IConfigurable, IConfigReader
Abstract config reader that supports configuration parameterization.

### Configuration parameters ###

  • parameters: this entire section is used as template parameters
  • ...

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addChangeListener(org.pipservices3.commons.run.INotifiable listener)
    Adds a listener that will be notified when configuration is changed
    void
    configure(org.pipservices3.commons.config.ConfigParams config)
    Configures component by passing configuration parameters.
    protected static String
    parameterize(String config, org.pipservices3.commons.config.ConfigParams parameters)
    Parameterized configuration template given as string with dynamic parameters.
    abstract org.pipservices3.commons.config.ConfigParams
    readConfig(String correlationId, org.pipservices3.commons.config.ConfigParams parameters)
    Reads configuration and parameterize it with given values.
    void
    removeChangeListener(org.pipservices3.commons.run.INotifiable listener)
    Remove a previously added change listener.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigReader

      public ConfigReader()
  • Method Details

    • configure

      public void configure(org.pipservices3.commons.config.ConfigParams config)
      Configures component by passing configuration parameters.
      Specified by:
      configure in interface org.pipservices3.commons.config.IConfigurable
      Parameters:
      config - configuration parameters to be set.
    • readConfig

      public abstract org.pipservices3.commons.config.ConfigParams readConfig(String correlationId, org.pipservices3.commons.config.ConfigParams parameters) throws org.pipservices3.commons.errors.ApplicationException
      Reads configuration and parameterize it with given values.
      Specified by:
      readConfig in interface IConfigReader
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      parameters - values to parameters the configuration or null to skip parameterization.
      Returns:
      ConfigParams configuration.
      Throws:
      org.pipservices3.commons.errors.ApplicationException - when error occured.
    • parameterize

      protected static String parameterize(String config, org.pipservices3.commons.config.ConfigParams parameters) throws Exception
      Parameterized configuration template given as string with dynamic parameters.

      The method uses Handlebars template engine.

      Parameters:
      config - a string with configuration template to be parameterized
      parameters - dynamic parameters to inject into the template
      Returns:
      a parameterized configuration string.
      Throws:
      IOException - when input/output error occured.
      Exception
    • addChangeListener

      public void addChangeListener(org.pipservices3.commons.run.INotifiable listener)
      Adds a listener that will be notified when configuration is changed
      Specified by:
      addChangeListener in interface IConfigReader
      Parameters:
      listener - a listener to be added.
    • removeChangeListener

      public void removeChangeListener(org.pipservices3.commons.run.INotifiable listener)
      Remove a previously added change listener.
      Specified by:
      removeChangeListener in interface IConfigReader
      Parameters:
      listener - a listener to be removed.