org.springframework.beans.factory

## 接口 DisposableBean

- 所有已知实现类:
    AbstractFactoryBean, AbstractServiceLoaderBasedFactoryBean, BeanConfigurerSupport, ListFactoryBean, MapFactoryBean, ObjectFactoryCreatingFactoryBean, ProviderCreatingFactoryBean, ServiceFactoryBean, ServiceListFactoryBean, ServiceLoaderFactoryBean, SetFactoryBean

      public interface DisposableBean

  Interface to be implemented by beans that want to release resources on destruction. A `BeanFactory` will invoke the destroy method on individual destruction of a scoped bean. An `org.springframework.context.ApplicationContext` is supposed to dispose all of its singletons on shutdown, driven by the application lifecycle.

  A Spring-managed bean may also implement Java's `AutoCloseable` interface for the same purpose. An alternative to implementing an interface is specifying a custom destroy method, for example in an XML bean definition. For a list of all bean lifecycle methods, see the `BeanFactory javadocs`.

  从以下版本开始:
    12.08.2003
  作者:
    Juergen Hoeller
  另请参阅:
    `InitializingBean`, `AbstractBeanDefinition.getDestroyMethodName()`, `ConfigurableBeanFactory.destroySingletons()`, `org.springframework.context.ConfigurableApplicationContext#close()`

- - ### 方法概要

    所有方法 实例方法 抽象方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `destroy()` Invoked by the containing `BeanFactory` on destruction of a bean.

- - ### 方法详细资料

    - #### destroy

          void destroy()
                throws Exception

      Invoked by the containing `BeanFactory` on destruction of a bean.
      抛出:
        `Exception` - in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources as well.