Interface to be implemented by objects used within a {@link BeanFactory}which are themselves factories. If a bean implements this interface, it is used as a factory for an object to expose, not directly as a bean instance that will be exposed itself.
NB: A bean that implements this interface cannot be used as a normal bean. A FactoryBean is defined in a bean style, but the object exposed for bean references ( {@link #getObject()} is alwaysthe object that it creates.
FactoryBeans can support singletons and prototypes, and can either create objects lazily on demand or eagerly on startup. The {@link SmartFactoryBean} interface allows for exposingmore fine-grained behavioral metadata.
This interface is heavily used within the framework itself, for example for the AOP {@link org.springframework.aop.framework.ProxyFactoryBean}or the {@link org.springframework.jndi.JndiObjectFactoryBean}. It can be used for application components as well; however, this is not common outside of infrastructure code.
NOTE: FactoryBean objects participate in the containing BeanFactory's synchronization of bean creation. There is usually no need for internal synchronization other than for purposes of lazy initialization within the FactoryBean itself (or the like).
@author Rod Johnson
@author Juergen Hoeller
@since 08.03.2003
@see org.springframework.beans.factory.BeanFactory
@see org.springframework.aop.framework.ProxyFactoryBean
@see org.springframework.jndi.JndiObjectFactoryBean