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

@@ -154,6 +154,8 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi
private boolean autoStartup = true;
private int shutdownOrder = Integer.MAX_VALUE;
private boolean running = false;
private final Object lifecycleMonitor = new Object();
@@ -226,6 +228,21 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi
return this.autoStartup;
}
/**
* Specify the order in which this endpoint manager 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 endpoint manager will be stopped.
*/
public int getShutdownOrder() {
return this.shutdownOrder;
}
/**
* Prepares the message endpoint, and automatically activates it
* if the "autoStartup" flag is set to "true".
@@ -280,6 +297,13 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi
}
}
public void stop(Runnable callback) {
synchronized (this.lifecycleMonitor) {
this.stop();
callback.run();
}
}
/**
* Return whether the configured message endpoint is currently active.
*/