You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cs...@apache.org on 2016/07/12 16:38:50 UTC

[1/3] activemq git commit: AMQ-6301: Changed activemq-osgi so that it embeds the spring-dm bundles so that we can avoid loading the spring-dm feature which causes Spring version conflicts.

Repository: activemq
Updated Branches:
  refs/heads/master c9c05eb86 -> 6c2ce67ff


AMQ-6301: Changed activemq-osgi so that it embeds the spring-dm bundles
so that we can avoid loading the spring-dm feature which causes Spring
version conflicts.


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/927bef73
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/927bef73
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/927bef73

Branch: refs/heads/master
Commit: 927bef7345dfff779209d3c3291d0df51f41583d
Parents: c9c05eb
Author: Seth Leger <se...@opennms.org>
Authored: Sun May 22 17:49:44 2016 -0400
Committer: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Committed: Tue Jul 12 12:17:14 2016 -0400

----------------------------------------------------------------------
 .../activemq/karaf/itest/ObrFeatureTest.java    | 55 ++++++++++++++++++++
 .../src/main/resources/features-core.xml        |  1 -
 activemq-osgi/pom.xml                           |  8 +--
 3 files changed, 59 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/927bef73/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ObrFeatureTest.java
----------------------------------------------------------------------
diff --git a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ObrFeatureTest.java b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ObrFeatureTest.java
index c59b2df..ea9a57d 100644
--- a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ObrFeatureTest.java
+++ b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ObrFeatureTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.karaf.itest;
 
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
@@ -25,6 +26,8 @@ import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.MavenUtils;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
 
 
 @RunWith(PaxExam.class)
@@ -67,4 +70,56 @@ public class ObrFeatureTest extends AbstractFeatureTest {
         executeCommand("feature:repo-add " + getCamelFeatureUrl());
         installAndAssertFeature("activemq-camel");
     }
+
+    @Test(timeout=5 * 60 * 1000)
+    public void testClientWithSpring31() throws Throwable {
+        executeCommand("feature:install spring/3.1.4.RELEASE");
+        installAndAssertFeature("activemq-client");
+        verifyBundleInstalledAndRegisteredServices("activemq-osgi", 2);
+    }
+
+    @Test(timeout=5 * 60 * 1000)
+    public void testClientWithSpring32() throws Throwable {
+        executeCommand("feature:install spring/3.2.14.RELEASE_1");
+        installAndAssertFeature("activemq-client");
+        verifyBundleInstalledAndRegisteredServices("activemq-osgi", 2);
+    }
+
+    @Test(timeout=5 * 60 * 1000)
+    public void testClientWithSpring40() throws Throwable {
+        executeCommand("feature:install spring/4.0.7.RELEASE_3");
+        installAndAssertFeature("activemq-client");
+        verifyBundleInstalledAndRegisteredServices("activemq-osgi", 2);
+    }
+
+    @Test(timeout=5 * 60 * 1000)
+    public void testClientWithSpring41() throws Throwable {
+        executeCommand("feature:install spring/4.1.7.RELEASE_2");
+        installAndAssertFeature("activemq-client");
+        verifyBundleInstalledAndRegisteredServices("activemq-osgi", 2);
+    }
+
+    @Test(timeout=5 * 60 * 1000)
+    public void testClientWithSpring42() throws Throwable {
+        executeCommand("feature:install spring/4.2.2.RELEASE_1");
+        installAndAssertFeature("activemq-client");
+        verifyBundleInstalledAndRegisteredServices("activemq-osgi", 2);
+    }
+
+    public boolean verifyBundleInstalledAndRegisteredServices(final String bundleName, final int numberOfServices) throws Exception {
+        boolean found = false;
+        for (final Bundle bundle : bundleContext.getBundles()) {
+            LOG.debug("Checking: " + bundle.getSymbolicName());
+            if (bundle.getSymbolicName().contains(bundleName)) {
+                Assert.assertEquals(Bundle.ACTIVE, bundle.getState());
+                // Assert that the bundle has registered some services via blueprint
+                Assert.assertNotNull(bundle.getRegisteredServices());
+                // Assert that the bundle has registered the correct number of services
+                Assert.assertEquals(numberOfServices, bundle.getRegisteredServices().length);
+                found = true;
+                break;
+            }
+        }
+        return found;
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/927bef73/activemq-karaf/src/main/resources/features-core.xml
----------------------------------------------------------------------
diff --git a/activemq-karaf/src/main/resources/features-core.xml b/activemq-karaf/src/main/resources/features-core.xml
index c578e15..04ddab7 100644
--- a/activemq-karaf/src/main/resources/features-core.xml
+++ b/activemq-karaf/src/main/resources/features-core.xml
@@ -23,7 +23,6 @@
     <!-- Bundles needed if only client will be deployed in the container -->
     <feature name="activemq-client" description="ActiveMQ client libraries" version="${project.version}" resolver="(obr)" start-level="50">
         <feature version="[3.2,4)">spring</feature>
-        <feature>spring-dm</feature>
         <bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/1.1.1</bundle>
         <bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
         <bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/1.1.1</bundle>

http://git-wip-us.apache.org/repos/asf/activemq/blob/927bef73/activemq-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/activemq-osgi/pom.xml b/activemq-osgi/pom.xml
index 89e9ba6..2802d1b 100644
--- a/activemq-osgi/pom.xml
+++ b/activemq-osgi/pom.xml
@@ -57,7 +57,6 @@
       org.fusesource.leveldbjni*;resolution:=optional,
       org.fusesource.hawtjni*;resolution:=optional,
       org.springframework.jms*;version="[3,5)";resolution:=optional,
-      org.springframework.osgi*;version="[1,4]";resolution:=optional,
       org.springframework.transaction*;version="[3,5)";resolution:=optional,
       org.springframework*;version="[3,5)";resolution:=optional,
       org.xmlpull*;resolution:=optional,
@@ -86,6 +85,7 @@
       org.apache.activemq.web*;version=${project.version};-noimport:=true;-split-package:=merge-first,
     </activemq.osgi.export>
     <activemq.osgi.private.pkg>
+         org.springframework.osgi*,
          org.fusesource.hawtdispatch*,
          org.fusesource.mqtt*,
          org.fusesource.hawtbuf*,
@@ -303,9 +303,9 @@
           <instructions>
             <Bundle-Activator>org.apache.activemq.util.osgi.Activator</Bundle-Activator>
             <Embed-Dependency>
-              *;
-              groupId=org.apache.activemq;inline=META-INF/services/*,
-              groupId=org.apache.qpid;inline=META-INF/services/*
+              *;groupId=org.apache.activemq;inline=META-INF/services/*,
+              *;groupId=org.apache.qpid;inline=META-INF/services/*,
+              *;groupId=org.springframework.osgi;inline=true
               <!--
               groupId=org.fusesource.leveldbjni;inline=META-INF/native/*,
               groupId=org.xerial.snappy;inline=org/xerial/snappy/*


[2/3] activemq git commit: https://issues.apache.org/jira/browse/AMQ-6301

Posted by cs...@apache.org.
https://issues.apache.org/jira/browse/AMQ-6301

This closes #187


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/a2205f69
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/a2205f69
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/a2205f69

Branch: refs/heads/master
Commit: a2205f69193ccde4441f5bad3826fc77921e4177
Parents: c9c05eb 927bef7
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Authored: Tue Jul 12 12:26:45 2016 -0400
Committer: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Committed: Tue Jul 12 12:26:45 2016 -0400

----------------------------------------------------------------------
 .../activemq/karaf/itest/ObrFeatureTest.java    | 55 ++++++++++++++++++++
 .../src/main/resources/features-core.xml        |  1 -
 activemq-osgi/pom.xml                           |  8 +--
 3 files changed, 59 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[3/3] activemq git commit: https://issues.apache.org/jira/browse/AMQ-6301

Posted by cs...@apache.org.
https://issues.apache.org/jira/browse/AMQ-6301

Updating ActiveMQServiceFactory to avoid using Spring DM directly and
instead use the Camel factory bean if it exists

Reverting back to Camel 2.16.3 until Spring DM is removed and Spring 4
can be used


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/6c2ce67f
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/6c2ce67f
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/6c2ce67f

Branch: refs/heads/master
Commit: 6c2ce67ffbde081f1db75002c8b41c3c7b7bb166
Parents: a2205f6
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Authored: Fri Jul 1 16:21:19 2016 +0000
Committer: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Committed: Tue Jul 12 12:27:30 2016 -0400

----------------------------------------------------------------------
 .../itest/ActiveMQBrokerNdCamelFeatureTest.java |  3 +-
 activemq-osgi/pom.xml                           |  2 +
 .../activemq/osgi/ActiveMQServiceFactory.java   | 53 ++++++++++++++++----
 pom.xml                                         |  2 +-
 4 files changed, 47 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/6c2ce67f/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java
----------------------------------------------------------------------
diff --git a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java
index dc2c1cc..ce32dfc 100644
--- a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java
+++ b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdCamelFeatureTest.java
@@ -35,8 +35,7 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfi
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
 
-//@RunWith(PaxExam.class)
-@Ignore
+@RunWith(PaxExam.class)
 public class ActiveMQBrokerNdCamelFeatureTest extends AbstractJmsFeatureTest {
 
     @Configuration

http://git-wip-us.apache.org/repos/asf/activemq/blob/6c2ce67f/activemq-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/activemq-osgi/pom.xml b/activemq-osgi/pom.xml
index 2802d1b..abf4bb0 100644
--- a/activemq-osgi/pom.xml
+++ b/activemq-osgi/pom.xml
@@ -64,6 +64,8 @@
       org.apache.xbean.spring*;resolution:=optional;version="[3.13,5)",
       org.apache.xbean*;version="[3.13,5)",
       javax.annotation*,
+      !com.thoughtworks.qdox*,
+      org.apache.commons.logging;version="[1.2,2)";resolution:=optional,
       javax.jms*;version="[1.1,3)",
       javax.management*,
       javax.transaction*,

http://git-wip-us.apache.org/repos/asf/activemq/blob/6c2ce67f/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
----------------------------------------------------------------------
diff --git a/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java b/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
index 5e49dfa..7c8d177 100644
--- a/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
+++ b/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
@@ -26,15 +26,19 @@ import java.util.Properties;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.spring.SpringBrokerContext;
 import org.apache.activemq.spring.Utils;
+import org.apache.camel.osgi.CamelContextFactoryBean;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.core.io.Resource;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
 
 public class ActiveMQServiceFactory implements ManagedServiceFactory {
 
@@ -74,14 +78,34 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory {
             Thread.currentThread().setContextClassLoader(BrokerService.class.getClassLoader());
             Resource resource = Utils.resourceFromString(config);
 
-            // when camel is embedded it needs a bundle context
-            OsgiBundleXmlApplicationContext ctx = new OsgiBundleXmlApplicationContext(new String[]{resource.getURL().toExternalForm()}) {
-                @Override
-                protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
-                    reader.setValidating(false);
-                }
-            };
-            ctx.setBundleContext(bundleContext);
+            ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
+                    new String[]{resource.getURL().toExternalForm()}, false);
+
+            if (isCamelContextFactoryBeanExist()) {
+
+                ctx.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
+
+                    @Override
+                    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+
+                        beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
+
+                            @Override
+                            public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+                                if (bean instanceof CamelContextFactoryBean) {
+                                    ((CamelContextFactoryBean) bean).setBundleContext(bundleContext);
+                                }
+                                return bean;
+                            }
+
+                            @Override
+                            public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+                                return bean;
+                            }
+                        });
+                    }
+                });
+            }
 
             // Handle properties in configuration
             PropertyPlaceholderConfigurer configurator = new PropertyPlaceholderConfigurer();
@@ -121,6 +145,15 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory {
         }
     }
 
+    private boolean isCamelContextFactoryBeanExist() {
+        try {
+            Class.forName("org.apache.camel.osgi.CamelContextFactoryBean");
+            return true;
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
+    }
+
     @Override
     synchronized public void deleted(String pid) {
         BrokerService broker = brokers.get(pid);

http://git-wip-us.apache.org/repos/asf/activemq/blob/6c2ce67f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0dae6c0..04f5991 100755
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,7 @@
     <aries-version>1.1.0</aries-version>
     <aries-transaction-version>1.1.1</aries-transaction-version>
     <axion-version>1.0-M3-dev</axion-version>
-    <camel-version>2.17.2</camel-version>
+    <camel-version>2.16.3</camel-version>
     <camel-version-range>[2.16,3)</camel-version-range>
     <cglib-version>2.2</cglib-version>
     <commons-beanutils-version>1.9.2</commons-beanutils-version>