Package org.bytemechanics.config.manager
Class ConfigManagerImpl
java.lang.Object
org.bytemechanics.config.manager.ConfigManagerImpl
- All Implemented Interfaces:
ConfigManager
public class ConfigManagerImpl extends java.lang.Object implements ConfigManager
Config manager service implementation
- Author:
- afarre
-
Constructor Summary
Constructors Constructor Description ConfigManagerImpl(java.lang.String... _locations)Config manager constructor using the default charsetConfigManagerImpl(java.net.URI... _locations)Config manager constructor using the default charsetConfigManagerImpl(java.nio.charset.Charset _charset, java.lang.String... _locations)Config manager constructorConfigManagerImpl(java.nio.charset.Charset _charset, java.net.URI... _locations)Config manager constructorConfigManagerImpl(java.util.List<java.net.URI> _locations, java.nio.charset.Charset _charset)Config manager constructor -
Method Summary
Modifier and Type Method Description java.nio.charset.CharsetgetCharset()Retrieve the effective charset (provided or default) to use loading configurationsjava.util.List<java.net.URI>getLocations()Retrieve the list of locations from where to load configurationsvoidload()Reads all configured locations and populate into System propertiesjava.util.stream.Stream<Config>read(java.net.URI _location)Reads the uri location if possible returning a configuration streamprotected java.util.stream.Stream<Config>read(java.net.URI _location, java.io.Reader _reader)Read configuration from the given _reader population as streamjava.util.stream.Stream<Config>stream()Reads all configured locations and return as streamprotected voidwrite(java.net.URI _location, java.io.Writer _writer, java.util.stream.Stream<Config> _config)Write configuration to the given _writer from the given _config streamvoidwrite(java.net.URI _location, java.util.stream.Stream<Config> _config)Utility method to update configuration locations when possible
-
Constructor Details
-
ConfigManagerImpl
public ConfigManagerImpl(java.util.List<java.net.URI> _locations, java.nio.charset.Charset _charset)Config manager constructor- Parameters:
_locations- list of URIs to load configurations_charset- charset to use to load the configurations
-
ConfigManagerImpl
public ConfigManagerImpl(java.nio.charset.Charset _charset, java.net.URI... _locations)Config manager constructor- Parameters:
_charset- charset to use to load the configurations_locations- list of URIs to load configurations
-
ConfigManagerImpl
public ConfigManagerImpl(java.nio.charset.Charset _charset, java.lang.String... _locations)Config manager constructor- Parameters:
_charset- charset to use to load the configurations_locations- list of locations to load configurations
-
ConfigManagerImpl
public ConfigManagerImpl(java.net.URI... _locations)Config manager constructor using the default charset- Parameters:
_locations- list of URIs to load configurations
-
ConfigManagerImpl
public ConfigManagerImpl(java.lang.String... _locations)Config manager constructor using the default charset- Parameters:
_locations- list of locations to load configurations
-
-
Method Details
-
getCharset
public java.nio.charset.Charset getCharset()Retrieve the effective charset (provided or default) to use loading configurations- Returns:
- effective charset
-
getLocations
public java.util.List<java.net.URI> getLocations()Retrieve the list of locations from where to load configurations- Returns:
- locations to load configurations
-
read
Read configuration from the given _reader population as stream- Parameters:
_location- configuration location to discern reader the format_reader- reader from where configuration must be readed- Returns:
- stream of read configurations
- Throws:
UnsupportedConfigLocationFormat- if the format of the location is not supportedjava.lang.NullPointerException- if any of parameters are null
-
write
protected void write(java.net.URI _location, java.io.Writer _writer, java.util.stream.Stream<Config> _config)Write configuration to the given _writer from the given _config stream- Parameters:
_location- configuration location to discern reader the format_writer- writer where configuration must be write down_config- configuration to be writen- Throws:
UnwritableConfigLocation- when for any reason the configuration can not be writenUnsupportedConfigLocationFormat- if the format of the location is not supportedjava.lang.UnsupportedOperationException- if write operation is not supported by the location format and/or schemejava.lang.NullPointerException- if any of parameters are null
-
read
Description copied from interface:ConfigManagerReads the uri location if possible returning a configuration stream- Specified by:
readin interfaceConfigManager- Parameters:
_location- location where read the configuration- Returns:
- Stream of configurations or an empty stream
- See Also:
ConfigManager.read(java.net.URI)
-
write
Description copied from interface:ConfigManagerUtility method to update configuration locations when possible- Specified by:
writein interfaceConfigManager- Parameters:
_location- location to update/create configuration_config- stream of config files to write- See Also:
ConfigManager.write(java.net.URI, java.util.stream.Stream)
-
stream
Description copied from interface:ConfigManagerReads all configured locations and return as stream- Specified by:
streamin interfaceConfigManager- Returns:
- Stream of configurations or an empty stream
- See Also:
ConfigManager.stream()
-
load
public void load()Description copied from interface:ConfigManagerReads all configured locations and populate into System properties- Specified by:
loadin interfaceConfigManager- See Also:
ConfigManager.load()
-