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

@@ -65,6 +65,8 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
private boolean autoStartup = true;
private int shutdownOrder = Integer.MAX_VALUE;
private String beanName;
private Connection sharedConnection;
@@ -116,6 +118,21 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
return this.autoStartup;
}
/**
* Specify the order in which this container 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 container will be stopped.
*/
public int getShutdownOrder() {
return this.shutdownOrder;
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
@@ -286,6 +303,11 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
}
}
public void stop(Runnable callback) {
this.stop();
callback.run();
}
/**
* Notify all invoker tasks and stop the shared Connection, if any.
* @throws JMSException if thrown by JMS API methods

View File

@@ -514,6 +514,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
* @throws JmsException if stopping failed
* @see #stop()
*/
@Override
public void stop(Runnable callback) throws JmsException {
synchronized (this.lifecycleMonitor) {
this.stopCallback = callback;