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
Propertiesobject 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:
Properties,PropertiesLoaderSupport
-
-
Field Summary
-
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description ConfigurationPropertiesFactoryBean()ConfigurationPropertiesFactoryBean(Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()CompositeConfigurationgetConfiguration()Configuration[]getConfigurations()Resource[]getLocations()PropertiesgetObject()Class<?>getObjectType()booleanisSingleton()booleanisThrowExceptionOnMissing()voidsetConfigurations(Configuration... configurations)Set the commons configurations objects which will be used as properties.voidsetLocations(Resource... locations)Shortcut for loading compositeConfiguration from Spring resources.voidsetThrowExceptionOnMissing(boolean throwExceptionOnMissing)Set the underlying Commons CompositeConfiguration throwExceptionOnMissing flag.
-
-
-
Constructor Detail
-
ConfigurationPropertiesFactoryBean
public ConfigurationPropertiesFactoryBean()
-
ConfigurationPropertiesFactoryBean
public ConfigurationPropertiesFactoryBean(Configuration configuration)
-
-
Method Detail
-
getObject
public Properties getObject() throws Exception
- Specified by:
getObjectin interfaceFactoryBean<Properties>- Throws:
Exception- See Also:
FactoryBean.getObject()
-
getObjectType
public Class<?> getObjectType()
- Specified by:
getObjectTypein interfaceFactoryBean<Properties>- See Also:
FactoryBean.getObjectType()
-
isSingleton
public boolean isSingleton()
- Specified by:
isSingletonin interfaceFactoryBean<Properties>- See Also:
FactoryBean.isSingleton()
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception- See Also:
InitializingBean.afterPropertiesSet()
-
getConfigurations
public Configuration[] getConfigurations()
-
setConfigurations
public void setConfigurations(Configuration... configurations)
Set the commons configurations objects which will be used as properties.- Parameters:
configurations- commons configurations objects which will be used as properties.
-
getLocations
public Resource[] getLocations()
-
setLocations
public void setLocations(Resource... locations)
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
-
isThrowExceptionOnMissing
public boolean isThrowExceptionOnMissing()
-
setThrowExceptionOnMissing
public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)
Set the underlying Commons CompositeConfiguration throwExceptionOnMissing flag.- Parameters:
throwExceptionOnMissing- The new value for the property- See Also:
AbstractConfiguration.setThrowExceptionOnMissing(boolean)
-
getConfiguration
public CompositeConfiguration getConfiguration()
-
-