You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gn...@apache.org on 2008/05/16 15:38:29 UTC

svn commit: r657059 - in /activemq/trunk/activemq-core/src/main: java/org/apache/activemq/xbean/XBeanBrokerService.java resources/activemq.xsd resources/activemq.xsd.html resources/activemq.xsd.wiki

Author: gnodet
Date: Fri May 16 06:38:29 2008
New Revision: 657059

URL: http://svn.apache.org/viewvc?rev=657059&view=rev
Log:
AMQ-1733: Add an option to allow the xbean broker to destroy the spring application context when the broker is stopped

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java
    activemq/trunk/activemq-core/src/main/resources/activemq.xsd
    activemq/trunk/activemq-core/src/main/resources/activemq.xsd.html
    activemq/trunk/activemq-core/src/main/resources/activemq.xsd.wiki

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java?rev=657059&r1=657058&r2=657059&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java Fri May 16 06:38:29 2008
@@ -22,6 +22,7 @@
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ConfigurableApplicationContext;
 
 /**
  * An ActiveMQ Message Broker. It consists of a number of transport
@@ -41,6 +42,7 @@
 
     private boolean start = true;
     private ApplicationContext applicationContext = null;
+    private boolean destroyApplicationContextOnShutdown = false;
 
     public XBeanBrokerService() {
     }
@@ -49,6 +51,15 @@
         if (start) {
             start();
         }
+        if (destroyApplicationContextOnShutdown) {
+            addShutdownHook(new Runnable() {
+                public void run() {
+                    if (applicationContext instanceof ConfigurableApplicationContext) {
+	                    ((ConfigurableApplicationContext) applicationContext).close();
+                    }
+                }
+            });
+        }
     }
 
     public void destroy() throws Exception {
@@ -68,6 +79,14 @@
         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)
 			throws BeansException {
 		this.applicationContext = applicationContext;

Modified: activemq/trunk/activemq-core/src/main/resources/activemq.xsd
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/resources/activemq.xsd?rev=657059&r1=657058&r2=657059&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/resources/activemq.xsd (original)
+++ activemq/trunk/activemq-core/src/main/resources/activemq.xsd Fri May 16 06:38:29 2008
@@ -824,6 +824,14 @@
           ]]></xs:documentation>
         </xs:annotation>
       </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='systemExitOnShutdown' type='xs:boolean'/>
       <xs:attribute name='systemExitOnShutdownExitCode' type='xs:integer'/>

Modified: activemq/trunk/activemq-core/src/main/resources/activemq.xsd.html
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/resources/activemq.xsd.html?rev=657059&r1=657058&r2=657059&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/resources/activemq.xsd.html (original)
+++ activemq/trunk/activemq-core/src/main/resources/activemq.xsd.html Fri May 16 06:38:29 2008
@@ -401,6 +401,8 @@
   <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
 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>keepDurableSubsActive</td><td>xs:boolean</td><td></td></tr>
   <tr><td>masterConnectorURI</td><td>xs:string</td><td></td></tr>

Modified: activemq/trunk/activemq-core/src/main/resources/activemq.xsd.wiki
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/resources/activemq.xsd.wiki?rev=657059&r1=657058&r2=657059&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/resources/activemq.xsd.wiki (original)
+++ activemq/trunk/activemq-core/src/main/resources/activemq.xsd.wiki Fri May 16 06:38:29 2008
@@ -642,6 +642,8 @@
     | 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 | (_[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} |
     | jmsBridgeConnectors | (_[org.apache.activemq.network.jms.JmsConnector|#org.apache.activemq.network.jms.JmsConnector-types]_)\* | {html}{html} |
     | keepDurableSubsActive | _boolean_ | {html}{html} |