org.springframework.beans.factory

## 接口 SmartInitializingSingleton

-     public interface SmartInitializingSingleton

  Callback interface triggered at the end of the singleton pre-instantiation phase during `BeanFactory` bootstrap. This interface can be implemented by singleton beans in order to perform some initialization after the regular singleton instantiation algorithm, avoiding side effects with accidental early initialization (e.g. from `ListableBeanFactory.getBeansOfType(java.lang.Class<T>)` calls). In that sense, it is an alternative to `InitializingBean` which gets triggered right at the end of a bean's local construction phase.

  This callback variant is somewhat similar to `org.springframework.context.event.ContextRefreshedEvent` but doesn't require an implementation of `org.springframework.context.ApplicationListener`, with no need to filter context references across a context hierarchy etc. It also implies a more minimal dependency on just the `beans` package and is being honored by standalone `ListableBeanFactory` implementations, not just in an `org.springframework.context.ApplicationContext` environment.

  NOTE: If you intend to start/manage asynchronous tasks, preferably implement `org.springframework.context.Lifecycle` instead which offers a richer model for runtime management and allows for phased startup/shutdown.

  从以下版本开始:
    4.1
  作者:
    Juergen Hoeller
  另请参阅:
    `ConfigurableListableBeanFactory.preInstantiateSingletons()`

- - ### 方法概要

    所有方法 实例方法 抽象方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `afterSingletonsInstantiated()` Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.

- - ### 方法详细资料

    - #### afterSingletonsInstantiated

          void afterSingletonsInstantiated()

      Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already. `ListableBeanFactory.getBeansOfType(java.lang.Class<T>)` calls within this method won't trigger accidental side effects during bootstrap.

      NOTE: This callback won't be triggered for singleton beans lazily initialized on demand after `BeanFactory` bootstrap, and not for any other bean scope either. Carefully use it for beans with the intended bootstrap semantics only.