|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.support.PropertiesLoaderSupport org.springframework.beans.factory.config.PropertiesFactoryBean org.springframework.context.support.ResourceMapFactoryBean
public class ResourceMapFactoryBean
FactoryBean that creates a Map with String keys and Resource values from properties, interpreting passed-in String values as resource locations.
Extends PropertiesFactoryBean to inherit the capability of defining local properties and loading from properties files.
Implements the ResourceLoaderAware interface to automatically use the context ResourceLoader if running in an ApplicationContext. Uses DefaultResourceLoader else.
DefaultResourceLoader
Field Summary |
---|
Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
---|
logger, XML_FILE_EXTENSION |
Constructor Summary | |
---|---|
ResourceMapFactoryBean()
|
Method Summary | |
---|---|
protected Object |
createInstance()
Create the Map instance, populated with keys and Resource values. |
Class |
getObjectType()
Return the type of object that this FactoryBean creates, or null if not known in advance. |
protected Resource |
getResource(String location)
Fetch the Resource handle for the given location, prepeding the resource base path. |
void |
setResourceBasePath(String resourceBasePath)
Set a base path to prepend to each resource location value in the properties file. |
void |
setResourceLoader(ResourceLoader resourceLoader)
Set the ResourceLoader that this object runs in. |
Methods inherited from class org.springframework.beans.factory.config.PropertiesFactoryBean |
---|
afterPropertiesSet, getObject, isSingleton, setSingleton |
Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
---|
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourceMapFactoryBean()
Method Detail |
---|
public void setResourceBasePath(String resourceBasePath)
E.g.: resourceBasePath="/images", value="/test.gif" -> location="/images/test.gif"
public void setResourceLoader(ResourceLoader resourceLoader)
ResourceLoaderAware
This might be a ResourcePatternResolver, which can be checked
through instanceof ResourcePatternResolver
. See also the
ResourcePatternUtils.getResourcePatternResolver
method.
Invoked after population of normal bean properties but before an init callback
like InitializingBean's afterPropertiesSet
or a custom init-method.
Invoked before ApplicationContextAware's setApplicationContext
.
setResourceLoader
in interface ResourceLoaderAware
resourceLoader
- ResourceLoader object to be used by this objectResourcePatternResolver
,
ResourcePatternUtils.getResourcePatternResolver(org.springframework.core.io.ResourceLoader)
public Class getObjectType()
FactoryBean
null
if not known in advance.
This allows one to check for specific types of beans without instantiating objects, for example on autowiring.
In the case of implementations that are creating a singleton object, this method should try to avoid singleton creation as far as possible; it should rather estimate the type in advance. For prototypes, returning a meaningful type here is advisable too.
This method can be called before this FactoryBean has been fully initialized. It must not rely on state created during initialization; of course, it can still use such state if available.
NOTE: Autowiring will simply ignore FactoryBeans that return
null
here. Therefore it is highly recommended to implement
this method properly, using the current state of the FactoryBean.
getObjectType
in interface FactoryBean
getObjectType
in class PropertiesFactoryBean
null
if not known at the time of the callListableBeanFactory.getBeansOfType(java.lang.Class)
protected Object createInstance() throws IOException
createInstance
in class PropertiesFactoryBean
IOException
- if an exception occured during properties loadingPropertiesFactoryBean.getObject()
,
PropertiesLoaderSupport.mergeProperties()
protected Resource getResource(String location)
location
- the resource location
ResourceLoader.getResource(String)
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |