Class MemoryConfigReader
java.lang.Object
org.pipservices3.components.config.MemoryConfigReader
- All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable
,org.pipservices3.commons.config.IReconfigurable
,IConfigReader
public class MemoryConfigReader extends Object implements IConfigReader, org.pipservices3.commons.config.IReconfigurable
Config reader that stores configuration in memory.
The reader supports parameterization using Handlebars template engine.
### Configuration parameters ###
The configuration parameters are the configuration template
### Example ####
ConfigParams config = ConfigParams.fromTuples(
"connection.host", "{{SERVICE_HOST}}",
"connection.port", "{{SERVICE_PORT}}{{^SERVICE_PORT}}8080{{/SERVICE_PORT}}"
);
MemoryConfigReader configReader = new MemoryConfigReader();
configReader.configure(config);
ConfigParams parameters = ConfigParams.fromValue(process.env);
configReader.readConfig("123", parameters);
- See Also:
IConfigReader
-
Field Summary
Fields Modifier and Type Field Description protected org.pipservices3.commons.config.ConfigParams
_config
-
Constructor Summary
Constructors Constructor Description MemoryConfigReader()
Creates a new instance of config reader.MemoryConfigReader(org.pipservices3.commons.config.ConfigParams config)
Creates a new instance of config reader. -
Method Summary
Modifier and Type Method Description void
configure(org.pipservices3.commons.config.ConfigParams config)
Configures component by passing configuration parameters.org.pipservices3.commons.config.ConfigParams
readConfig(String correlationId, org.pipservices3.commons.config.ConfigParams parameters)
Reads configuration and parameterize it with given values.org.pipservices3.commons.config.ConfigParams
readConfigSection(String correlationId, String section)
-
Field Details
-
_config
protected org.pipservices3.commons.config.ConfigParams _config
-
-
Constructor Details
-
MemoryConfigReader
public MemoryConfigReader()Creates a new instance of config reader. -
MemoryConfigReader
public MemoryConfigReader(org.pipservices3.commons.config.ConfigParams config)Creates a new instance of config reader.- Parameters:
config
- (optional) component configuration parameters
-
-
Method Details
-
configure
public void configure(org.pipservices3.commons.config.ConfigParams config)Configures component by passing configuration parameters.- Specified by:
configure
in interfaceorg.pipservices3.commons.config.IConfigurable
- Parameters:
config
- configuration parameters to be set.
-
readConfig
public org.pipservices3.commons.config.ConfigParams readConfig(String correlationId, org.pipservices3.commons.config.ConfigParams parameters)Reads configuration and parameterize it with given values.- Specified by:
readConfig
in interfaceIConfigReader
- 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.
-
readConfigSection
-