站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

MapFactoryBean (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.beans.factory.config
Class MapFactoryBean

java.lang.Object
  extended by org.springframework.beans.factory.config.AbstractFactoryBean
      extended by org.springframework.beans.factory.config.MapFactoryBean
All Implemented Interfaces:
BeanFactoryAware, DisposableBean, FactoryBean, InitializingBean

public class MapFactoryBean
extends AbstractFactoryBean

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  Object createInstance()
          Template method that subclasses must 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 setSourceMap(Map sourceMap)
          Set the source Map, typically populated via XML "map" elements.
 void setTargetMapClass(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, 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(Map sourceMap)
Set the source Map, typically populated via XML "map" elements.


setTargetMapClass

public void setTargetMapClass(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. If no linked Map implementation is available, a plain HashMap will be used as fallback (not keeping the registration order).

See Also:
CollectionFactory.createLinkedMapIfPossible(int)

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 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.

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()
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
Returns:
the object returned by this factory
See Also:
AbstractFactoryBean.getObject()

The Spring Framework

Copyright © 2002-2007 The Spring Framework.