org.springframework.context.support
Class ResourceMapFactoryBean

java.lang.Object
  extended by org.springframework.core.io.support.PropertiesLoaderSupport
      extended by org.springframework.beans.factory.config.PropertiesFactoryBean
          extended by org.springframework.context.support.ResourceMapFactoryBean
All Implemented Interfaces:
FactoryBean, InitializingBean, ResourceLoaderAware

public class ResourceMapFactoryBean
extends PropertiesFactoryBean
implements ResourceLoaderAware

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.

Since:
1.0.2
Author:
Juergen Hoeller, Keith Donald
See Also:
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()
          Template method that subclasses may override to construct the object returned by this factory.
 Class getObjectType()
          Return the type of object that this FactoryBean creates, or null if not known in advance.
 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, setPropertiesPersister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceMapFactoryBean

public ResourceMapFactoryBean()
Method Detail

setResourceBasePath

public void setResourceBasePath(String resourceBasePath)
Set a base path to prepend to each resource location value in the properties file.

E.g.: resourceBasePath="/images", value="/test.gif" -> location="/images/test.gif"


setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Description copied from interface: ResourceLoaderAware
Set the ResourceLoader that this object runs in.

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.

Specified by:
setResourceLoader in interface ResourceLoaderAware
Parameters:
resourceLoader - ResourceLoader object to be used by this object

getObjectType

public Class getObjectType()
Description copied from interface: FactoryBean
Return the type of object that this FactoryBean creates, or null if not known in advance. This allows to check for specific types of beans without instantiating objects, for example on autowiring.

For a singleton, this 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.

Specified by:
getObjectType in interface FactoryBean
Overrides:
getObjectType in class PropertiesFactoryBean
Returns:
the type of object that this FactoryBean creates, or null if not known at the time of the call
See Also:
ListableBeanFactory.getBeansOfType(java.lang.Class)

createInstance

protected Object createInstance()
                         throws IOException
Description copied from class: PropertiesFactoryBean
Template method that subclasses may override to construct the object returned by this factory. Default returns the plain merged Properties.

Invoked on initialization of this FactoryBean in case of a singleton; else, on each getObject() call.

Overrides:
createInstance in class PropertiesFactoryBean
Returns:
the object returned by this factory
Throws:
IOException - if an exception occured during properties loading
See Also:
PropertiesFactoryBean.getObject(), PropertiesLoaderSupport.mergeProperties()


Copyright (c) 2002-2005 The Spring Framework Project.