ConfigurationPropertiesFactoryBean (Apache Commons Configuration 2.15.1 API)
Description: declaration: package: org.apache.commons.configuration2.spring, class: ConfigurationPropertiesFactoryBean

Package org.apache.commons.configuration2.spring

# 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:
  - `Properties`
  - `PropertiesLoaderSupport`

- ## Field Summary

  ### Fields inherited from interface org.springframework.beans.factory.FactoryBean

  `OBJECT_TYPE_ATTRIBUTE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConfigurationPropertiesFactoryBean()`
  Constructs a new instance.
  `ConfigurationPropertiesFactoryBean(Configuration configuration)`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `afterPropertiesSet()`
  `CompositeConfiguration`
  `getConfiguration()`
  Gets the composite configuration.
  `Configuration[]`
  `getConfigurations()`
  Gets a copy of the configurations.
  `Resource[]`
  `getLocations()`
  Gets a copy of the resource locations.
  `Properties`
  `getObject()`
  `Class<?>`
  `getObjectType()`
  `boolean`
  `isSingleton()`
  `boolean`
  `isThrowExceptionOnMissing()`
  Tests the underlying CompositeConfiguration throwExceptionOnMissing flag.
  `void`
  `setConfigurations(Configuration... configurations)`
  Sets the Commons Configuration 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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ConfigurationPropertiesFactoryBean

    public ConfigurationPropertiesFactoryBean()
    Constructs a new instance.

  - ### ConfigurationPropertiesFactoryBean

    public ConfigurationPropertiesFactoryBean(Configuration configuration)
    Constructs a new instance.
    Parameters:
      `configuration` - The configuration to compose.

- ## Method Details

  - ### afterPropertiesSet

    public void afterPropertiesSet() throws Exception
    Specified by:
      `afterPropertiesSet` in interface `InitializingBean`
    Throws:
      `Exception`
    See Also:
      - `InitializingBean.afterPropertiesSet()`

  - ### getConfiguration

    public CompositeConfiguration getConfiguration()
    Gets the composite configuration.
    Returns:
      the composite configuration.

  - ### getConfigurations

    public Configuration[] getConfigurations()
    Gets a copy of the configurations.
    Returns:
      a copy of the configurations.

  - ### getLocations

    public Resource[] getLocations()
    Gets a copy of the resource locations.
    Returns:
      a copy of the resource locations.

  - ### getObject

    public Properties getObject() throws Exception
    Specified by:
      `getObject` in interface `FactoryBean<Properties>`
    Throws:
      `Exception`
    See Also:
      - `FactoryBean.getObject()`

  - ### getObjectType

    public Class<?> getObjectType()
    Specified by:
      `getObjectType` in interface `FactoryBean<Properties>`
    See Also:
      - `FactoryBean.getObjectType()`

  - ### isSingleton

    public boolean isSingleton()
    Specified by:
      `isSingleton` in interface `FactoryBean<Properties>`
    See Also:
      - `FactoryBean.isSingleton()`

  - ### isThrowExceptionOnMissing

    public boolean isThrowExceptionOnMissing()
    Tests the underlying CompositeConfiguration throwExceptionOnMissing flag.
    Returns:
      the underlying CompositeConfiguration throwExceptionOnMissing flag.

  - ### setConfigurations

    public void setConfigurations(Configuration... configurations)
    Sets the Commons Configuration objects which will be used as properties.
    Parameters:
      `configurations` - Commons Configuration objects which will be used as properties.

  - ### 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

  - ### setThrowExceptionOnMissing

    public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)
    Sets the underlying CompositeConfiguration throwExceptionOnMissing flag.
    Parameters:
      `throwExceptionOnMissing` - The new value for the property
    See Also:
      - `AbstractConfiguration.setThrowExceptionOnMissing(boolean)`