Example usage for org.springframework.beans.factory.config DestructionAwareBeanPostProcessor requiresDestruction

List of usage examples for org.springframework.beans.factory.config DestructionAwareBeanPostProcessor requiresDestruction

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config DestructionAwareBeanPostProcessor requiresDestruction.

Prototype

default boolean requiresDestruction(Object bean) 

Source Link

Document

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

Usage

From source file:org.springframework.beans.factory.support.DisposableBeanAdapter.java

/**
 * Search for all DestructionAwareBeanPostProcessors in the List.
 * @param processors the List to search//from   w ww . ja  v a  2 s  .c om
 * @return the filtered List of DestructionAwareBeanPostProcessors
 */
@Nullable
private List<DestructionAwareBeanPostProcessor> filterPostProcessors(List<BeanPostProcessor> processors,
        Object bean) {
    List<DestructionAwareBeanPostProcessor> filteredPostProcessors = null;
    if (!CollectionUtils.isEmpty(processors)) {
        filteredPostProcessors = new ArrayList<>(processors.size());
        for (BeanPostProcessor processor : processors) {
            if (processor instanceof DestructionAwareBeanPostProcessor) {
                DestructionAwareBeanPostProcessor dabpp = (DestructionAwareBeanPostProcessor) processor;
                if (dabpp.requiresDestruction(bean)) {
                    filteredPostProcessors.add(dabpp);
                }
            }
        }
    }
    return filteredPostProcessors;
}

From source file:org.springframework.beans.factory.support.DisposableBeanAdapter.java

/**
 * Check whether the given bean has destruction-aware post-processors applying to it.
 * @param bean the bean instance/*from  www.  j  a v a2  s.c  om*/
 * @param postProcessors the post-processor candidates
 */
public static boolean hasApplicableProcessors(Object bean, List<BeanPostProcessor> postProcessors) {
    if (!CollectionUtils.isEmpty(postProcessors)) {
        for (BeanPostProcessor processor : postProcessors) {
            if (processor instanceof DestructionAwareBeanPostProcessor) {
                DestructionAwareBeanPostProcessor dabpp = (DestructionAwareBeanPostProcessor) processor;
                if (dabpp.requiresDestruction(bean)) {
                    return true;
                }
            }
        }
    }
    return false;
}