org.springframework.beans.factory

## Interface DisposableBean

- All Known Implementing Classes:
    AbstractApplicationContext, AbstractBeanFactoryBasedTargetSourceCreator, AbstractEntityManagerFactoryBean, AbstractFactoryBean, AbstractJaxWsServiceExporter, AbstractJmsListeningContainer, AbstractMessageListenerContainer, AbstractPollingMessageListenerContainer, AbstractPoolingTargetSource, AbstractRefreshableApplicationContext, AbstractRefreshableConfigApplicationContext, AbstractRefreshablePortletApplicationContext, AbstractRefreshableWebApplicationContext, AbstractRequestLoggingFilter, AbstractServiceLoaderBasedFactoryBean, AbstractSessionFactoryBean, AbstractXmlApplicationContext, AnnotationConfigApplicationContext, AnnotationConfigWebApplicationContext, AnnotationMBeanExporter, AnnotationSessionFactoryBean, BeanConfigurerSupport, CachingConnectionFactory, CharacterEncodingFilter, ClassPathXmlApplicationContext, CommonsPoolTargetSource, CommonsRequestLoggingFilter, ConnectorServerFactoryBean, ContextLifecycleScheduledTaskRegistrar, DataSourceInitializer, DefaultContextLoadTimeWeaver, DefaultMessageListenerContainer, DelegatingFilterProxy, EhCacheManagerFactoryBean, EmbeddedDatabaseFactoryBean, ExecutorConfigurationSupport, FileSystemXmlApplicationContext, ForkJoinPoolFactoryBean, GenericApplicationContext, GenericFilterBean, GenericGroovyApplicationContext, GenericMessageEndpointManager, GenericWebApplicationContext, GenericXmlApplicationContext, HiddenHttpMethodFilter, HttpComponentsAsyncClientHttpRequestFactory, HttpComponentsClientHttpRequestFactory, HttpPutFormContentFilter, JCacheManagerFactoryBean, JmsMessageEndpointManager, JndiRmiServiceExporter, LazyInitTargetSourceCreator, ListFactoryBean, LocalContainerEntityManagerFactoryBean, LocalEntityManagerFactoryBean, LocalPersistenceManagerFactoryBean, LocalSessionFactoryBean, LocalSessionFactoryBean, LocalValidatorFactoryBean, Log4jNestedDiagnosticContextFilter, MapFactoryBean, MBeanClientInterceptor, MBeanExporter, MBeanProxyFactoryBean, MBeanServerConnectionFactoryBean, MBeanServerFactoryBean, MultipartFilter, NotificationListenerRegistrar, ObjectFactoryCreatingFactoryBean, OncePerRequestFilter, OpenEntityManagerInViewFilter, OpenPersistenceManagerInViewFilter, OpenSessionInViewFilter, OpenSessionInViewFilter, OptionalValidatorFactoryBean, PortletContextScope, PortletWrappingController, ProviderCreatingFactoryBean, QuickTargetSourceCreator, RequestContextFilter, ResourceAdapterApplicationContext, ResourceAdapterFactoryBean, ResourceBundleViewResolver, RmiRegistryFactoryBean, RmiServiceExporter, ScheduledAnnotationBeanPostProcessor, ScheduledExecutorFactoryBean, ScheduledTaskRegistrar, SchedulerFactoryBean, ScriptFactoryPostProcessor, ServiceFactoryBean, ServiceListFactoryBean, ServiceLoaderFactoryBean, ServletContextRequestLoggingFilter, ServletContextScope, ServletWrappingController, SetFactoryBean, ShallowEtagHeaderFilter, SimpleHttpServerFactoryBean, SimpleHttpServerJaxWsServiceExporter, SimpleJaxWsServiceExporter, SimpleMessageListenerContainer, SimpleRemoteSlsbInvokerInterceptor, SimpleRemoteStatelessSessionProxyFactoryBean, SimpleThreadPoolTaskExecutor, SingleConnectionDataSource, SingleConnectionFactory, SingleConnectionFactory, SortedResourcesFactoryBean, StaticApplicationContext, StaticPortletApplicationContext, StaticWebApplicationContext, TaskExecutorFactoryBean, ThreadLocalTargetSource, ThreadPoolExecutorFactoryBean, ThreadPoolTaskExecutor, ThreadPoolTaskScheduler, TilesConfigurer, TilesConfigurer, TimerManagerAccessor, TimerManagerFactoryBean, TimerManagerTaskScheduler, XmlPortletApplicationContext, XmlViewResolver, XmlWebApplicationContext

      public interface DisposableBean

  Interface to be implemented by beans that want to release resources on destruction. A BeanFactory is supposed to invoke the destroy method if it disposes a cached singleton. An application context is supposed to dispose all of its singletons on close.

  An alternative to implementing DisposableBean 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.

  Since:
    12.08.2003
  Author:
    Juergen Hoeller
  See Also:
    `AbstractBeanDefinition.getDestroyMethodName()`, `ConfigurableApplicationContext.close()`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()` Invoked by a BeanFactory on destruction of a singleton.

- - ### Method Detail

    - #### destroy

          void destroy()
                throws Exception

      Invoked by a BeanFactory on destruction of a singleton.
      Throws:
        `Exception` - in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources too.