Class MultiFileConfigurationBuilderProvider
- java.lang.Object
-
- org.apache.commons.configuration2.builder.combined.BaseConfigurationBuilderProvider
-
- org.apache.commons.configuration2.builder.combined.MultiFileConfigurationBuilderProvider
-
- All Implemented Interfaces:
ConfigurationBuilderProvider
public class MultiFileConfigurationBuilderProvider extends BaseConfigurationBuilderProvider
A specialized
ConfigurationBuilderProvider
implementation for integratingMultiFileConfigurationBuilder
withCombinedConfigurationBuilder
.When using a configuration source managed by
MultiFileConfigurationBuilder
it is not sufficient to store the configuration once obtained from the builder in the resulting combined configuration. Rather, it has to be ensured that each access to this configuration queries the builder anew so that it can evaluate its file pattern and return a different configuration if necessary. Therefore, this class returns a specialized wrapper over aMultiFileConfigurationBuilder
which returns a configuration wrapping the builder; so accessing the configuration's properties actually calls back to the builder. This constellation is compatible with the wayDynamicCombinedConfiguration
manages its data.- Since:
- 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MultiFileConfigurationBuilderProvider.ReloadableWrapperBuilder
A wrapper builder implementation which also provides aReloadingController
.private static class
MultiFileConfigurationBuilderProvider.WrapperBuilder
A simple wrapper implementation of theConfigurationBuilder
interface which returns a fix configuration and delegates to another builder for event listener management.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
BUILDER_CLASS
Constant for the name of the builder class.private static java.lang.String
PARAM_CLASS
Constant for the name of the parameters class.private static java.lang.String
RELOADING_BUILDER_CLASS
Constant for the name of the reloading builder class.
-
Constructor Summary
Constructors Constructor Description MultiFileConfigurationBuilderProvider(java.lang.String configCls, java.lang.String paramCls)
Creates a new instance ofMultiFileConfigurationBuilderProvider
and sets the name of the configuration class to be returned byMultiFileConfigurationBuilder
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static ConfigurationBuilder<? extends Configuration>
createWrapperBuilder(ConfigurationBuilder<? extends Configuration> multiBuilder, Configuration wrapConfig)
Creates theConfigurationBuilder
to be returned by this provider.private Configuration
createWrapperConfiguration(ConfigurationBuilder builder)
Creates a configuration which wraps the specified builder.ConfigurationBuilder<? extends Configuration>
getConfigurationBuilder(ConfigurationDeclaration decl)
Gets the builder for the configuration source managed by this provider.-
Methods inherited from class org.apache.commons.configuration2.builder.combined.BaseConfigurationBuilderProvider
configureBuilder, createBuilder, createParameterObjects, determineBuilderClass, determineConfigurationClass, getBuilderClass, getConfigurationClass, getParameterClasses, getReloadingBuilderClass, inheritParentBuilderProperties, initializeParameterObjects, isAllowFailOnInit
-
-
-
-
Field Detail
-
BUILDER_CLASS
private static final java.lang.String BUILDER_CLASS
Constant for the name of the 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 reloading builder class.- See Also:
- Constant Field Values
-
PARAM_CLASS
private static final java.lang.String PARAM_CLASS
Constant for the name of the parameters class.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultiFileConfigurationBuilderProvider
public MultiFileConfigurationBuilderProvider(java.lang.String configCls, java.lang.String paramCls)
Creates a new instance ofMultiFileConfigurationBuilderProvider
and sets the name of the configuration class to be returned byMultiFileConfigurationBuilder
.- Parameters:
configCls
- the name of the managed configuration classparamCls
- the name of the class of the parameters object to configure the managed configuration
-
-
Method Detail
-
createWrapperBuilder
private static ConfigurationBuilder<? extends Configuration> createWrapperBuilder(ConfigurationBuilder<? extends Configuration> multiBuilder, Configuration wrapConfig)
Creates theConfigurationBuilder
to be returned by this provider. This is a very simple implementation which always returns the same wrapper configuration instance. The handling of builder listeners is delegated to the wrappedMultiFileConfigurationBuilder
. If reloading is support, the builder returned by this method also implements theReloadingControllerSupport
interface.- Parameters:
multiBuilder
- theMultiFileConfigurationBuilder
wrapConfig
- the configuration to be returned- Returns:
- the wrapper builder
-
createWrapperConfiguration
private Configuration createWrapperConfiguration(ConfigurationBuilder builder)
Creates a configuration which wraps the specified builder.- Parameters:
builder
- the builder- Returns:
- the wrapping configuration
-
getConfigurationBuilder
public ConfigurationBuilder<? extends Configuration> getConfigurationBuilder(ConfigurationDeclaration decl) throws ConfigurationException
Gets the builder for the configuration source managed by this provider. This method is called during processing of the combined configuration definition file. This implementation delegates to some protected methods to create a new builder instance using reflection and to configure it with parameter values defined by the passed inBeanDeclaration
. This implementation lets the super class create a fully configured builder. Then it returns a special wrapper around it.- Specified by:
getConfigurationBuilder
in interfaceConfigurationBuilderProvider
- Overrides:
getConfigurationBuilder
in classBaseConfigurationBuilderProvider
- Parameters:
decl
- the bean declaration with initialization parameters for the configuration builder- Returns:
- the
ConfigurationBuilder
object created by this provider - Throws:
ConfigurationException
- if an error occurs
-
-