接口 SmartFactoryBean<T>
- 所有超级接口:
FactoryBean<T>
public interface SmartFactoryBean<T> extends FactoryBean<T>
Extension of theFactoryBean
interface. Implementations may indicate whether they always return independent instances, for the case where theirFactoryBean.isSingleton()
implementation returningfalse
does not clearly indicate independent instances.Plain
FactoryBean
implementations which do not implement this extended interface are simply assumed to always return independent instances if theirFactoryBean.isSingleton()
implementation returnsfalse
; the exposed object is only accessed on demand.NOTE: This interface is a special purpose interface, mainly for internal use within the framework and within collaborating frameworks. In general, application-provided FactoryBeans should simply implement the plain
FactoryBean
interface. New methods might be added to this extended interface even in point releases.- 从以下版本开始:
- 2.0.3
- 作者:
- Juergen Hoeller
- 另请参阅:
isPrototype()
,FactoryBean.isSingleton()
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 boolean
isEagerInit()
Does this FactoryBean expect eager initialization, that is, eagerly initialize itself as well as expect eager initialization of its singleton object (if any)?boolean
isPrototype()
Is the object managed by this factory a prototype?从接口继承的方法 org.springframework.beans.factory.FactoryBean
getObject, getObjectType, isSingleton
方法详细资料
isPrototype
boolean isPrototype()
Is the object managed by this factory a prototype? That is, willFactoryBean.getObject()
always return an independent instance?The prototype status of the FactoryBean itself will generally be provided by the owning
BeanFactory
; usually, it has to be defined as singleton there.This method is supposed to strictly check for independent instances; it should not return
true
for scoped objects or other kinds of non-singleton, non-independent objects. For this reason, this is not simply the inverted form ofFactoryBean.isSingleton()
.- 返回:
- whether the exposed object is a prototype
- 另请参阅:
FactoryBean.getObject()
,FactoryBean.isSingleton()
isEagerInit
boolean isEagerInit()
Does this FactoryBean expect eager initialization, that is, eagerly initialize itself as well as expect eager initialization of its singleton object (if any)?A standard FactoryBean is not expected to initialize eagerly: Its
FactoryBean.getObject()
will only be called for actual access, even in case of a singleton object. Returningtrue
from this method suggests thatFactoryBean.getObject()
should be called eagerly, also applying post-processors eagerly. This may make sense in case of asingleton
object, in particular if post-processors expect to be applied on startup.- 返回:
- whether eager initialization applies
- 另请参阅:
ConfigurableListableBeanFactory.preInstantiateSingletons()