tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1489 just deactivating our forced schedulersupport = false
Date Thu, 08 Jan 2015 13:29:52 GMT
Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x 50c306e14 -> 1d1d7d00a


TOMEE-1489 just deactivating our forced schedulersupport = false


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

Branch: refs/heads/tomee-1.7.x
Commit: 1d1d7d00afaf88678256b407327e92d7715c75e4
Parents: 50c306e
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Thu Jan 8 14:29:44 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Thu Jan 8 14:29:44 2015 +0100

----------------------------------------------------------------------
 .../resource/activemq/ActiveMQ5Factory.java     | 28 ++--------------
 .../activemq/ActiveMQResourceAdapterTest.java   | 34 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/1d1d7d00/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
b/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
index bf52201..eb34606 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
@@ -70,18 +70,12 @@ public class ActiveMQ5Factory implements BrokerFactoryHandler {
         if (null == broker || !broker.isStarted()) {
 
             final Properties properties = getLowerCaseProperties();
-            boolean scheduleSupport = false;
 
             final URISupport.CompositeData compositeData = URISupport.parseComposite(new
URI(brokerURI.getRawSchemeSpecificPart()));
             final Map<String, String> params = new HashMap<String, String>(compositeData.getParameters());
             final PersistenceAdapter persistenceAdapter;
             if ("true".equals(params.remove("usekahadb"))) {
                 persistenceAdapter = createPersistenceAdapter("org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter",
"kahadb", params);
-
-                if ("true".equals(params.remove("scheduler"))) {
-                    scheduleSupport = true;
-                }
-
             } else if ("true".equals(params.remove("useleveldb"))) {
                 persistenceAdapter = createPersistenceAdapter("org.apache.activemq.store.leveldb.LevelDBPersistenceAdapter",
"leveldb", params);
             } else if (params.get("persistenceadapter") != null) {
@@ -100,7 +94,7 @@ public class ActiveMQ5Factory implements BrokerFactoryHandler {
                 // if user didn't set persistent to true then setPersistenceAdapter() alone
is ignored so forcing it with the factory
                 broker.setPersistenceFactory(new ProvidedPersistenceAdapterPersistenceAdapterFactory(persistenceAdapter));
                 broker.setPersistent(true);
-                tomeeConfig(broker, scheduleSupport);
+                tomeeConfig(broker);
             } else {
                 final boolean notXbean = !uri.getScheme().toLowerCase().startsWith("xbean");
                 if (notXbean) {
@@ -155,7 +149,7 @@ public class ActiveMQ5Factory implements BrokerFactoryHandler {
                         broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
                     }
 
-                    tomeeConfig(broker, scheduleSupport);
+                    tomeeConfig(broker);
                 }
             }
 
@@ -290,27 +284,11 @@ public class ActiveMQ5Factory implements BrokerFactoryHandler {
         return persistenceAdapter;
     }
 
-    private void tomeeConfig(final BrokerService broker, final boolean scheduleSupport) {
-        //New since 5.4.x
-        setSchedulerSupport(broker, scheduleSupport);
-
+    private void tomeeConfig(final BrokerService broker) {
         //Notify when an error occurs on shutdown.
         broker.setUseLoggingForShutdownErrors(Logger.getInstance(LogCategory.OPENEJB_STARTUP,
ActiveMQ5Factory.class).isErrorEnabled());
     }
 
-    private static void setSchedulerSupport(final BrokerService broker, final boolean scheduleSupport)
{
-        try {
-            final Class<?> clazz = Class.forName("org.apache.activemq.broker.BrokerService");
-            final Method method = clazz.getMethod("setSchedulerSupport", new Class[]{Boolean.class});
-            method.invoke(broker, scheduleSupport);
-        } catch (final Throwable e) {
-            if (scheduleSupport) {
-                final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class);
-                logger.error("Failed to activate scheduler support", e);
-            }
-        }
-    }
-
     private Properties getLowerCaseProperties() {
         final Properties newProperties = new Properties();
         if (properties != null) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/1d1d7d00/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
index dfad874..7764b80 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
@@ -18,12 +18,29 @@
 package org.apache.openejb.resource.activemq;
 
 import junit.framework.TestCase;
+import org.apache.activemq.broker.BrokerService;
 import org.apache.openejb.util.Duration;
 import org.apache.openejb.util.NetworkUtil;
+import org.apache.openejb.util.reflection.Reflections;
 
 import java.util.concurrent.TimeUnit;
 
 public class ActiveMQResourceAdapterTest extends TestCase {
+    @Override
+    protected void tearDown() throws Exception {
+        cleanup();
+    }
+    @Override
+    protected void setUp() throws Exception {
+        cleanup();
+    }
+
+    private void cleanup() throws Exception {
+        for (final BrokerService bs : ActiveMQFactory.getBrokers()) {
+            bs.stop();
+        }
+    }
+
     public void test() throws Exception {
         final ActiveMQResourceAdapter resourceAdapter = new ActiveMQResourceAdapter();
         resourceAdapter.setServerUrl("vm://localhost?waitForStart=30000&async=false");
@@ -36,4 +53,21 @@ public class ActiveMQResourceAdapterTest extends TestCase {
         //
         resourceAdapter.start(null);
     }
+
+    public void testSchedulerSupport() throws Exception {
+        final ActiveMQResourceAdapter resourceAdapter = new ActiveMQResourceAdapter();
+        resourceAdapter.setServerUrl("vm://localhost?waitForStart=30000&async=false");
+        resourceAdapter.setStartupTimeout(new Duration(10, TimeUnit.SECONDS));
+
+        final String brokerAddress = NetworkUtil.getLocalAddress("broker:(tcp://", ")?useJmx=false&schedulerSupport=true");
+        resourceAdapter.setBrokerXmlConfig(brokerAddress);
+        resourceAdapter.start(null);
+        assertTrue(Boolean.class.cast(Reflections.get(ActiveMQFactory.getBrokers().iterator().next(),
"schedulerSupport")));
+        resourceAdapter.stop();
+
+        resourceAdapter.setBrokerXmlConfig(NetworkUtil.getLocalAddress("broker:(tcp://",
")?useJmx=false&schedulerSupport=false"));
+        resourceAdapter.start(null);
+        assertFalse(Boolean.class.cast(Reflections.get(ActiveMQFactory.getBrokers().iterator().next(),
"schedulerSupport")));
+        resourceAdapter.stop();
+    }
 }


Mime
View raw message