public abstract class

PropertiesLoaderSupport

extends Object
java.lang.Object
   ↳ org.springframework.core.io.support.PropertiesLoaderSupport
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Base class for JavaBean-style components that need to load properties from one or more resources. Supports local properties as well, with configurable overriding.

Summary

Constants
String XML_FILE_EXTENSION
Fields
protected boolean localOverride
protected Properties[] localProperties
protected final Log logger Logger available to subclasses
Public Constructors
PropertiesLoaderSupport()
Public Methods
void setFileEncoding(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 setLocalOverride(boolean localOverride)
Set whether local properties override properties from files.
void setLocation(Resource location)
Set a location of a properties file to be loaded.
void setLocations(Resource[] locations)
Set locations of properties files to be loaded.
void setProperties(Properties properties)
Set local properties, e.g.
void setPropertiesArray(Properties[] propertiesArray)
Set local properties, e.g.
void setPropertiesPersister(PropertiesPersister propertiesPersister)
Set the PropertiesPersister to use for parsing properties files.
Protected Methods
void loadProperties(Properties props)
Load properties into the given instance.
Properties mergeProperties()
Return a merged Properties instance containing both the loaded properties and properties set on this FactoryBean.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String XML_FILE_EXTENSION

Also: SpringCore

Constant Value: ".xml"

Fields

protected boolean localOverride

Also: SpringCore

protected Properties[] localProperties

Also: SpringCore

protected final Log logger

Also: SpringCore

Logger available to subclasses

Public Constructors

public PropertiesLoaderSupport ()

Also: SpringCore

Public Methods

public void setFileEncoding (String encoding)

Also: SpringCore

Set the encoding to use for parsing properties files.

Default is none, using the java.util.Properties default encoding.

Only applies to classic properties files, not to XML files.

public void setIgnoreResourceNotFound (boolean ignoreResourceNotFound)

Also: SpringCore

Set if failure to find the property resource should be ignored.

"true" is appropriate if the properties file is completely optional. Default is "false".

public void setLocalOverride (boolean localOverride)

Also: SpringCore

Set whether local properties override properties from files.

Default is "false": Properties from files override local defaults. Can be switched to "true" to let local properties override defaults from files.

public void setLocation (Resource location)

Also: SpringCore

Set a location of a properties file to be loaded.

Can point to a classic properties file or to an XML file that follows JDK 1.5's properties XML format.

public void setLocations (Resource[] locations)

Also: SpringCore

Set locations of properties files to be loaded.

Can point to classic properties files or to XML files that follow JDK 1.5's properties XML format.

Note: Properties defined in later files will override properties defined earlier files, in case of overlapping keys. Hence, make sure that the most specific files are the last ones in the given list of locations.

public void setProperties (Properties properties)

Also: SpringCore

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.

public void setPropertiesArray (Properties[] propertiesArray)

Also: SpringCore

Set local properties, e.g. via the "props" tag in XML bean definitions, allowing for merging multiple properties sets into one.

public void setPropertiesPersister (PropertiesPersister propertiesPersister)

Also: SpringCore

Set the PropertiesPersister to use for parsing properties files. The default is DefaultPropertiesPersister.

Protected Methods

protected void loadProperties (Properties props)

Also: SpringCore

Load properties into the given instance.

Parameters
props the Properties instance to load into
Throws
IOException in case of I/O errors

protected Properties mergeProperties ()

Also: SpringCore

Return a merged Properties instance containing both the loaded properties and properties set on this FactoryBean.

Throws
IOException