You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by de...@apache.org on 2010/07/16 18:20:22 UTC

svn commit: r964847 - in /activemq/trunk: ./ activemq-core/ activemq-core/src/main/java/org/apache/activemq/broker/ activemq-core/src/main/java/org/apache/activemq/xbean/ activemq-karaf/src/main/resources/ activemq-karaf/src/main/resources/org/apache/a...

Author: dejanb
Date: Fri Jul 16 16:20:21 2010
New Revision: 964847

URL: http://svn.apache.org/viewvc?rev=964847&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2574 - removing runtime OSGi dependency

Added:
    activemq/trunk/activemq-spring/src/main/java/org/apache/activemq/hooks/
    activemq/trunk/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java
Modified:
    activemq/trunk/activemq-core/pom.xml
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java
    activemq/trunk/activemq-karaf/src/main/resources/features.xml
    activemq/trunk/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml
    activemq/trunk/activemq-spring/pom.xml
    activemq/trunk/assembly/pom.xml
    activemq/trunk/assembly/src/main/descriptors/common-bin.xml
    activemq/trunk/pom.xml

Modified: activemq/trunk/activemq-core/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/pom.xml?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/activemq-core/pom.xml (original)
+++ activemq/trunk/activemq-core/pom.xml Fri Jul 16 16:20:21 2010
@@ -99,29 +99,6 @@
       <artifactId>org.osgi.core</artifactId>
     </dependency>
     
-    <dependency>
-        <groupId>org.springframework.osgi</groupId>
-        <artifactId>spring-osgi-core</artifactId>
-        <exclusions>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>org.springframework.context</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>org.springframework.beans</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>org.springframework.aop</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>org.springframework.core</artifactId>
-            </exclusion>
-        </exclusions>
-    </dependency>
-    
 
     <dependency>
       <groupId>org.apache.activemq</groupId>

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java Fri Jul 16 16:20:21 2010
@@ -1942,6 +1942,17 @@ public class BrokerService implements Se
     }
 
     /**
+     * Sets hooks to be executed when broker shut down
+     * 
+     * @org.apache.xbean.Property
+     */
+    public void setShutdownHooks(List<Runnable> hooks) throws Exception {
+        for (Runnable hook : hooks) {
+            addShutdownHook(hook);
+        }
+    }
+    
+    /**
      * Causes a clean shutdown of the container when the VM is being shut down
      */
     protected void containerShutdown() {

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=964847&r1=964846&r2=964847&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 Jul 16 16:20:21 2010
@@ -25,12 +25,9 @@ import org.apache.activemq.broker.Broker
 import org.apache.activemq.usage.SystemUsage;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleException;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
 
 /**
  * An ActiveMQ Message Broker. It consists of a number of transport
@@ -51,24 +48,6 @@ public class XBeanBrokerService extends 
     
     private boolean start = true;
     private ApplicationContext applicationContext = null;
-    private boolean destroyApplicationContextOnShutdown = false;
-    private boolean destroyApplicationContextOnStop = false;
-
-    Runnable stopContextRunnable = new Runnable() {
-        public void run() {
-            if (applicationContext instanceof ConfigurableApplicationContext) {
-                ((ConfigurableApplicationContext) applicationContext).close();
-            }
-            if (applicationContext instanceof OsgiBundleXmlApplicationContext){
-                try {
-                    ((OsgiBundleXmlApplicationContext)applicationContext).getBundle().stop();
-                } catch (BundleException e) {
-                    LOG.info("Error stopping OSGi bundle " + e, e);
-                }
-            }
-
-        }
-    };
     
     public XBeanBrokerService() {
     }
@@ -84,9 +63,6 @@ public class XBeanBrokerService extends 
         if (start) {
             start();
         }
-        if (destroyApplicationContextOnShutdown) {
-            addShutdownHook(stopContextRunnable);
-        }
     }
 
     private void ensureSystemUsageHasStore() throws IOException {
@@ -108,15 +84,6 @@ public class XBeanBrokerService extends 
     public void destroy() throws Exception {
         stop();
     }
-
-    
-   @Override
-   public void stop() throws Exception {      
-       if (destroyApplicationContextOnStop) {
-           stopContextRunnable.run();
-       }
-       super.stop();
-   }
     
 
     /**
@@ -132,16 +99,18 @@ public class XBeanBrokerService extends 
      * Sets whether the broker should shutdown the ApplicationContext when the broker jvm is shutdown.
      * The broker can be stopped because the underlying JDBC store is unavailable for example.
      */
+    @Deprecated
     public void setDestroyApplicationContextOnShutdown(boolean destroy) {
-        this.destroyApplicationContextOnShutdown = destroy;
+        LOG.warn("destroyApplicationContextOnShutdown parameter is deprecated, please use shutdown hooks instead");
     }
     
     /**
      * 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.
      */
+    @Deprecated
     public void setDestroyApplicationContextOnStop(boolean destroy) {
-        this.destroyApplicationContextOnStop = destroy;
+        LOG.warn("destroyApplicationContextOnStop parameter is deprecated, please use shutdown hooks instead");
     }
 
 	public void setApplicationContext(ApplicationContext applicationContext)

Modified: activemq/trunk/activemq-karaf/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf/src/main/resources/features.xml?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf/src/main/resources/features.xml (original)
+++ activemq/trunk/activemq-karaf/src/main/resources/features.xml Fri Jul 16 16:20:21 2010
@@ -23,6 +23,7 @@
     <feature name="activemq-spring" version="${activemq-version}">
         <feature version="1.2.0">spring-dm</feature> 
         <feature version="${activemq-version}">activemq</feature> 
+        <bundle>mvn:org.apache.activemq/activemq-spring/${activemq-version}</bundle> 
         <bundle>mvn:org.apache.xbean/xbean-spring/${xbean-version}</bundle> 
     </feature>
 

Modified: activemq/trunk/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml (original)
+++ activemq/trunk/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml Fri Jul 16 16:20:21 2010
@@ -100,6 +100,10 @@
         </systemUsage>
         -->
 
+        <shutdownHooks>
+           <bean xmlns="http://www.springframework.org/schema/beans" id="hook" class="org.apache.activemq.hooks.SpringContextHook" />
+        </shutdownHooks>
+
         <!-- The transport connectors ActiveMQ will listen to -->
         <transportConnectors>
             <transportConnector name="openwire" uri="tcp://localhost:61616"/>

Modified: activemq/trunk/activemq-spring/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-spring/pom.xml?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/activemq-spring/pom.xml (original)
+++ activemq/trunk/activemq-spring/pom.xml Fri Jul 16 16:20:21 2010
@@ -39,7 +39,8 @@
     </activemq.osgi.import.pkg>
     <activemq.osgi.export>
       org.apache.activemq.pool*;version=${project.version};-noimport:=;-split-package:=merge-last,
-      org.apache.activemq.xbean*;version=${project.version};-noimport:=true;-split-package:=merge-last
+      org.apache.activemq.xbean*;version=${project.version};-noimport:=true;-split-package:=merge-last,
+      org.apache.activemq.hooks*;version=${project.version};-noimport:=;-split-package:=merge-last
     </activemq.osgi.export>
   </properties>
 
@@ -108,6 +109,29 @@
     	<artifactId>log4j</artifactId>
     	<scope>test</scope>
     </dependency>
+    <dependency>
+        <groupId>org.springframework.osgi</groupId>
+        <artifactId>spring-osgi-core</artifactId>
+        <exclusions>
+            <exclusion>
+                <groupId>org.springframework</groupId>
+                <artifactId>org.springframework.context</artifactId>
+            </exclusion>
+            <exclusion>
+                <groupId>org.springframework</groupId>
+                <artifactId>org.springframework.beans</artifactId>
+            </exclusion>
+            <exclusion>
+                <groupId>org.springframework</groupId>
+                <artifactId>org.springframework.aop</artifactId>
+            </exclusion>
+            <exclusion>
+                <groupId>org.springframework</groupId>
+                <artifactId>org.springframework.core</artifactId>
+            </exclusion>
+        </exclusions>
+    </dependency>    
+    
   </dependencies>
 
 </project>

Added: activemq/trunk/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java?rev=964847&view=auto
==============================================================================
--- activemq/trunk/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java (added)
+++ activemq/trunk/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java Fri Jul 16 16:20:21 2010
@@ -0,0 +1,35 @@
+package org.apache.activemq.hooks;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.BundleException;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
+
+public class SpringContextHook implements Runnable, ApplicationContextAware {
+
+    private static final transient Log LOG = LogFactory.getLog(SpringContextHook.class);
+    ApplicationContext applicationContext;
+    
+    public void run() {
+        if (applicationContext instanceof ConfigurableApplicationContext) {
+            ((ConfigurableApplicationContext) applicationContext).close();
+        }
+        if (applicationContext instanceof OsgiBundleXmlApplicationContext){
+            try {
+                ((OsgiBundleXmlApplicationContext)applicationContext).getBundle().stop();
+            } catch (BundleException e) {
+                LOG.info("Error stopping OSGi bundle " + e, e);
+            }
+        }
+
+    }
+
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = applicationContext;
+    }
+
+}

Modified: activemq/trunk/assembly/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/pom.xml?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/assembly/pom.xml (original)
+++ activemq/trunk/assembly/pom.xml Fri Jul 16 16:20:21 2010
@@ -94,6 +94,10 @@
     </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
+      <artifactId>activemq-spring</artifactId>
+    </dependency>    
+    <dependency>
+      <groupId>${project.groupId}</groupId>
       <artifactId>activemq-web-demo</artifactId>
       <type>war</type>
     </dependency>

Modified: activemq/trunk/assembly/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/main/descriptors/common-bin.xml?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/assembly/src/main/descriptors/common-bin.xml (original)
+++ activemq/trunk/assembly/src/main/descriptors/common-bin.xml Fri Jul 16 16:20:21 2010
@@ -180,6 +180,7 @@
         <include>${pom.groupId}:activemq-optional</include>
         <include>${pom.groupId}:activemq-pool</include>
         <include>${pom.groupId}:activemq-xmpp</include>
+        <include>${pom.groupId}:activemq-spring</include>
         <include>${pom.groupId}:activeio-core</include>
         <include>${pom.groupId}:activemq-jmdns_1.0</include>
         <include>commons-beanutils:commons-beanutils</include>
@@ -209,8 +210,6 @@
         <include>org.codehaus.jettison:jettison</include>
         <include>org.apache.velocity:velocity</include>
         <include>net.sf.josql:josql</include>
-        <include>org.osgi:org.osgi.core</include>
-        <include>org.springframework.osgi:spring-osgi-core</include>
       </includes>
     </dependencySet>
     <dependencySet>
@@ -230,7 +229,6 @@
         <include>org.mortbay.jetty:jsp-2.1-glassfish</include>
         <include>org.mortbay.jetty:jsp-api-2.1-glassfish</include>
         <include>org.eclipse.jdt:core</include>
-        <include>org.apache.ant:ant</include>
 
         <!-- JSTL and other web stuff -->
         <include>opensymphony:sitemesh</include>

Modified: activemq/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/pom.xml?rev=964847&r1=964846&r2=964847&view=diff
==============================================================================
--- activemq/trunk/pom.xml (original)
+++ activemq/trunk/pom.xml Fri Jul 16 16:20:21 2010
@@ -231,6 +231,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.activemq</groupId>
+        <artifactId>activemq-spring</artifactId>
+        <version>${activemq-version}</version>
+      </dependency>      
+      <dependency>
+        <groupId>org.apache.activemq</groupId>
         <artifactId>activemq-web</artifactId>
         <version>${activemq-version}</version>
       </dependency>