本文整理汇总了Java中org.springframework.beans.factory.DisposableBean.destroy方法的典型用法代码示例。如果您正苦于以下问题:Java DisposableBean.destroy方法的具体用法?Java DisposableBean.destroy怎么用?Java DisposableBean.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.DisposableBean
的用法示例。
在下文中一共展示了DisposableBean.destroy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: destroy
import org.springframework.beans.factory.DisposableBean; //导入方法依赖的package包/类
@Override
public void destroy() throws Exception {
if (executor instanceof DisposableBean) {
DisposableBean bean = (DisposableBean) executor;
bean.destroy();
}
}
示例2: dispose
import org.springframework.beans.factory.DisposableBean; //导入方法依赖的package包/类
protected void dispose(String name, Object bean) {
if (DisposableBean.class.isInstance(bean)) {
DisposableBean disposable = DisposableBean.class.cast(bean);
try {
disposable.destroy();
}
catch (Exception e) {
logger.warn("unable to dispose of bean {}", name, bean);
}
}
}
示例3: destroy
import org.springframework.beans.factory.DisposableBean; //导入方法依赖的package包/类
@Override
public void destroy() throws Exception {
if(executor instanceof DisposableBean) {
DisposableBean bean = (DisposableBean) executor;
bean.destroy();
}
}
示例4: closeBean
import org.springframework.beans.factory.DisposableBean; //导入方法依赖的package包/类
private void closeBean(DisposableBean bean) {
try {
if (bean != null) {
bean.destroy();
}
} catch (Exception e) {
// ignore
}
}
示例5: destroyBean
import org.springframework.beans.factory.DisposableBean; //导入方法依赖的package包/类
/**
* Destroy the given bean. Must destroy beans that depend on the given
* bean before the bean itself. Should not throw any exceptions.
* @param beanName the name of the bean
* @param bean the bean instance to destroy
*/
protected void destroyBean(String beanName, DisposableBean bean) {
// Trigger destruction of dependent beans first...
Set<String> dependencies = this.dependentBeanMap.remove(beanName);
if (dependencies != null) {
if (logger.isDebugEnabled()) {
logger.debug("Retrieved dependent beans for bean '" + beanName + "': " + dependencies);
}
for (String dependentBeanName : dependencies) {
destroySingleton(dependentBeanName);
}
}
// Actually destroy the bean now...
if (bean != null) {
try {
bean.destroy();
}
catch (Throwable ex) {
logger.error("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
}
}
// Trigger destruction of contained beans...
Set<String> containedBeans = this.containedBeanMap.remove(beanName);
if (containedBeans != null) {
for (String containedBeanName : containedBeans) {
destroySingleton(containedBeanName);
}
}
// Remove destroyed bean from other beans' dependencies.
synchronized (this.dependentBeanMap) {
for (Iterator<Map.Entry<String, Set<String>>> it = this.dependentBeanMap.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, Set<String>> entry = it.next();
Set<String> dependenciesToClean = entry.getValue();
dependenciesToClean.remove(beanName);
if (dependenciesToClean.isEmpty()) {
it.remove();
}
}
}
// Remove destroyed bean's prepared dependency information.
this.dependenciesForBeanMap.remove(beanName);
}