SPR-5507 Added support for shutdown order on SmartLifecycle. DefaultLifecycleProcessor now manages the shutdown in phases depending on that order (with a timeout value per group).

This commit is contained in:
Mark Fisher
2009-11-12 02:09:44 +00:00
parent d666f0a7d6
commit 535ec5cffd
8 changed files with 490 additions and 7 deletions

View File

@@ -190,6 +190,8 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
private int startupDelay = 0;
private int shutdownOrder = Integer.MAX_VALUE;
private boolean exposeSchedulerInRepository = false;
private boolean waitForJobsToCompleteOnShutdown = false;
@@ -373,6 +375,21 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
return this.autoStartup;
}
/**
* Specify the order in which this scheduler should be stopped.
* By default it will be stopped in the last group.
*/
public void setShutdownOrder(int shutdownOrder) {
this.shutdownOrder = shutdownOrder;
}
/**
* Return the order in which this scheduler will be stopped.
*/
public int getShutdownOrder() {
return this.shutdownOrder;
}
/**
* Set the number of seconds to wait after initialization before
* starting the scheduler asynchronously. Default is 0, meaning
@@ -708,6 +725,11 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
}
}
public void stop(Runnable callback) throws SchedulingException {
this.stop();
callback.run();
}
public boolean isRunning() throws SchedulingException {
if (this.scheduler != null) {
try {