public interface DisposableBean
BeanFactory
will invoke the destroy method on individual destruction of a
scoped bean. An 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
.
InitializingBean
,
AbstractBeanDefinition.getDestroyMethodName()
,
ConfigurableBeanFactory.destroySingletons()
,
ConfigurableApplicationContext.close()
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Invoked by the containing
BeanFactory on destruction of a bean. |