mirror of https://github.com/apache/activemq.git
AMQ-1733: Add an option to allow the xbean broker to destroy the spring application context when the broker is stopped
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@657059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2076f452e7
commit
b609bdb95b
|
@ -22,6 +22,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ActiveMQ Message Broker. It consists of a number of transport
|
* An ActiveMQ Message Broker. It consists of a number of transport
|
||||||
|
@ -41,6 +42,7 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
|
||||||
|
|
||||||
private boolean start = true;
|
private boolean start = true;
|
||||||
private ApplicationContext applicationContext = null;
|
private ApplicationContext applicationContext = null;
|
||||||
|
private boolean destroyApplicationContextOnShutdown = false;
|
||||||
|
|
||||||
public XBeanBrokerService() {
|
public XBeanBrokerService() {
|
||||||
}
|
}
|
||||||
|
@ -49,6 +51,15 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
|
||||||
if (start) {
|
if (start) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
if (destroyApplicationContextOnShutdown) {
|
||||||
|
addShutdownHook(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (applicationContext instanceof ConfigurableApplicationContext) {
|
||||||
|
((ConfigurableApplicationContext) applicationContext).close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
|
@ -68,6 +79,14 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
|
||||||
this.start = start;
|
this.start = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the broker should shutdown the ApplicationContext when the broker is stopped.
|
||||||
|
* The broker can be stopped because the underlying JDBC store is unavailable for example.
|
||||||
|
*/
|
||||||
|
public void setDestroyApplicationContextOnShutdown(boolean destroy) {
|
||||||
|
this.destroyApplicationContextOnShutdown = destroy;
|
||||||
|
}
|
||||||
|
|
||||||
public void setApplicationContext(ApplicationContext applicationContext)
|
public void setApplicationContext(ApplicationContext applicationContext)
|
||||||
throws BeansException {
|
throws BeansException {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
|
|
|
@ -824,6 +824,14 @@ with JUnit tests you may wish to start and stop the broker explicitly yourself.
|
||||||
]]></xs:documentation>
|
]]></xs:documentation>
|
||||||
</xs:annotation>
|
</xs:annotation>
|
||||||
</xs:attribute>
|
</xs:attribute>
|
||||||
|
<xs:attribute name='destroyApplicationContextOnShutdown' type='xs:boolean'>
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation><![CDATA[
|
||||||
|
Sets whether the broker should shutdown the ApplicationContext when the broker is stopped.
|
||||||
|
The broker can be stopped because the underlying JDBC store is unavailable for example.
|
||||||
|
]]></xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:attribute>
|
||||||
<xs:attribute name='supportFailOver' type='xs:boolean'/>
|
<xs:attribute name='supportFailOver' type='xs:boolean'/>
|
||||||
<xs:attribute name='systemExitOnShutdown' type='xs:boolean'/>
|
<xs:attribute name='systemExitOnShutdown' type='xs:boolean'/>
|
||||||
<xs:attribute name='systemExitOnShutdownExitCode' type='xs:integer'/>
|
<xs:attribute name='systemExitOnShutdownExitCode' type='xs:integer'/>
|
||||||
|
|
|
@ -401,6 +401,8 @@ the JDBC and Journal persistence adaptors.</td></tr>
|
||||||
<tr><td>dedicatedTaskRunner</td><td>xs:boolean</td><td></td></tr>
|
<tr><td>dedicatedTaskRunner</td><td>xs:boolean</td><td></td></tr>
|
||||||
<tr><td>deleteAllMessagesOnStartup</td><td>xs:boolean</td><td>Sets whether or not all messages are deleted on startup - mostly only
|
<tr><td>deleteAllMessagesOnStartup</td><td>xs:boolean</td><td>Sets whether or not all messages are deleted on startup - mostly only
|
||||||
useful for testing.</td></tr>
|
useful for testing.</td></tr>
|
||||||
|
<tr><td>destroyApplicationContextOnShutdown</td><td>xs:boolean</td><td> Sets whether the broker should shutdown the ApplicationContext when the broker is stopped.
|
||||||
|
The broker can be stopped because the underlying JDBC store is unavailable for example.</td></tr>
|
||||||
<tr><td>enableStatistics</td><td>xs:boolean</td><td>Sets whether or not the Broker's services enable statistics or not.</td></tr>
|
<tr><td>enableStatistics</td><td>xs:boolean</td><td>Sets whether or not the Broker's services enable statistics or not.</td></tr>
|
||||||
<tr><td>keepDurableSubsActive</td><td>xs:boolean</td><td></td></tr>
|
<tr><td>keepDurableSubsActive</td><td>xs:boolean</td><td></td></tr>
|
||||||
<tr><td>masterConnectorURI</td><td>xs:string</td><td></td></tr>
|
<tr><td>masterConnectorURI</td><td>xs:string</td><td></td></tr>
|
||||||
|
|
|
@ -642,6 +642,8 @@ useful for testing.{html} |
|
||||||
| destinationPolicy | _[org.apache.activemq.broker.region.policy.PolicyMap|#org.apache.activemq.broker.region.policy.PolicyMap-types]_ | {html}Sets the destination specific policies available either for exact
|
| destinationPolicy | _[org.apache.activemq.broker.region.policy.PolicyMap|#org.apache.activemq.broker.region.policy.PolicyMap-types]_ | {html}Sets the destination specific policies available either for exact
|
||||||
destinations or for wildcard areas of destinations.{html} |
|
destinations or for wildcard areas of destinations.{html} |
|
||||||
| destinations | (_[org.apache.activemq.command.ActiveMQDestination|#org.apache.activemq.command.ActiveMQDestination-types]_)\* | {html}Sets the destinations which should be loaded/created on startup{html} |
|
| destinations | (_[org.apache.activemq.command.ActiveMQDestination|#org.apache.activemq.command.ActiveMQDestination-types]_)\* | {html}Sets the destinations which should be loaded/created on startup{html} |
|
||||||
|
| destroyApplicationContextOnShutdown | _boolean_ | {html}Sets whether the broker should shutdown the ApplicationContext when the broker is stopped.
|
||||||
|
The broker can be stopped because the underlying JDBC store is unavailable for example.{html} |
|
||||||
| enableStatistics | _boolean_ | {html}Sets whether or not the Broker's services enable statistics or not.{html} |
|
| enableStatistics | _boolean_ | {html}Sets whether or not the Broker's services enable statistics or not.{html} |
|
||||||
| jmsBridgeConnectors | (_[org.apache.activemq.network.jms.JmsConnector|#org.apache.activemq.network.jms.JmsConnector-types]_)\* | {html}{html} |
|
| jmsBridgeConnectors | (_[org.apache.activemq.network.jms.JmsConnector|#org.apache.activemq.network.jms.JmsConnector-types]_)\* | {html}{html} |
|
||||||
| keepDurableSubsActive | _boolean_ | {html}{html} |
|
| keepDurableSubsActive | _boolean_ | {html}{html} |
|
||||||
|
|
Loading…
Reference in New Issue