From b469638171985a9abe6ba4cd9c33720cab11a6dc Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Tue, 25 Sep 2012 22:52:28 +0000 Subject: [PATCH] fix up assembly xml configuration validtion tests - have them run by default. Pull out osgi isms to separate hook and add shutdown hook when jetty.xml is included so that it is shutdown on broker stop. Fix problems with the xml eposed by the tests git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1390204 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/broker/util/CommandAgent.java | 11 ++-- .../apache/activemq/karaf/commands/spring.xml | 2 +- .../activemq/hooks/SpringContextHook.java | 13 ----- .../activemq/hooks/SpringOsgiContextHook.java | 51 +++++++++++++++++++ assembly/pom.xml | 25 +++++++-- assembly/src/main/descriptors/common-bin.xml | 2 +- assembly/src/release/conf/activemq.xml | 5 ++ assembly/src/sample-conf/activemq-demo.xml | 7 ++- .../src/sample-conf/activemq-security.xml | 11 ++-- .../config/BrokerXmlConfigStartTest.java | 7 ++- 10 files changed, 102 insertions(+), 32 deletions(-) create mode 100644 activemq-spring/src/main/java/org/apache/activemq/hooks/SpringOsgiContextHook.java diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java index ff65a7c1f9..0da5990591 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java @@ -75,32 +75,27 @@ public class CommandAgent implements Service, ExceptionListener { */ @PreDestroy public void stop() throws Exception { - ServiceStopper stopper = new ServiceStopper(); if (consumer != null) { try { consumer.close(); consumer = null; - } catch (JMSException e) { - stopper.onException(this, e); + } catch (JMSException ignored) { } } if (session != null) { try { session.close(); session = null; - } catch (JMSException e) { - stopper.onException(this, e); + } catch (JMSException ignored) { } } if (connection != null) { try { connection.close(); connection = null; - } catch (JMSException e) { - stopper.onException(this, e); + } catch (JMSException ignored) { } } - stopper.throwFirstException(); } // Properties diff --git a/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml b/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml index 3de5938234..d5f4051053 100644 --- a/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml +++ b/activemq-karaf/src/main/resources/org/apache/activemq/karaf/commands/spring.xml @@ -101,7 +101,7 @@ --> - + diff --git a/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java b/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java index 5b1fef652b..e22a3d82fa 100644 --- a/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java +++ b/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringContextHook.java @@ -16,32 +16,19 @@ */ package org.apache.activemq.hooks; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -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 Logger LOG = LoggerFactory.getLogger(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 { diff --git a/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringOsgiContextHook.java b/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringOsgiContextHook.java new file mode 100644 index 0000000000..a544a68aa2 --- /dev/null +++ b/activemq-spring/src/main/java/org/apache/activemq/hooks/SpringOsgiContextHook.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.hooks; + +import org.osgi.framework.BundleException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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 SpringOsgiContextHook implements Runnable, ApplicationContextAware { + + private static final transient Logger LOG = LoggerFactory.getLogger(SpringOsgiContextHook.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; + } + +} diff --git a/assembly/pom.xml b/assembly/pom.xml index a4bcee4ef5..ed8399b07b 100755 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -125,10 +125,6 @@ org.apache.camel camel-spring - - org.apache.camel - camel-jetty - org.apache.camel camel-jms @@ -293,6 +289,12 @@ jasypt + + org.jasypt + jasypt-spring3 + ${jasypt-version} + + junit junit @@ -341,6 +343,18 @@ + + maven-compiler-plugin + + + validate-config + test-compile + + testCompile + + + + maven-surefire-plugin @@ -352,6 +366,9 @@ pertest + + activemq + diff --git a/assembly/src/main/descriptors/common-bin.xml b/assembly/src/main/descriptors/common-bin.xml index ab168b6c1b..fcfa95d062 100644 --- a/assembly/src/main/descriptors/common-bin.xml +++ b/assembly/src/main/descriptors/common-bin.xml @@ -127,7 +127,6 @@ org.apache.camel:camel-core org.apache.camel:camel-spring - org.apache.camel:camel-jetty org.apache.camel:camel-jms org.apache.activemq:activemq-camel @@ -171,6 +170,7 @@ org.apache.velocity:velocity org.apache.servicemix.bundles:org.apache.servicemix.bundles.josql org.jasypt:jasypt + org.jasypt:jasypt-spring3 javax.jmdns:jmdns diff --git a/assembly/src/release/conf/activemq.xml b/assembly/src/release/conf/activemq.xml index ea5bbb1aff..8a4c031f93 100755 --- a/assembly/src/release/conf/activemq.xml +++ b/assembly/src/release/conf/activemq.xml @@ -145,6 +145,11 @@ + + + + + - + + + + + + + + +