Top Description Methods
org.springframework.beans.factory.config

public Interface DestructionAwareBeanPostProcessor

extends BeanPostProcessor
Known Direct Implementers
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor
Imports
org.springframework.beans.BeansException

Subinterface of 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.

Author
Juergen Hoeller
Since
1.0.1

Method Summary

Modifier and TypeMethod and Description
public void
postProcessBeforeDestruction(Object
the bean instance to be destroyed
bean
,
String
the name of the bean
beanName
)

Apply this BeanPostProcessor to the given bean instance before its destruction, e.g. invoking custom destruction callbacks.

public default boolean

Returns:

true if postProcessBeforeDestruction is supposed to be called for this bean instance eventually, or false if not needed
requiresDestruction
(Object
the bean instance to check
bean
)

Determine whether the given bean instance requires destruction by this post-processor.

Inherited from org.springframework.beans.factory.config.BeanPostProcessor:
postProcessAfterInitializationpostProcessBeforeInitialization

Method Detail

postProcessBeforeDestructionback to summary
public 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.

Parameters
bean:Object

the bean instance to be destroyed

beanName:String

the name of the bean

Exceptions
BeansException:
in case of errors
See Also
org.springframework.beans.factory.DisposableBean#destroy(), org.springframework.beans.factory.support.AbstractBeanDefinition#setDestroyMethodName(String)
requiresDestructionback to summary
public 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 of DestructionAwareBeanPostProcessor does not provide a concrete implementation of this method, Spring silently assumes true as well.

Parameters
bean:Object

the bean instance to check

Returns:boolean

true if postProcessBeforeDestruction is supposed to be called for this bean instance eventually, or false if not needed

Since
4.3