Class ConfigurationPropertiesFactoryBean
java.lang.Object
org.apache.commons.configuration2.spring.ConfigurationPropertiesFactoryBean
- All Implemented Interfaces:
FactoryBean<Properties>
,InitializingBean
public class ConfigurationPropertiesFactoryBean
extends Object
implements InitializingBean, FactoryBean<Properties>
FactoryBean which wraps a Commons CompositeConfiguration object for usage with PropertiesLoaderSupport. This allows
the compositeConfiguration object to behave like a normal Properties
object which can be passed on to
setProperties() method allowing PropertyOverrideConfigurer and PropertyPlaceholderConfigurer to take advantage of
Commons Configuration.
Internally a CompositeConfiguration object is used for merging multiple Configuration objects.
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance.ConfigurationPropertiesFactoryBean
(Configuration configuration) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Gets the composite configuration.Gets a copy of the configurations.Resource[]
Gets a copy of the resource locations.Class
<?> boolean
boolean
Tests the underlying CompositeConfiguration throwExceptionOnMissing flag.void
setConfigurations
(Configuration... configurations) Sets the commons configurations objects which will be used as properties.void
setLocations
(Resource... locations) Shortcut for loading compositeConfiguration from Spring resources.void
setThrowExceptionOnMissing
(boolean throwExceptionOnMissing) Sets the underlying CompositeConfiguration throwExceptionOnMissing flag.
-
Constructor Details
-
ConfigurationPropertiesFactoryBean
public ConfigurationPropertiesFactoryBean()Constructs a new instance. -
ConfigurationPropertiesFactoryBean
Constructs a new instance.- Parameters:
configuration
- The configuration to compose.
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
- See Also:
-
getConfiguration
Gets the composite configuration.- Returns:
- the composite configuration.
-
getConfigurations
Gets a copy of the configurations.- Returns:
- a copy of the configurations.
-
getLocations
Gets a copy of the resource locations.- Returns:
- a copy of the resource locations.
-
getObject
- Specified by:
getObject
in interfaceFactoryBean<Properties>
- Throws:
Exception
- See Also:
-
getObjectType
- Specified by:
getObjectType
in interfaceFactoryBean<Properties>
- See Also:
-
isSingleton
- Specified by:
isSingleton
in interfaceFactoryBean<Properties>
- See Also:
-
isThrowExceptionOnMissing
Tests the underlying CompositeConfiguration throwExceptionOnMissing flag.- Returns:
- the underlying CompositeConfiguration throwExceptionOnMissing flag.
-
setConfigurations
Sets the commons configurations objects which will be used as properties.- Parameters:
configurations
- commons configurations objects which will be used as properties.
-
setLocations
Shortcut for loading compositeConfiguration from Spring resources. It will internally create a PropertiesConfiguration object based on the URL retrieved from the given Resources.- Parameters:
locations
- resources of configuration files
-
setThrowExceptionOnMissing
Sets the underlying CompositeConfiguration throwExceptionOnMissing flag.- Parameters:
throwExceptionOnMissing
- The new value for the property- See Also:
-