Package io.microsphere.metadata
Interface ConfigurationPropertyReader
-
- All Superinterfaces:
java.lang.Comparable<Prioritized>
,Prioritized
- All Known Implementing Classes:
DefaultConfigurationPropertyReader
public interface ConfigurationPropertyReader extends Prioritized
The SPI to read the list ofconfiguration properties
from various sources.- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ConfigurationProperty
,ConfigurationProperty
-
-
Field Summary
-
Fields inherited from interface io.microsphere.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.List<ConfigurationProperty>
read(java.io.InputStream inputStream)
Reads a list ofConfigurationProperty
objects from the providedInputStream
.default java.util.List<ConfigurationProperty>
read(java.io.Reader reader)
Reads a list ofConfigurationProperty
objects from the providedReader
.java.util.List<ConfigurationProperty>
read(java.lang.String content)
Reads a list ofConfigurationProperty
objects from the provided content string.-
Methods inherited from interface io.microsphere.lang.Prioritized
compareTo, getPriority
-
-
-
-
Method Detail
-
read
@Nonnull @Immutable default java.util.List<ConfigurationProperty> read(java.io.InputStream inputStream) throws java.lang.Throwable
Reads a list ofConfigurationProperty
objects from the providedInputStream
.This method reads configuration properties from the given input stream, using the default charset for decoding the content. It internally delegates to
read(Reader)
after wrapping the input stream into anInputStreamReader
.Example Usage
ConfigurationPropertiesReader reader = ...; // Obtain an instance try (InputStream inputStream = new FileInputStream("config.properties")) { List<ConfigurationProperty> properties = reader.load(inputStream); // Process the loaded properties }
- Parameters:
inputStream
- the input stream to read from; must not benull
- Returns:
- a list of
ConfigurationProperty
objects loaded from the input stream - Throws:
java.lang.Throwable
- if any error occurs during loading- See Also:
read(Reader)
-
read
@Nonnull @Immutable default java.util.List<ConfigurationProperty> read(java.io.Reader reader) throws java.lang.Throwable
Reads a list ofConfigurationProperty
objects from the providedReader
.This method reads configuration properties from the given reader by first copying its content into a string using
IOUtils.copyToString(Reader)
, then delegating toread(String)
to perform the actual parsing and loading.Example Usage
ConfigurationPropertiesReader reader = ...; // Obtain an instance try (Reader fileReader = new FileReader("config.properties")) { List<ConfigurationProperty> properties = reader.load(fileReader); // Process the loaded properties }
- Parameters:
reader
- the reader to read from; must not benull
- Returns:
- a list of
ConfigurationProperty
objects loaded from the reader - Throws:
java.lang.Throwable
- if any error occurs during loading- See Also:
read(String)
,IOUtils.copyToString(Reader)
-
read
@Nonnull @Immutable java.util.List<ConfigurationProperty> read(java.lang.String content) throws java.lang.Throwable
Reads a list ofConfigurationProperty
objects from the provided content string.This method parses and loads configuration properties from the given string content. The format of the content is determined by the specific implementation of this interface.
Example Usage
ConfigurationPropertiesReader reader = ...; // Obtain an instance String content = "property1=value1\nproperty2=value2"; List<ConfigurationProperty> properties = reader.load(content); // Process the loaded properties
- Parameters:
content
- the string content to parse and load from; must not benull
- Returns:
- a list of
ConfigurationProperty
objects loaded from the content - Throws:
java.lang.Throwable
- if any error occurs during loading- See Also:
ConfigurationProperty
-
-