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
This commit is contained in:
Bosanac Dejan 2010-01-20 12:54:07 +00:00
parent e5d134d4c0
commit 0a3c0e5300
3 changed files with 25 additions and 1 deletions

View File

@ -97,6 +97,11 @@
<artifactId>org.osgi.core</artifactId> <artifactId>org.osgi.core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>spring-osgi-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>

View File

@ -20,12 +20,16 @@ import java.io.IOException;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.usage.SystemUsage; 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.BeansException;
import org.springframework.beans.factory.DisposableBean; 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; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
/** /**
* An ActiveMQ Message Broker. It consists of a number of transport * An ActiveMQ Message Broker. It consists of a number of transport
@ -42,7 +46,8 @@ import org.springframework.context.ConfigurableApplicationContext;
* @version $Revision: 1.1 $ * @version $Revision: 1.1 $
*/ */
public class XBeanBrokerService extends BrokerService implements InitializingBean, DisposableBean, ApplicationContextAware { public class XBeanBrokerService extends BrokerService implements InitializingBean, DisposableBean, ApplicationContextAware {
private static final transient Log LOG = LogFactory.getLog(XBeanBrokerService.class);
private boolean start = true; private boolean start = true;
private ApplicationContext applicationContext = null; private ApplicationContext applicationContext = null;
private boolean destroyApplicationContextOnShutdown = false; private boolean destroyApplicationContextOnShutdown = false;
@ -61,6 +66,14 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
if (applicationContext instanceof ConfigurableApplicationContext) { if (applicationContext instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) applicationContext).close(); ((ConfigurableApplicationContext) applicationContext).close();
} }
if (applicationContext instanceof OsgiBundleXmlApplicationContext){
try {
((OsgiBundleXmlApplicationContext)applicationContext).getBundle().stop();
} catch (BundleException e) {
LOG.info("Error stopping OSGi bundle " + e, e);
}
}
} }
}); });
} }

View File

@ -37,6 +37,7 @@
<!-- base url for site deployment. See distribution management for full url. Override this in settings.xml for staging --> <!-- base url for site deployment. See distribution management for full url. Override this in settings.xml for staging -->
<staging.siteURL>scp://people.apache.org/x1/www/activemq.apache.org</staging.siteURL> <staging.siteURL>scp://people.apache.org/x1/www/activemq.apache.org</staging.siteURL>
<spring-version>2.5.6</spring-version> <spring-version>2.5.6</spring-version>
<spring-osgi-version>1.2.1</spring-osgi-version>
<activesoap-version>1.3</activesoap-version> <activesoap-version>1.3</activesoap-version>
<annogen-version>0.1.0</annogen-version> <annogen-version>0.1.0</annogen-version>
<ant-version>1.7.1</ant-version> <ant-version>1.7.1</ant-version>
@ -582,6 +583,11 @@
<artifactId>spring-oxm-tiger</artifactId> <artifactId>spring-oxm-tiger</artifactId>
<version>${spring-oxm-version}</version> <version>${spring-oxm-version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>spring-osgi-core</artifactId>
<version>${spring-osgi-version}</version>
</dependency>
<!-- Optional Derby support--> <!-- Optional Derby support-->
<dependency> <dependency>