Class PropertiesLoaderSupport
- Direct Known Subclasses:
PropertiesFactoryBean, PropertyResourceConfigurer
- Since:
- 1.2.2
- Author:
- Juergen Hoeller
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Properties @Nullable []protected final org.apache.commons.logging.LogLogger available to subclasses. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidloadProperties(Properties props) Load properties into the given instance.protected PropertiesReturn a mergedPropertiesinstance containing both the loaded properties and properties set on this component.voidsetFileEncoding(String encoding) Set the encoding to use for parsing properties files.voidsetIgnoreResourceNotFound(boolean ignoreResourceNotFound) Set if failure to find the property resource should be ignored.voidsetLocalOverride(boolean localOverride) Set whether local properties override properties from files.voidsetLocation(Resource location) Set a location of a properties file to be loaded.voidsetLocations(Resource... locations) Set locations of properties files to be loaded.voidsetProperties(Properties properties) Set local properties, for example, via the "props" tag in xml bean definitions.voidsetPropertiesArray(Properties... propertiesArray) Set local properties, for example, via the "props" tag in xml bean definitions, allowing for merging multiple properties sets into one.voidsetPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) Set the PropertiesPersister to use for parsing properties files.
-
Field Details
-
logger
protected final org.apache.commons.logging.Log loggerLogger available to subclasses. -
localProperties
-
localOverride
protected boolean localOverride
-
-
Constructor Details
-
PropertiesLoaderSupport
public PropertiesLoaderSupport()
-
-
Method Details
-
setProperties
Set local properties, for example, via the "props" tag in xml bean definitions. These can be considered defaults, to be overridden by properties loaded from files. -
setPropertiesArray
Set local properties, for example, via the "props" tag in xml bean definitions, allowing for merging multiple properties sets into one. -
setLocation
Set a location of a properties file to be loaded.Can point to a classic properties file or to an xml file that follows Java's properties xml format.
-
setLocations
Set locations of properties files to be loaded.Can point to classic properties files or to xml files that follow Java'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.
-
setLocalOverride
public void setLocalOverride(boolean localOverride) 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.
-
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".
-
setFileEncoding
Set the encoding to use for parsing properties files.Default is none, using the
java.util.Propertiesdefault encoding.Only applies to classic properties files, not to xml files.
- See Also:
-
setPropertiesPersister
Set the PropertiesPersister to use for parsing properties files. The default isDefaultPropertiesPersister.- See Also:
-
mergeProperties
Return a mergedPropertiesinstance containing both the loaded properties and properties set on this component.- Throws:
IOException
-
loadProperties
Load properties into the given instance.- Parameters:
props- the Properties instance to load into- Throws:
IOException- in case of I/O errors- See Also:
-