public interface DestructionAwareBeanPostProcessor extends BeanPostProcessor
BeanPostProcessor that adds a before-destruction callback.
The typical usage will be to invoke custom destruction callbacks on specific bean types, matching corresponding initialization callbacks.
| Modifier and Type | Method and Description |
|---|---|
void |
postProcessBeforeDestruction(Object bean,
String beanName)
Apply this BeanPostProcessor to the given bean instance before its
destruction, e.g.
|
default boolean |
requiresDestruction(Object bean)
Determine whether the given bean instance requires destruction by this
post-processor.
|
postProcessAfterInitialization, postProcessBeforeInitializationvoid postProcessBeforeDestruction(Object bean, String beanName) throws BeansException
Like DisposableBean's destroy and a custom destroy method, this
callback will only apply to beans which the container fully manages the
lifecycle for. This is usually the case for singletons and scoped beans.
bean - the bean instance to be destroyedbeanName - the name of the beanBeansException - in case of errorsDisposableBean.destroy(),
AbstractBeanDefinition.setDestroyMethodName(String)default boolean requiresDestruction(Object bean)
The default implementation returns true. If a pre-5 implementation
of DestructionAwareBeanPostProcessor does not provide a concrete
implementation of this method, Spring silently assumes true as well.
bean - the bean instance to checktrue if postProcessBeforeDestruction(java.lang.Object, java.lang.String) is supposed to
be called for this bean instance eventually, or false if not needed