Java Code Examples for org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor#requiresDestruction()

The following examples show how to use org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor#requiresDestruction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisposableBeanAdapter.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Search for all DestructionAwareBeanPostProcessors in the List.
 * @param processors the List to search
 * @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;
}
 
Example 2
Source File: DisposableBeanAdapter.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Search for all DestructionAwareBeanPostProcessors in the List.
 * @param processors the List to search
 * @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;
}
 
Example 3
Source File: DisposableBeanAdapter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Search for all DestructionAwareBeanPostProcessors in the List.
 * @param processors the List to search
 * @return the filtered List of DestructionAwareBeanPostProcessors
 */
private List<DestructionAwareBeanPostProcessor> filterPostProcessors(List<BeanPostProcessor> processors, Object bean) {
	List<DestructionAwareBeanPostProcessor> filteredPostProcessors = null;
	if (!CollectionUtils.isEmpty(processors)) {
		filteredPostProcessors = new ArrayList<DestructionAwareBeanPostProcessor>(processors.size());
		for (BeanPostProcessor processor : processors) {
			if (processor instanceof DestructionAwareBeanPostProcessor) {
				DestructionAwareBeanPostProcessor dabpp = (DestructionAwareBeanPostProcessor) processor;
				try {
					if (dabpp.requiresDestruction(bean)) {
						filteredPostProcessors.add(dabpp);
					}
				}
				catch (AbstractMethodError err) {
					// A pre-4.3 third-party DestructionAwareBeanPostProcessor...
					// As of 5.0, we can let requiresDestruction be a Java 8 default method which returns true.
					filteredPostProcessors.add(dabpp);
				}
			}
		}
	}
	return filteredPostProcessors;
}
 
Example 4
Source File: DisposableBeanAdapter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check whether the given bean has destruction-aware post-processors applying to it.
 * @param bean the bean instance
 * @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;
				try {
					if (dabpp.requiresDestruction(bean)) {
						return true;
					}
				}
				catch (AbstractMethodError err) {
					// A pre-4.3 third-party DestructionAwareBeanPostProcessor...
					// As of 5.0, we can let requiresDestruction be a Java 8 default method which returns true.
					return true;
				}
			}
		}
	}
	return false;
}
 
Example 5
Source File: DisposableBeanAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Check whether the given bean has destruction-aware post-processors applying to it.
 * @param bean the bean instance
 * @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;
}
 
Example 6
Source File: DisposableBeanAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Check whether the given bean has destruction-aware post-processors applying to it.
 * @param bean the bean instance
 * @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;
}