public interface DestructionAwareBeanPostProcessor extends BeanPostProcessor
BeanPostProcessorthat 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|
Apply this BeanPostProcessor to the given bean instance before its destruction, e.g.
Determine whether the given bean instance requires destruction by this post-processor.
void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException
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 destroyed
beanName- the name of the bean
BeansException- in case of errors
boolean requiresDestruction(Object bean)
NOTE: Even as a late addition, this method has been introduced on
DestructionAwareBeanPostProcessor itself instead of on a SmartDABPP
subinterface. This allows existing
implementations to easily provide
requiresDestruction logic while
retaining compatibility with Spring <4.3, and it is also an easier onramp to
requiresDestruction as a Java 8 default method in Spring 5.
If an implementation of
not provide a concrete implementation of this method, Spring's invocation
mechanism silently assumes a method returning
true (the effective
default before 4.3, and the to-be-default in the Java 8 method in Spring 5).
bean- the bean instance to check
postProcessBeforeDestruction(java.lang.Object, java.lang.String)is supposed to be called for this bean instance eventually, or
falseif not needed