org.springframework.beans.factory.config
Class ListFactoryBean

java.lang.Object
  extended by org.springframework.beans.factory.config.AbstractFactoryBean
      extended by org.springframework.beans.factory.config.ListFactoryBean
All Implemented Interfaces:
DisposableBean, 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
See Also:
SetFactoryBean, MapFactoryBean

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


setTargetListClass

public void setTargetListClass(Class targetListClass)
Set the class to use for the target List. Can be populated with a fully qualified class name when defined in a Spring application context.

Default is a java.util.ArrayList.

See Also:
ArrayList

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.

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

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


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