类 AbstractFactoryBean<T>

    • 字段详细资料

      • logger

        protected final Log logger
        Logger available to subclasses.
    • 方法详细资料

      • setSingleton

        public void setSingleton​(boolean singleton)
        Set if a singleton should be created, or a new object on each request otherwise. Default is true (a singleton).
      • isSingleton

        public boolean isSingleton()
        从接口复制的说明: FactoryBean
        Is the object managed by this factory a singleton? That is, will FactoryBean.getObject() always return the same object (a reference that can be cached)?

        NOTE: If a FactoryBean indicates to hold a singleton object, the object returned from getObject() might get cached by the owning BeanFactory. Hence, do not return true unless the FactoryBean always exposes the same reference.

        The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory; usually, it has to be defined as singleton there.

        NOTE: This method returning false does not necessarily indicate that returned objects are independent instances. An implementation of the extended SmartFactoryBean interface may explicitly indicate independent instances through its SmartFactoryBean.isPrototype() method. Plain FactoryBean implementations which do not implement this extended interface are simply assumed to always return independent instances if the isSingleton() implementation returns false.

        The default implementation returns true, since a FactoryBean typically manages a singleton instance.

        指定者:
        isSingleton 在接口中 FactoryBean<T>
        返回:
        whether the exposed object is a singleton
        另请参阅:
        FactoryBean.getObject(), SmartFactoryBean.isPrototype()
      • getObjectType

        @Nullable
        public abstract Class<?> getObjectType()
        This abstract method declaration mirrors the method in the FactoryBean interface, for a consistent offering of abstract template methods.
        指定者:
        getObjectType 在接口中 FactoryBean<T>
        返回:
        the type of object that this FactoryBean creates, or null if not known at the time of the call
        另请参阅:
        FactoryBean.getObjectType()
      • createInstance

        protected abstract T 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.

        返回:
        the object returned by this factory
        抛出:
        Exception - if an exception occurred during object creation
        另请参阅:
        getObject()
      • getEarlySingletonInterfaces

        @Nullable
        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 otherwise. The latter indicates that early singleton access is not supported by this FactoryBean. This will lead to a FactoryBeanNotInitializedException getting thrown.

        返回:
        the interfaces to use for 'early singletons', or null to indicate a FactoryBeanNotInitializedException
        另请参阅:
        FactoryBeanNotInitializedException
      • destroyInstance

        protected void destroyInstance​(@Nullable
                                       T instance)
                                throws Exception
        Callback for destroying a singleton instance. Subclasses may override this to destroy the previously created instance.

        The default implementation is empty.

        参数:
        instance - the singleton instance, as returned by createInstance()
        抛出:
        Exception - in case of shutdown errors
        另请参阅:
        createInstance()