Spring Framework

org.springframework.beans.factory.config
Class MapFactoryBean

java.lang.Object
  extended by org.springframework.beans.factory.config.AbstractFactoryBean<java.util.Map>
      extended by org.springframework.beans.factory.config.MapFactoryBean
All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, DisposableBean, FactoryBean<java.util.Map>, InitializingBean

public class MapFactoryBean
extends AbstractFactoryBean<java.util.Map>

Simple factory for shared Map instances. Allows for central setup of Maps via the "map" element in XML bean definitions.

Since:
09.12.2003
Author:
Juergen Hoeller
See Also:
SetFactoryBean, ListFactoryBean

Field Summary
 
Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
logger
 
Constructor Summary
MapFactoryBean()
           
 
Method Summary
protected  java.util.Map createInstance()
          Template method that subclasses must override to construct the object returned by this factory.
 java.lang.Class<java.util.Map> getObjectType()
          This abstract method declaration mirrors the method in the FactoryBean interface, for a consistent offering of abstract template methods.
 void setSourceMap(java.util.Map sourceMap)
          Set the source Map, typically populated via XML "map" elements.
 void setTargetMapClass(java.lang.Class targetMapClass)
          Set the class to use for the target Map.
 
Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
afterPropertiesSet, destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapFactoryBean

public MapFactoryBean()
Method Detail

setSourceMap

public void setSourceMap(java.util.Map sourceMap)
Set the source Map, typically populated via XML "map" elements.


setTargetMapClass

public void setTargetMapClass(java.lang.Class targetMapClass)
Set the class to use for the target Map. Can be populated with a fully qualified class name when defined in a Spring application context.

Default is a linked HashMap, keeping the registration order.

See Also:
LinkedHashMap

getObjectType

public java.lang.Class<java.util.Map> getObjectType()
Description copied from class: AbstractFactoryBean
This abstract method declaration mirrors the method in the FactoryBean interface, for a consistent offering of abstract template methods.

Specified by:
getObjectType in interface FactoryBean<java.util.Map>
Specified by:
getObjectType in class AbstractFactoryBean<java.util.Map>
Returns:
the type of object that this FactoryBean creates, or null if not known at the time of the call
See Also:
FactoryBean.getObjectType()

createInstance

protected java.util.Map createInstance()
Description copied from class: AbstractFactoryBean
Template method that subclasses must override to construct the object returned by this factory.

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

Specified by:
createInstance in class AbstractFactoryBean<java.util.Map>
Returns:
the object returned by this factory
See Also:
AbstractFactoryBean.getObject()

Spring Framework