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:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user