org.springframework.beans.factory.DisposableBean#destroy ( )源码实例Demo

下面列出了org.springframework.beans.factory.DisposableBean#destroy ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
/**
 * Destroy.
 *
 * @throws Exception the exception
 */
@Override
public void destroy() throws Exception {
	if (executor instanceof DisposableBean) {
		DisposableBean bean = (DisposableBean) executor;
		bean.destroy();
	}
}
 
@Override
public void destroy() throws Exception {
	if (this.executor instanceof DisposableBean) {
		DisposableBean bean = (DisposableBean) this.executor;
		bean.destroy();
	}

}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
源代码9 项目: gpmr   文件: ExceptionHandlingAsyncTaskExecutor.java
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
/** {@inheritDoc} */
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
@Override
public void destroy() throws Exception {
    if (executor instanceof DisposableBean) {
        DisposableBean bean = (DisposableBean) executor;
        bean.destroy();
    }
}
 
源代码15 项目: pinpoint   文件: DataReceiverGroupTest.java
private void closeBean(DisposableBean bean) {
    try {
        if (bean != null) {
            bean.destroy();
        }
    } catch (Exception e) {
        // ignore
    }
}
 
/**
 * 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, @Nullable DisposableBean bean) {
	// Trigger destruction of dependent beans first...
	Set<String> dependencies;
	synchronized (this.dependentBeanMap) {
		// Within full synchronization in order to guarantee a disconnected Set
		dependencies = this.dependentBeanMap.remove(beanName);
	}
	if (dependencies != null) {
		if (logger.isTraceEnabled()) {
			logger.trace("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) {
			if (logger.isInfoEnabled()) {
				logger.info("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
			}
		}
	}

	// Trigger destruction of contained beans...
	Set<String> containedBeans;
	synchronized (this.containedBeanMap) {
		// Within full synchronization in order to guarantee a disconnected Set
		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);
}
 
/**
 * 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, @Nullable DisposableBean bean) {
	// Trigger destruction of dependent beans first...
	Set<String> dependencies;
	synchronized (this.dependentBeanMap) {
		// Within full synchronization in order to guarantee a disconnected Set
		dependencies = this.dependentBeanMap.remove(beanName);
	}
	if (dependencies != null) {
		if (logger.isTraceEnabled()) {
			logger.trace("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) {
			if (logger.isInfoEnabled()) {
				logger.info("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
			}
		}
	}

	// Trigger destruction of contained beans...
	Set<String> containedBeans;
	synchronized (this.containedBeanMap) {
		// Within full synchronization in order to guarantee a disconnected Set
		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);
}
 
源代码18 项目: lams   文件: DefaultSingletonBeanRegistry.java
/**
 * 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);
}
 
源代码19 项目: blog_demos   文件: DefaultSingletonBeanRegistry.java
/**
 * 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);
}
 
/**
 * 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);
}