本文整理匯總了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);
}