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:
IConfigReader
  • Constructor Summary

    Constructors
    Constructor Description
    ConfigReader()  
  • Method Summary

    Modifier and Type Method Description
    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.

    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 IOException
      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.