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.Charset
getCharset()
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 configurationsvoid
load()
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 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 streamvoid
write(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:ConfigManager
Reads the uri location if possible returning a configuration stream- Specified by:
read
in 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:ConfigManager
Utility method to update configuration locations when possible- Specified by:
write
in 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:ConfigManager
Reads all configured locations and return as stream- Specified by:
stream
in interfaceConfigManager
- Returns:
- Stream of configurations or an empty stream
- See Also:
ConfigManager.stream()
-
load
public void load()Description copied from interface:ConfigManager
Reads all configured locations and populate into System properties- Specified by:
load
in interfaceConfigManager
- See Also:
ConfigManager.load()
-