org.springframework.beans.factory.config
Class SetFactoryBean

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

public class SetFactoryBean
extends AbstractFactoryBean

Simple factory for shared Set instances. Allows for central setup of Sets via the "set" element in XML bean definitions.

Since:
21.01.2003
Version:
$Id: SetFactoryBean.java,v 1.4 2004/04/26 22:03:08 jhoeller Exp $
Author:
Juergen Hoeller

Field Summary
 
Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
logger
 
Constructor Summary
SetFactoryBean()
           
 
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 setSourceSet(java.util.Set sourceSet)
          Set the source Set, typically populated via XML "set" elements.
 void setTargetSetClass(java.lang.Class targetSetClass)
          Set the class to use for the target Set.
 
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

SetFactoryBean

public SetFactoryBean()
Method Detail

setSourceSet

public void setSourceSet(java.util.Set sourceSet)
Set the source Set, typically populated via XML "set" elements.


setTargetSetClass

public void setTargetSetClass(java.lang.Class targetSetClass)
Set the class to use for the target Set. Default is java.util.HashSet.

See Also:
HashSet

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.