接口 DestructionAwareBeanPostProcessor
- 所有超级接口:
BeanPostProcessor
- 所有已知实现类:
CommonAnnotationBeanPostProcessor
,InitDestroyAnnotationBeanPostProcessor
,PersistenceAnnotationBeanPostProcessor
,ScheduledAnnotationBeanPostProcessor
,SimpleServletPostProcessor
public interface DestructionAwareBeanPostProcessor extends BeanPostProcessor
Subinterface ofBeanPostProcessor
that adds a before-destruction callback.The typical usage will be to invoke custom destruction callbacks on specific bean types, matching corresponding initialization callbacks.
- 从以下版本开始:
- 1.0.1
- 作者:
- Juergen Hoeller
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 void
postProcessBeforeDestruction(Object bean, String beanName)
Apply this BeanPostProcessor to the given bean instance before its destruction, e.g. invoking custom destruction callbacks.default boolean
requiresDestruction(Object bean)
Determine whether the given bean instance requires destruction by this post-processor.从接口继承的方法 org.springframework.beans.factory.config.BeanPostProcessor
postProcessAfterInitialization, postProcessBeforeInitialization
方法详细资料
postProcessBeforeDestruction
void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException
Apply this BeanPostProcessor to the given bean instance before its destruction, e.g. invoking custom destruction callbacks.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 bean- 抛出:
BeansException
- in case of errors- 另请参阅:
DisposableBean.destroy()
,AbstractBeanDefinition.setDestroyMethodName(String)
requiresDestruction
default boolean requiresDestruction(Object bean)
Determine whether the given bean instance requires destruction by this post-processor.The default implementation returns
true
. If a pre-5 implementation ofDestructionAwareBeanPostProcessor
does not provide a concrete implementation of this method, Spring silently assumestrue
as well.- 参数:
bean
- the bean instance to check- 返回:
true
ifpostProcessBeforeDestruction(java.lang.Object, java.lang.String)
is supposed to be called for this bean instance eventually, orfalse
if not needed- 从以下版本开始:
- 4.3