Top Description Methods
org.springframework.beans.factory

public Interface DisposableBean

Known Direct Implementers
org.springframework.beans.factory.config.AbstractFactoryBean, org.springframework.beans.factory.support.DisposableBeanAdapter, org.springframework.beans.factory.wiring.BeanConfigurerSupport

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.

Author
Juergen Hoeller
Since
12.08.2003
See Also
InitializingBean, org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName(), org.springframework.beans.factory.config.ConfigurableBeanFactory#destroySingletons(), org.springframework.context.ConfigurableApplicationContext#close()

Method Summary

Modifier and TypeMethod and Description
public void
destroy()

Invoked by the containing BeanFactory on destruction of a bean.

Method Detail

destroyback to summary
public void destroy() throws Exception

Invoked by the containing BeanFactory on destruction of a bean.

Exceptions
Exception:
in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources as well.