SimpleTaskScheduler now invokes destroy() on its TaskExecutor if that executor implements DisposableBean (INT-393).
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.util.ErrorHandler;
|
||||
import org.springframework.scheduling.SchedulingException;
|
||||
@@ -42,7 +43,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class SimpleTaskScheduler implements TaskScheduler {
|
||||
public class SimpleTaskScheduler implements TaskScheduler, DisposableBean {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -138,6 +139,16 @@ public class SimpleTaskScheduler implements TaskScheduler {
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() throws Exception {
|
||||
this.stop();
|
||||
if (this.executor instanceof DisposableBean) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("shutting down TaskExecutor");
|
||||
}
|
||||
((DisposableBean) this.executor).destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean prefersShortLivedTasks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user