org.reactive.configuration
Class PropertiesConfigurationFactory

java.lang.Object
  extended by org.reactive.configuration.PropertiesConfigurationFactory
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public class PropertiesConfigurationFactory
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean

This class merges properties from several sources into one Properties object.

An example of the bean factory configuration required for Commons Configuration

 TODO: Add example XML
 

Note: This class is basically Spring's org.springframework.beans.factory.config.PropertyResourceConfigurer by Juergen Hoeller with a few things moved to other classes.

Since:
31.12.2004
Version:
$Id: PropertiesConfigurationFactory.java,v 1.1 2004/12/30 23:28:28 dan_washusen Exp $
Author:
Dan Washusen

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
PropertiesConfigurationFactory()
           
 
Method Summary
 void afterPropertiesSet()
          Merges the properties provided by setLocations(org.springframework.core.io.Resource[]) and setProperties(java.util.Properties) after all properties have been set by the bean factory.
 java.util.Properties getConfiguration()
          A convenience method that returns the merged properties.
 java.util.Properties getMergedProperties()
          Returns the merge properties, the result of merging the properties specified by setLocation(org.springframework.core.io.Resource), setLocations(org.springframework.core.io.Resource[]) and setProperties(java.util.Properties).
 void setFileEncoding(java.lang.String encoding)
          Set the encoding to use for parsing properties files.
 void setIgnoreResourceNotFound(boolean ignoreResourceNotFound)
          Set if failure to find the property resource should be ignored.
 void setLocation(org.springframework.core.io.Resource location)
          Set a location of a properties file to be loaded.
 void setLocations(org.springframework.core.io.Resource[] locations)
          Set locations of properties files to be loaded.
 void setProperties(java.util.Properties properties)
          Set local properties, e.g.
 void setPropertiesPersister(org.springframework.util.PropertiesPersister propertiesPersister)
          Set the PropertiesPersister to use for parsing properties files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

PropertiesConfigurationFactory

public PropertiesConfigurationFactory()
Method Detail

setProperties

public void setProperties(java.util.Properties properties)
Set local properties, e.g. via the "props" tag in XML bean definitions. These can be considered defaults, to be overridden by properties loaded from files.

See Also:
setLocation(org.springframework.core.io.Resource), setLocations(org.springframework.core.io.Resource[])

setLocation

public void setLocation(org.springframework.core.io.Resource location)
Set a location of a properties file to be loaded.

See Also:
setLocations(org.springframework.core.io.Resource[])

setLocations

public void setLocations(org.springframework.core.io.Resource[] locations)
Set locations of properties files to be loaded.

See Also:
setLocation(org.springframework.core.io.Resource)

setFileEncoding

public void setFileEncoding(java.lang.String encoding)
Set the encoding to use for parsing properties files. Default is none, using java.util.Properties' default encoding.

See Also:
PropertiesPersister.load(java.util.Properties, java.io.InputStream)

setPropertiesPersister

public void setPropertiesPersister(org.springframework.util.PropertiesPersister propertiesPersister)
Set the PropertiesPersister to use for parsing properties files. The default is DefaultPropertiesPersister.

See Also:
DefaultPropertiesPersister

setIgnoreResourceNotFound

public void setIgnoreResourceNotFound(boolean ignoreResourceNotFound)
Set if failure to find the property resource should be ignored. True is appropriate if the properties file is completely optional. Default is false.


afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Merges the properties provided by setLocations(org.springframework.core.io.Resource[]) and setProperties(java.util.Properties) after all properties have been set by the bean factory.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception - If an IO error occurs while attempting to read a properties file from disk

getMergedProperties

public java.util.Properties getMergedProperties()
Returns the merge properties, the result of merging the properties specified by setLocation(org.springframework.core.io.Resource), setLocations(org.springframework.core.io.Resource[]) and setProperties(java.util.Properties).

Returns:
The merged properties

getConfiguration

public java.util.Properties getConfiguration()
A convenience method that returns the merged properties.

Returns:
The merged properties


Copyright © 2004-2005 reactive.org. All Rights Reserved.