A convenience class which simplifies the creation of standard configurations and their builders.
Complex initializations of configuration builders can be done in a pretty straight-forward way by making use of the provided fluent API. However, if only default settings are used (and maybe a configuration file to be loaded has to be specified), this approach tends to become a bit verbose. This class was introduced to simplify the creation of configuration objects in such cases. It offers a bunch of methods which allow the creation of some standard configuration classes with default settings passing in only a minimum required parameters.
An an example consider the creation of a {@code PropertiesConfiguration}object from a file. Using a builder, code like the following one would have to be written:
Parameters params = new Parameters(); FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<PropertiesConfiguration>( PropertiesConfiguration.class).configure(params.fileBased() .setFile(new File("config.properties"))); PropertiesConfiguration config = builder.getConfiguration();With a convenience method of {@code Configurations} the same can be achievedwith the following:
Configurations configurations = new Configurations(); PropertiesConfiguration config = configurations.properties(new File( "config.properties"));There are similar methods for constructing builder objects from which configurations can then be obtained.
This class is thread-safe. A single instance can be created by an application and used in a central way to create configuration objects. When an instance is created a {@link Parameters} instance can be passed in. Otherwise, adefault instance is created. In any case, the {@code Parameters} instanceassociated with a {@code Configurations} object can be used to define defaultsettings for the configurations to be created.
@version $Id: Configurations.java 1624601 2014-09-12 18:04:36Z oheger $ @since 2.0 @see org.apache.commons.configuration2.builder.DefaultParametersManager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|