public class ConfigBuilder extends Object
Usage pattern is trivial: create configuration builder instance for desired configuration source and invoke build()
.
ConfigBuilder builder = new ConfigBuilder(new File("conf/logs.xml")); Config config = builder.build();
Current builder implementation supports two main configuration sources: XML and Java properties.
Modifier and Type | Class and Description |
---|---|
private static class |
ConfigBuilder.Loader
SAX handler for configuration object loading from XML source.
|
Modifier and Type | Field and Description |
---|---|
private Properties |
properties
Configuration properties.
|
private InputStream |
xmlStream
Configuration source XML stream.
|
Modifier | Constructor and Description |
---|---|
protected |
ConfigBuilder()
Protected default constructor for sub-classing.
|
|
ConfigBuilder(File xmlFile)
Create configuration builder from XML file.
|
|
ConfigBuilder(InputStream xmlStream)
Create configuration builder from XML stream.
|
|
ConfigBuilder(Properties properties)
Create configuration builder from Java properties.
|
|
ConfigBuilder(String xml)
Create configuration builder from XML represented as string, merrely for tests.
|
private InputStream xmlStream
private Properties properties
public ConfigBuilder(String xml)
xml
- source XML serialized as string.public ConfigBuilder(File xmlFile) throws FileNotFoundException
xmlFile
- source XML file.FileNotFoundException
- if source XML file does not exist.public ConfigBuilder(InputStream xmlStream)
xmlStream
- source XML stream.public ConfigBuilder(Properties properties)
properties
- source properties.protected ConfigBuilder()
public Config build() throws ConfigException
ConfigException
- if XML stream read operation fails or is not well formed.Copyright © 2018. All rights reserved.