Package io.dropwizard.configuration
Class BaseConfigurationFactory<T>
- java.lang.Object
-
- io.dropwizard.configuration.BaseConfigurationFactory<T>
-
- Type Parameters:
T- the type of the configuration objects to produce
- All Implemented Interfaces:
ConfigurationFactory<T>
- Direct Known Subclasses:
JsonConfigurationFactory,YamlConfigurationFactory
public abstract class BaseConfigurationFactory<T> extends Object implements ConfigurationFactory<T>
A generic factory class for loading configuration files, binding them to configuration objects, and validating their constraints. Allows for overriding configuration parameters from system properties.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.databind.ObjectMappermapper
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseConfigurationFactory(com.fasterxml.jackson.core.JsonFactory parserFactory, String formatName, Class<T> klass, @Nullable javax.validation.Validator validator, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String propertyPrefix)Creates a new configuration factory for the given class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddOverride(com.fasterxml.jackson.databind.JsonNode root, String name, String value)Tbuild()Loads, parses, binds, and validates a configuration object from an empty document.protected Tbuild(com.fasterxml.jackson.databind.JsonNode node, String path)Tbuild(ConfigurationSourceProvider provider, String path)Loads, parses, binds, and validates a configuration object.protected com.fasterxml.jackson.core.JsonParsercreateParser(InputStream input)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.dropwizard.configuration.ConfigurationFactory
build
-
-
-
-
Constructor Detail
-
BaseConfigurationFactory
protected BaseConfigurationFactory(com.fasterxml.jackson.core.JsonFactory parserFactory, String formatName, Class<T> klass, @Nullable javax.validation.Validator validator, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String propertyPrefix)Creates a new configuration factory for the given class.- Parameters:
parserFactory- the factory that creates the parser usedformatName- the name of the format parsed by this factory (used in exceptions)klass- the configuration classvalidator- the validator to usepropertyPrefix- the system property name prefix used by overrides
-
-
Method Detail
-
build
public T build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException
Description copied from interface:ConfigurationFactoryLoads, parses, binds, and validates a configuration object.- Specified by:
buildin interfaceConfigurationFactory<T>- Parameters:
provider- the provider to to use for reading configuration filespath- the path of the configuration file- Returns:
- a validated configuration object
- Throws:
IOException- if there is an error reading the fileConfigurationException- if there is an error parsing or validating the file
-
createParser
protected com.fasterxml.jackson.core.JsonParser createParser(InputStream input) throws IOException
- Throws:
IOException
-
build
public T build() throws IOException, ConfigurationException
Description copied from interface:ConfigurationFactoryLoads, parses, binds, and validates a configuration object from an empty document.- Specified by:
buildin interfaceConfigurationFactory<T>- Returns:
- a validated configuration object
- Throws:
IOException- if there is an error reading the fileConfigurationException- if there is an error parsing or validating the file
-
build
protected T build(com.fasterxml.jackson.databind.JsonNode node, String path) throws IOException, ConfigurationException
- Throws:
IOExceptionConfigurationException
-
-