Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » beans » factory » config » [javadoc | source]
org.springframework.beans.factory.config
abstract public class: AbstractFactoryBean [javadoc | source]
java.lang.Object
   org.springframework.beans.factory.config.AbstractFactoryBean

All Implemented Interfaces:
    BeanClassLoaderAware, DisposableBean, BeanFactoryAware, InitializingBean, FactoryBean

Direct Known Subclasses:
    ObjectFactoryCreatingFactoryBean, MapFactoryBean, SetFactoryBean, ServiceFactoryBean, ListFactoryBean, AbstractServiceLoaderBasedFactoryBean, ServiceListFactoryBean, ServiceLoaderFactoryBean

Simple template superclass for FactoryBean implementations that creates a singleton or a prototype object, depending on a flag.

If the "singleton" flag is true (the default), this class will create the object that it creates exactly once on initialization and subsequently return said singleton instance on all calls to the #getObject() method.

Else, this class will create a new instance every time the #getObject() method is invoked. Subclasses are responsible for implementing the abstract #createInstance() template method to actually create the object(s) to expose.

Field Summary
protected final  Log logger    Logger available to subclasses 
Method from org.springframework.beans.factory.config.AbstractFactoryBean Summary:
afterPropertiesSet,   createInstance,   destroy,   destroyInstance,   getBeanFactory,   getBeanTypeConverter,   getEarlySingletonInterfaces,   getObject,   getObjectType,   isSingleton,   setBeanClassLoader,   setBeanFactory,   setSingleton
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.beans.factory.config.AbstractFactoryBean Detail:
 public  void afterPropertiesSet() throws Exception 
    Eagerly create the singleton instance, if necessary.
 abstract protected Object createInstance() throws Exception
    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.

 public  void destroy() throws Exception 
    Destroy the singleton instance, if any.
 protected  void destroyInstance(Object instance) throws Exception 
    Callback for destroying a singleton instance. Subclasses may override this to destroy the previously created instance.

    The default implementation is empty.

 protected BeanFactory getBeanFactory() 
    Return the BeanFactory that this bean runs in.
 protected TypeConverter getBeanTypeConverter() 
    Obtain a bean type converter from the BeanFactory that this bean runs in. This is typically a fresh instance for each call, since TypeConverters are usually not thread-safe.

    Falls back to a SimpleTypeConverter when not running in a BeanFactory.

 protected Class[] getEarlySingletonInterfaces() 
    Return an array of interfaces that a singleton object exposed by this FactoryBean is supposed to implement, for use with an 'early singleton proxy' that will be exposed in case of a circular reference.

    The default implementation returns this FactoryBean's object type, provided that it is an interface, or null else. The latter indicates that early singleton access is not supported by this FactoryBean. This will lead to a FactoryBeanNotInitializedException getting thrown.

 public final Object getObject() throws Exception 
    Expose the singleton instance or create a new prototype instance.
 abstract public Class getObjectType()
    This abstract method declaration mirrors the method in the FactoryBean interface, for a consistent offering of abstract template methods.
 public boolean isSingleton() 
 public  void setBeanClassLoader(ClassLoader classLoader) 
 public  void setBeanFactory(BeanFactory beanFactory) 
 public  void setSingleton(boolean singleton) 
    Set if a singleton should be created, or a new object on each request else. Default is true (a singleton).