org.springframework.beans.factory.config
Class ListFactoryBean

java.lang.Object
  extended byorg.springframework.beans.factory.config.AbstractFactoryBean
      extended byorg.springframework.beans.factory.config.ListFactoryBean
All Implemented Interfaces:
FactoryBean, InitializingBean

public class ListFactoryBean
extends AbstractFactoryBean

Simple factory for shared List instances. Allows for central setup of Lists via the "list" element in XML bean definitions.

Since:
09.12.2003
Author:
Juergen Hoeller

Field Summary
 
Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
logger
 
Constructor Summary
ListFactoryBean()
           
 
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.
 void setSourceList(java.util.List sourceList)
          Set the source List, typically populated via XML "list" elements.
 void setTargetListClass(java.lang.Class targetListClass)
          Set the class to use for the target List.
 
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

ListFactoryBean

public ListFactoryBean()
Method Detail

setSourceList

public void setSourceList(java.util.List sourceList)
Set the source List, typically populated via XML "list" elements.


setTargetListClass

public void setTargetListClass(java.lang.Class targetListClass)
Set the class to use for the target List. Default is java.util.ArrayList.

See Also:
ArrayList

getObjectType

public java.lang.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, e.g. on autowiring.

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.

Returns:
the type of object that this FactoryBean creates, or null
See Also:
ListableBeanFactory.getBeansOfType(java.lang.Class, boolean, boolean)

createInstance

protected java.lang.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 getObject() call.

Specified by:
createInstance in class AbstractFactoryBean
Returns:
the object returned by this factory
See Also:
AbstractFactoryBean.getObject()


Copyright (C) 2003-2004 The Spring Framework Project.