From 0a3c0e5300a706b8a504ade0fd997677208424a3 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Wed, 20 Jan 2010 12:54:07 +0000 Subject: [PATCH] https://issues.apache.org/activemq/browse/AMQ-2574 - stop osgi bundle on application context close git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@901171 13f79535-47bb-0310-9956-ffa450edef68 --- activemq-core/pom.xml | 5 +++++ .../apache/activemq/xbean/XBeanBrokerService.java | 15 ++++++++++++++- pom.xml | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/activemq-core/pom.xml b/activemq-core/pom.xml index 8b1f5bdd52..1d6341a0c7 100755 --- a/activemq-core/pom.xml +++ b/activemq-core/pom.xml @@ -97,6 +97,11 @@ org.osgi.core + + org.springframework.osgi + spring-osgi-core + + org.apache.activemq diff --git a/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java b/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java index 2a039866df..89ad2c5b58 100644 --- a/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java +++ b/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java @@ -20,12 +20,16 @@ import java.io.IOException; import org.apache.activemq.broker.BrokerService; 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.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; 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 @@ -42,7 +46,8 @@ import org.springframework.context.ConfigurableApplicationContext; * @version $Revision: 1.1 $ */ public class XBeanBrokerService extends BrokerService implements InitializingBean, DisposableBean, ApplicationContextAware { - + private static final transient Log LOG = LogFactory.getLog(XBeanBrokerService.class); + private boolean start = true; private ApplicationContext applicationContext = null; private boolean destroyApplicationContextOnShutdown = false; @@ -61,6 +66,14 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea 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); + } + } + } }); } diff --git a/pom.xml b/pom.xml index 4f109911c6..8f15745333 100755 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ scp://people.apache.org/x1/www/activemq.apache.org 2.5.6 + 1.2.1 1.3 0.1.0 1.7.1 @@ -582,6 +583,11 @@ spring-oxm-tiger ${spring-oxm-version} + + org.springframework.osgi + spring-osgi-core + ${spring-osgi-version} +