接口 DestructionAwareBeanPostProcessor
- 所有超级接口:
BeanPostProcessor
- 所有已知实现类:
CommonAnnotationBeanPostProcessor
,InitDestroyAnnotationBeanPostProcessor
,PersistenceAnnotationBeanPostProcessor
,ScheduledAnnotationBeanPostProcessor
,SimplePortletPostProcessor
,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.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
boolean requiresDestruction(Object bean)
Determine whether the given bean instance requires destruction by this post-processor.NOTE: Even as a late addition, this method has been introduced on
DestructionAwareBeanPostProcessor
itself instead of on a SmartDABPP subinterface. This allows existingDestructionAwareBeanPostProcessor
implementations to easily providerequiresDestruction
logic while retaining compatibility with Spring <4.3, and it is also an easier onramp to declaringrequiresDestruction
as a Java 8 default method in Spring 5.If an implementation of
DestructionAwareBeanPostProcessor
does not provide a concrete implementation of this method, Spring's invocation mechanism silently assumes a method returningtrue
(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- 返回:
true
ifpostProcessBeforeDestruction(java.lang.Object, java.lang.String)
is supposed to be called for this bean instance eventually, orfalse
if not needed- 从以下版本开始:
- 4.3