|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.beans.factory.config.AbstractFactoryBean
org.springframework.beans.factory.config.PropertiesFactoryBean
Allows for making a properties file from a classpath location available as Properties instance in a bean factory. Can be used for to populate any bean property of type Properties via a bean reference.
Supports loading from a properties file and/or setting local properties on this FactoryBean. The created Properties instance will be merged from loaded and local values. If neither a location nor local properties are set, an exception will be thrown on initialization.
Can create a singleton or a new object on each request. Default is singleton.
Properties
Field Summary |
Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean |
logger |
Constructor Summary | |
PropertiesFactoryBean()
|
Method Summary | |
protected java.lang.Object |
createInstance()
Template method that subclasses must override to construct the object returned by this factory. |
java.lang.Class |
getObjectType()
Return the type of object that this FactoryBean creates, or null if not known in advance. |
protected java.util.Properties |
loadProperties()
Load the Properties instance. |
protected java.util.Properties |
mergeProperties()
Return a merged Properties instance containing both the loaded properties and properties set on this FactoryBean. |
void |
setFileEncoding(java.lang.String encoding)
Set the encoding to use for parsing properties 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(java.util.Properties properties)
Set local properties, e.g. via the "props" tag in XML bean definitions. |
void |
setPropertiesPersister(PropertiesPersister propertiesPersister)
Set the PropertiesPersister to use for parsing properties files. |
Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean |
afterPropertiesSet, getObject, isSingleton, setSingleton |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PropertiesFactoryBean()
Method Detail |
public void setProperties(java.util.Properties properties)
public void setLocation(Resource location)
public void setLocations(Resource[] locations)
public void setFileEncoding(java.lang.String encoding)
PropertiesPersister.load(java.util.Properties, java.io.InputStream)
public void setPropertiesPersister(PropertiesPersister propertiesPersister)
DefaultPropertiesPersister
public java.lang.Class getObjectType()
FactoryBean
For a singleton, this can simply return getObject().getClass(), or even null, as autowiring will always check the actual objects for singletons. For prototypes, returning a meaningful type here is highly advisable, as autowiring will simply ignore them else.
ListableBeanFactory.getBeansOfType(java.lang.Class, boolean, boolean)
protected java.lang.Object createInstance() throws java.lang.Exception
AbstractFactoryBean
Invoked on initialization of this FactoryBean in case of a singleton; else, on each getObject() call.
createInstance
in class AbstractFactoryBean
java.lang.Exception
- if an exception occured during object creationAbstractFactoryBean.getObject()
protected java.util.Properties mergeProperties() throws java.io.IOException
java.io.IOException
protected java.util.Properties loadProperties() throws java.io.IOException
java.io.IOException
- in case of I/O errors
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |