RESOLVED - issue SPR-6955, SPR-6901 added DisposableBean to TaskExecutorFactoryBean

This commit is contained in:
David Syer 2010-03-08 12:13:30 +00:00
parent 5303ab68aa
commit 8d7df01d73
1 changed files with 8 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.JdkVersion;
@ -33,7 +34,7 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher
* @since 3.0
*/
public class TaskExecutorFactoryBean implements FactoryBean<TaskExecutor>, BeanNameAware {
public class TaskExecutorFactoryBean implements FactoryBean<TaskExecutor>, BeanNameAware, DisposableBean {
private volatile TaskExecutor target;
@ -89,6 +90,12 @@ public class TaskExecutorFactoryBean implements FactoryBean<TaskExecutor>, BeanN
public boolean isSingleton() {
return true;
}
public void destroy() throws Exception {
if (this.target instanceof DisposableBean) {
((DisposableBean) this.target).destroy();
}
}
private void initializeExecutor() throws Exception {
synchronized (this.initializationMonitor) {