public class ConfigRegistry extends Object
Modifier and Type | Method and Description |
---|---|
void |
addConfiguration(String key,
Object value)
Add the specified key/value pair as a configuration entry.
|
void |
addConfiguration(String tableHeader,
String tableField,
Object value)
Add the specified key/value pair as a configuration entry.
|
void |
addEncryptedConfiguration(String key,
String value)
Encrypts the value before adding the specified key/value pair as a configuration entry.
|
void |
addEncryptedConfiguration(String tableHeader,
String tableField,
String value)
Encrypts the given value before adding the specified key/value pair as a configuration entry.
|
boolean |
contains(String key)
Checks whether the given key is present in the Config Registry.
|
boolean |
contains(String tableHeader,
String tableField)
Checks whether the given header/field combination is present in the Config Registry.
|
boolean |
getAsBoolean(String key)
Retrieves the config value specified by the key as a boolean.
|
boolean |
getAsBoolean(String sectionHeader,
String field)
Retrieves the config value specified by the section header and the field.
|
double |
getAsFloat(String key)
Retrieves the config value specified by the key as a float.
|
double |
getAsFloat(String sectionHeader,
String field)
Retrieves the config value specified by the section header and the field.
|
long |
getAsInt(String key)
Retrieves the config value specified by the key as an int.
|
long |
getAsInt(String sectionHeader,
String field)
Retrieves the config value specified by the section header and the field.
|
Map<String,Object> |
getAsMap(String key)
Retrieves the config value specified by the key as a float.
|
Map<String,Object> |
getAsMap(String sectionHeader,
String field)
Retrieves the config value specified by the section header and the field.
|
String |
getAsString(String key)
Retrieve the configuration value mapped by the specified key.
|
String |
getAsString(String tableHeader,
String tableField)
Retrieve the configuration value mapped by the specified table header and table field.
|
char[] |
getConfigAsCharArray(String key)
Retrieve the configuration value mapped by the specified key as a char array.
|
char[] |
getConfigAsCharArray(String tableHeader,
String tableField)
Retrieve the configuration value mapped by the specified table header and table field as a char array.
|
String |
getConfigOrDefault(String key,
String defaultValue)
Retrieve the configuration value mapped by the specified key.
|
Map<String,String> |
getConfigTable(String tableHeader)
Deprecated.
|
Object |
getConfiguration(String key)
Retrieves the config value specified by the key.
|
Object |
getConfiguration(String sectionHeader,
String field)
Retrieves the config value specified by the section header and the field.
|
static ConfigRegistry |
getInstance() |
void |
initRegistry(Map<String,String> runtimeParams,
String configFilePath,
Path ballerinaConfPath)
Prepares for parsing and loading the configurations by initializing the config processor.
|
Iterator<String> |
keySetIterator()
Returns an iterator for the key set of the config registry.
|
Object |
removeConfiguration(String key)
Removes the specified key from the Config Registry.
|
void |
resetRegistry()
Removes all the entries in the Config Registry.
|
public static ConfigRegistry getInstance()
public void initRegistry(Map<String,String> runtimeParams, String configFilePath, Path ballerinaConfPath) throws IOException
runtimeParams
- The Ballerina runtime parameters (-B params)configFilePath
- The path to the user provided Ballerina config fileballerinaConfPath
- Path to the default ballerina.conf fileIOException
public void addConfiguration(String key, Object value)
key
- The configuration keyvalue
- The configuration valuepublic void addConfiguration(String tableHeader, String tableField, Object value)
tableHeader
- The name of the TOML table to which the config will be addedtableField
- The config key under which the config value will be mapped in the tablevalue
- The configuration valuepublic void addEncryptedConfiguration(String key, String value)
key
- The configuration keyvalue
- The configuration valuepublic void addEncryptedConfiguration(String tableHeader, String tableField, String value)
tableHeader
- The name of the TOML table to which the config will be addedtableField
- The config key under which the config value will be mapped in the tablevalue
- The configuration valuepublic boolean contains(String key)
key
- The key to look-uppublic boolean contains(String tableHeader, String tableField)
tableHeader
- The name of the TOML table to look-uptableField
- The config key under which the config value will be mapped in the tablepublic Object getConfiguration(String key)
key
- The key of the config entrypublic Object getConfiguration(String sectionHeader, String field)
sectionHeader
- The header namefield
- The field in the sectionpublic boolean getAsBoolean(String key)
key
- The key of the config entrypublic boolean getAsBoolean(String sectionHeader, String field)
sectionHeader
- The header namefield
- The field in the sectionpublic long getAsInt(String key)
key
- The key of the config entrypublic long getAsInt(String sectionHeader, String field)
sectionHeader
- The header namefield
- The field in the sectionpublic double getAsFloat(String key)
key
- The key of the config entrypublic double getAsFloat(String sectionHeader, String field)
sectionHeader
- The header namefield
- The field in the sectionpublic Map<String,Object> getAsMap(String key)
key
- The key of the config entrypublic Map<String,Object> getAsMap(String sectionHeader, String field)
sectionHeader
- The header namefield
- The field in the sectionpublic String getAsString(String key)
key
- The key of the configuration valuepublic String getAsString(String tableHeader, String tableField)
tableHeader
- The name of the TOML table which contains the configurationtableField
- The config key under which the config value is mapped in the tablepublic char[] getConfigAsCharArray(String key)
key
- The key of the configuration valuepublic char[] getConfigAsCharArray(String tableHeader, String tableField)
tableHeader
- The name of the TOML table which contains the configurationtableField
- The config key under which the config value is mapped in the tablepublic String getConfigOrDefault(String key, String defaultValue)
key
- The key of the configuration valuedefaultValue
- The value to be used if the key is not in the registry@Deprecated public Map<String,String> getConfigTable(String tableHeader)
tableHeader
- The table name to retrievepublic Iterator<String> keySetIterator()
public Object removeConfiguration(String key)
key
- The key for the configuration value to be removedpublic void resetRegistry()
Copyright © 2018 WSO2. All rights reserved.