• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DestructionAwareBeanPostProcessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor的典型用法代码示例。如果您正苦于以下问题:Java DestructionAwareBeanPostProcessor类的具体用法?Java DestructionAwareBeanPostProcessor怎么用?Java DestructionAwareBeanPostProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DestructionAwareBeanPostProcessor类属于org.springframework.beans.factory.config包,在下文中一共展示了DestructionAwareBeanPostProcessor类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: filterPostProcessors

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:txazo,项目名称:spring,代码行数:28,代码来源:DisposableBeanAdapter.java


示例2: hasApplicableProcessors

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:txazo,项目名称:spring,代码行数:26,代码来源:DisposableBeanAdapter.java


示例3: DisposableBeanAdapter

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
/**
 * Create a new DisposableBeanAdapter for the given bean.
 */
private DisposableBeanAdapter(Object bean, String beanName, boolean invokeDisposableBean,
		boolean nonPublicAccessAllowed, String destroyMethodName,
		List<DestructionAwareBeanPostProcessor> postProcessors) {

	this.bean = bean;
	this.beanName = beanName;
	this.invokeDisposableBean = invokeDisposableBean;
	this.nonPublicAccessAllowed = nonPublicAccessAllowed;
	this.acc = null;
	this.destroyMethodName = destroyMethodName;
	this.beanPostProcessors = postProcessors;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:DisposableBeanAdapter.java


示例4: filterPostProcessors

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
/**
 * Search for all DestructionAwareBeanPostProcessors in the List.
 * @param postProcessors the List to search
 * @return the filtered List of DestructionAwareBeanPostProcessors
 */
private List<DestructionAwareBeanPostProcessor> filterPostProcessors(List<BeanPostProcessor> postProcessors) {
	List<DestructionAwareBeanPostProcessor> filteredPostProcessors = null;
	if (postProcessors != null && !postProcessors.isEmpty()) {
		filteredPostProcessors = new ArrayList<DestructionAwareBeanPostProcessor>(postProcessors.size());
		for (BeanPostProcessor postProcessor : postProcessors) {
			if (postProcessor instanceof DestructionAwareBeanPostProcessor) {
				filteredPostProcessors.add((DestructionAwareBeanPostProcessor) postProcessor);
			}
		}
	}
	return filteredPostProcessors;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:DisposableBeanAdapter.java


示例5: writeReplace

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
/**
 * Serializes a copy of the state of this class,
 * filtering out non-serializable BeanPostProcessors.
 */
protected Object writeReplace() {
	List<DestructionAwareBeanPostProcessor> serializablePostProcessors = null;
	if (this.beanPostProcessors != null) {
		serializablePostProcessors = new ArrayList<DestructionAwareBeanPostProcessor>();
		for (DestructionAwareBeanPostProcessor postProcessor : this.beanPostProcessors) {
			if (postProcessor instanceof Serializable) {
				serializablePostProcessors.add(postProcessor);
			}
		}
	}
	return new DisposableBeanAdapter(this.bean, this.beanName, this.invokeDisposableBean,
			this.nonPublicAccessAllowed, this.destroyMethodName, serializablePostProcessors);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:DisposableBeanAdapter.java


示例6: addBeanPostProcessor

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
@Override
public void addBeanPostProcessor(BeanPostProcessor beanPostProcessor) {
	Assert.notNull(beanPostProcessor, "BeanPostProcessor must not be null");
	this.beanPostProcessors.remove(beanPostProcessor);
	this.beanPostProcessors.add(beanPostProcessor);
	if (beanPostProcessor instanceof InstantiationAwareBeanPostProcessor) {
		this.hasInstantiationAwareBeanPostProcessors = true;
	}
	if (beanPostProcessor instanceof DestructionAwareBeanPostProcessor) {
		this.hasDestructionAwareBeanPostProcessors = true;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:AbstractBeanFactory.java


示例7: filterPostProcessors

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
/**
 * Search for all DestructionAwareBeanPostProcessors in the List.
 * @param postProcessors the List to search
 * @return the filtered List of DestructionAwareBeanPostProcessors
 */
private List<DestructionAwareBeanPostProcessor> filterPostProcessors(List<BeanPostProcessor> postProcessors) {
	List<DestructionAwareBeanPostProcessor> filteredPostProcessors = null;
	if (!CollectionUtils.isEmpty(postProcessors)) {
		filteredPostProcessors = new ArrayList<DestructionAwareBeanPostProcessor>(postProcessors.size());
		for (BeanPostProcessor postProcessor : postProcessors) {
			if (postProcessor instanceof DestructionAwareBeanPostProcessor) {
				filteredPostProcessors.add((DestructionAwareBeanPostProcessor) postProcessor);
			}
		}
	}
	return filteredPostProcessors;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:DisposableBeanAdapter.java


示例8: addBeanPostProcessor

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
public void addBeanPostProcessor(BeanPostProcessor beanPostProcessor) {
	Assert.notNull(beanPostProcessor, "BeanPostProcessor must not be null");
	this.beanPostProcessors.remove(beanPostProcessor);
	this.beanPostProcessors.add(beanPostProcessor);
	if (beanPostProcessor instanceof InstantiationAwareBeanPostProcessor) {
		this.hasInstantiationAwareBeanPostProcessors = true;
	}
	if (beanPostProcessor instanceof DestructionAwareBeanPostProcessor) {
		this.hasDestructionAwareBeanPostProcessors = true;
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:AbstractBeanFactory.java


示例9: destroy

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
@Override
public void destroy() {
	if (this.beanPostProcessors != null && !this.beanPostProcessors.isEmpty()) {
		for (DestructionAwareBeanPostProcessor processor : this.beanPostProcessors) {
			processor.postProcessBeforeDestruction(this.bean, this.beanName);
		}
	}

	if (this.invokeDisposableBean) {
		if (logger.isDebugEnabled()) {
			logger.debug("Invoking destroy() on bean with name '" + this.beanName + "'");
		}
		try {
			if (System.getSecurityManager() != null) {
				AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
					@Override
					public Object run() throws Exception {
						((DisposableBean) bean).destroy();
						return null;
					}
				}, acc);
			}
			else {
				((DisposableBean) bean).destroy();
			}
		}
		catch (Throwable ex) {
			String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
			if (logger.isDebugEnabled()) {
				logger.warn(msg, ex);
			}
			else {
				logger.warn(msg + ": " + ex);
			}
		}
	}

	if (this.destroyMethod != null) {
		invokeCustomDestroyMethod(this.destroyMethod);
	}
	else if (this.destroyMethodName != null) {
		Method methodToCall = determineDestroyMethod();
		if (methodToCall != null) {
			invokeCustomDestroyMethod(methodToCall);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:DisposableBeanAdapter.java


示例10: destroy

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
@Override
public void destroy() {
	if (!CollectionUtils.isEmpty(this.beanPostProcessors)) {
		for (DestructionAwareBeanPostProcessor processor : this.beanPostProcessors) {
			processor.postProcessBeforeDestruction(this.bean, this.beanName);
		}
	}

	if (this.invokeDisposableBean) {
		if (logger.isDebugEnabled()) {
			logger.debug("Invoking destroy() on bean with name '" + this.beanName + "'");
		}
		try {
			if (System.getSecurityManager() != null) {
				AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
					@Override
					public Object run() throws Exception {
						((DisposableBean) bean).destroy();
						return null;
					}
				}, acc);
			}
			else {
				((DisposableBean) bean).destroy();
			}
		}
		catch (Throwable ex) {
			String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
			if (logger.isDebugEnabled()) {
				logger.warn(msg, ex);
			}
			else {
				logger.warn(msg + ": " + ex);
			}
		}
	}

	if (this.destroyMethod != null) {
		invokeCustomDestroyMethod(this.destroyMethod);
	}
	else if (this.destroyMethodName != null) {
		Method methodToCall = determineDestroyMethod();
		if (methodToCall != null) {
			invokeCustomDestroyMethod(methodToCall);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:48,代码来源:DisposableBeanAdapter.java


示例11: destroy

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; //导入依赖的package包/类
public void destroy() {
	if (this.beanPostProcessors != null && !this.beanPostProcessors.isEmpty()) {
		for (DestructionAwareBeanPostProcessor processor : this.beanPostProcessors) {
			processor.postProcessBeforeDestruction(this.bean, this.beanName);
		}
	}

	if (this.invokeDisposableBean) {
		if (logger.isDebugEnabled()) {
			logger.debug("Invoking destroy() on bean with name '" + this.beanName + "'");
		}
		try {
			if (System.getSecurityManager() != null) {
				AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
					public Object run() throws Exception {
						((DisposableBean) bean).destroy();
						return null;
					}
				}, acc);
			}
			else {
				((DisposableBean) bean).destroy();
			}
		}
		catch (Throwable ex) {
			String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
			if (logger.isDebugEnabled()) {
				logger.warn(msg, ex);
			}
			else {
				logger.warn(msg + ": " + ex);
			}
		}
	}

	if (this.destroyMethod != null) {
		invokeCustomDestroyMethod(this.destroyMethod);
	}
	else if (this.destroyMethodName != null) {
		Method methodToCall = determineDestroyMethod();
		if (methodToCall != null) {
			invokeCustomDestroyMethod(methodToCall);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:46,代码来源:DisposableBeanAdapter.java



注:本文中的org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GroundOverlay类代码示例发布时间:2022-05-21
下一篇:
Java FileConnection类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap