Class CombinedConfigurationBuilderProvider
- java.lang.Object
-
- org.apache.commons.configuration2.builder.combined.BaseConfigurationBuilderProvider
-
- org.apache.commons.configuration2.builder.combined.CombinedConfigurationBuilderProvider
-
- All Implemented Interfaces:
ConfigurationBuilderProvider
public class CombinedConfigurationBuilderProvider extends BaseConfigurationBuilderProvider
A specialized
ConfigurationBuilderProvider
implementation which deals with combined configuration builders.This class is used to support
<configuration>
elements in configuration definition files. The provider creates anotherCombinedConfigurationBuilder
which inherits some of the properties from its parent builder.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
BUILDER_CLASS
Constant for the name of the supported builder class.private static java.lang.String
COMBINED_PARAMS
Constant for the combined configuration builder parameters class.private static java.lang.String
CONFIGURATION_CLASS
Constant for the name of the supported configuration class.private static java.lang.String
FILE_PARAMS
Constant for the name of the file-based builder parameters class.private static java.lang.String
RELOADING_BUILDER_CLASS
Constant for the name of the supported reloading builder class.
-
Constructor Summary
Constructors Constructor Description CombinedConfigurationBuilderProvider()
Creates a new instance ofCombinedConfigurationBuilderProvider
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BasicConfigurationBuilder<? extends Configuration>
createBuilder(ConfigurationDeclaration decl, java.util.Collection<BuilderParameters> params)
Creates a new, uninitialized instance of the builder class managed by this provider.protected void
initializeParameterObjects(ConfigurationDeclaration decl, java.util.Collection<BuilderParameters> params)
Initializes the parameter objects with data stored in the current bean declaration.private static void
setUpBasicParameters(CombinedConfiguration config, BasicBuilderParameters params)
Populates the specified parameters object with properties from the given configuration.-
Methods inherited from class org.apache.commons.configuration2.builder.combined.BaseConfigurationBuilderProvider
configureBuilder, createParameterObjects, determineBuilderClass, determineConfigurationClass, getBuilderClass, getConfigurationBuilder, getConfigurationClass, getParameterClasses, getReloadingBuilderClass, inheritParentBuilderProperties, isAllowFailOnInit
-
-
-
-
Field Detail
-
BUILDER_CLASS
private static final java.lang.String BUILDER_CLASS
Constant for the name of the supported builder class.- See Also:
- Constant Field Values
-
RELOADING_BUILDER_CLASS
private static final java.lang.String RELOADING_BUILDER_CLASS
Constant for the name of the supported reloading builder class.- See Also:
- Constant Field Values
-
CONFIGURATION_CLASS
private static final java.lang.String CONFIGURATION_CLASS
Constant for the name of the supported configuration class.- See Also:
- Constant Field Values
-
COMBINED_PARAMS
private static final java.lang.String COMBINED_PARAMS
Constant for the combined configuration builder parameters class.- See Also:
- Constant Field Values
-
FILE_PARAMS
private static final java.lang.String FILE_PARAMS
Constant for the name of the file-based builder parameters class.- See Also:
- Constant Field Values
-
-
Method Detail
-
setUpBasicParameters
private static void setUpBasicParameters(CombinedConfiguration config, BasicBuilderParameters params)
Populates the specified parameters object with properties from the given configuration. This method is used to set default values for basic properties based on the result configuration of the parent builder.- Parameters:
config
- the configuration whose properties are to be copiedparams
- the target parameters object
-
createBuilder
protected BasicConfigurationBuilder<? extends Configuration> createBuilder(ConfigurationDeclaration decl, java.util.Collection<BuilderParameters> params) throws java.lang.Exception
Creates a new, uninitialized instance of the builder class managed by this provider. This implementation determines the builder class to be used by delegating todetermineBuilderClass()
. It then calls the constructor expecting the configuration class, the map with properties, and theallowFailOnInit flag. This implementation creates the result builder object directly, not using reflection. (The reflection-based approach of the base class does not work here because a combined configuration builder has constructors with a different signature.) It also performs some additional initializations.- Overrides:
createBuilder
in classBaseConfigurationBuilderProvider
- Parameters:
decl
- the currentConfigurationDeclaration
params
- initialization parameters for the new builder object- Returns:
- the newly created builder instance
- Throws:
java.lang.Exception
- if an error occurs
-
initializeParameterObjects
protected void initializeParameterObjects(ConfigurationDeclaration decl, java.util.Collection<BuilderParameters> params) throws java.lang.Exception
Initializes the parameter objects with data stored in the current bean declaration. This method is called before the newly created builder instance is configured with the parameter objects. It maps attributes of the bean declaration to properties of parameter objects. In addition, it invokes the parentCombinedConfigurationBuilder
so that the parameters object can inherit properties already defined for this builder. This implementation pre-fills basic parameters from the basic properties of the parent builder's result configuration.- Overrides:
initializeParameterObjects
in classBaseConfigurationBuilderProvider
- Parameters:
decl
- the currentConfigurationDeclaration
params
- the collection with (uninitialized) parameter objects- Throws:
java.lang.Exception
- if an error occurs
-
-