activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/3] activemq-artemis git commit: ARTEMIS-793 Improvements to OSGi Integration
Date Wed, 19 Oct 2016 20:58:37 GMT
ARTEMIS-793 Improvements to OSGi Integration


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

Branch: refs/heads/master
Commit: 128a5058914e3da0ee42fb0a4e944fa8ceab2de7
Parents: 2020dcd
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Wed Oct 19 16:51:03 2016 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Oct 19 16:51:03 2016 -0400

----------------------------------------------------------------------
 .../activemq/artemis/osgi/OsgiBroker.java       | 39 +++++++++-----------
 .../activemq/artemis/osgi/ProtocolTracker.java  |  4 +-
 .../artemis/osgi/ProtocolTrackerCallBack.java   | 28 --------------
 .../artemis/osgi/ServerTrackerCallBack.java     | 11 +++++-
 .../artemis/osgi/ProtocolTrackerTest.java       |  2 +-
 5 files changed, 30 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/128a5058/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java
----------------------------------------------------------------------
diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java
b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java
index 58c2109..9fb5e11 100644
--- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java
+++ b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java
@@ -96,13 +96,15 @@ public class OsgiBroker {
       final ActiveMQServer server = (ActiveMQServer) components.get("core");
 
       String[] requiredProtocols = getRequiredProtocols(server.getConfiguration().getAcceptorConfigurations());
-      ProtocolTrackerCallBack callback = new ProtocolTrackerCallBackImpl(server, context,
properties);
+      ServerTrackerCallBack callback = new ServerTrackerCallBackImpl(server, context, properties);
 
       StoreConfiguration storeConfiguration = server.getConfiguration().getStoreConfiguration();
       String dataSourceName = String.class.cast(properties.get("dataSourceName"));
-      if (storeConfiguration.getStoreType() == StoreType.DATABASE && dataSourceName
!= null &&
+
+      if (storeConfiguration != null &&
+          storeConfiguration.getStoreType() == StoreType.DATABASE && dataSourceName
!= null &&
                !dataSourceName.isEmpty()) {
-         callback = new ServerTrackerCallBackImpl(server, context, properties);
+         callback.setDataSourceDependency(true);
          String filter = "(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name="
+ dataSourceName + "))";
          DataSourceTracker trackerCust =
                   new DataSourceTracker(name, context, DatabaseStorageConfiguration.class.cast(storeConfiguration),
@@ -207,13 +209,15 @@ public class OsgiBroker {
       }
    }
 
-   private class ProtocolTrackerCallBackImpl implements ProtocolTrackerCallBack {
+   private class ServerTrackerCallBackImpl implements ServerTrackerCallBack {
+
+      private volatile boolean dataSourceDependency = false;
 
       private final ActiveMQServer server;
       private final BundleContext context;
       private final Dictionary<String, Object> properties;
 
-      ProtocolTrackerCallBackImpl(ActiveMQServer server, BundleContext context,
+      ServerTrackerCallBackImpl(ActiveMQServer server, BundleContext context,
                                          Dictionary<String, Object> properties) {
          this.server = server;
          this.context = context;
@@ -242,37 +246,28 @@ public class OsgiBroker {
 
       @Override
       public void start() throws Exception {
-         List<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
-         for (ActiveMQComponent component : componentsByStartOrder) {
-            component.start();
+         if (!dataSourceDependency) {
+            List<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
+            for (ActiveMQComponent component : componentsByStartOrder) {
+               component.start();
+            }
+            register(context, properties);
          }
-         register(context, properties);
       }
 
       @Override
       public boolean isStarted() {
          return server.isStarted();
       }
-   }
-
-   private class ServerTrackerCallBackImpl extends ProtocolTrackerCallBackImpl implements
ServerTrackerCallBack {
 
-      private volatile boolean dataSourceDependency = true;
 
-      ServerTrackerCallBackImpl(ActiveMQServer server, BundleContext context, Dictionary<String,
Object> properties) {
-         super(server, context, properties);
-      }
 
       @Override
       public void setDataSourceDependency(boolean dataSourceDependency) {
          this.dataSourceDependency = dataSourceDependency;
       }
 
-      @Override
-      public void start() throws Exception {
-         if (!dataSourceDependency) {
-            super.start();
-         }
-      }
+
    }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/128a5058/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java
----------------------------------------------------------------------
diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java
b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java
index 545e897..e01f629 100644
--- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java
+++ b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java
@@ -43,12 +43,12 @@ public class ProtocolTracker implements ServiceTrackerCustomizer<ProtocolManager
    private String name;
    private BundleContext context;
    private Map<String, Boolean> protocols;
-   private ProtocolTrackerCallBack callback;
+   private ServerTrackerCallBack callback;
 
    public ProtocolTracker(String name,
                           BundleContext context,
                           String[] requiredProtocols,
-                          ProtocolTrackerCallBack callback) {
+                          ServerTrackerCallBack callback) {
       this.name = name;
       this.context = context;
       this.callback = callback;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/128a5058/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java
----------------------------------------------------------------------
diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java
b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java
deleted file mode 100644
index 44cc590..0000000
--- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.artemis.osgi;
-
-import org.apache.activemq.artemis.api.core.Interceptor;
-import org.apache.activemq.artemis.core.server.ActiveMQComponent;
-import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
-
-public interface ProtocolTrackerCallBack extends ActiveMQComponent {
-
-   void addFactory(ProtocolManagerFactory<Interceptor> pmf);
-
-   void removeFactory(ProtocolManagerFactory<Interceptor> pmf);
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/128a5058/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ServerTrackerCallBack.java
----------------------------------------------------------------------
diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ServerTrackerCallBack.java
b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ServerTrackerCallBack.java
index 1ef4c9e..5087a77 100644
--- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ServerTrackerCallBack.java
+++ b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ServerTrackerCallBack.java
@@ -16,7 +16,16 @@
  */
 package org.apache.activemq.artemis.osgi;
 
-public interface ServerTrackerCallBack extends ProtocolTrackerCallBack {
+import org.apache.activemq.artemis.api.core.Interceptor;
+import org.apache.activemq.artemis.core.server.ActiveMQComponent;
+import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
+
+public interface ServerTrackerCallBack extends ActiveMQComponent {
+
+   void addFactory(ProtocolManagerFactory<Interceptor> pmf);
+
+   void removeFactory(ProtocolManagerFactory<Interceptor> pmf);
 
    void setDataSourceDependency(boolean dataSourceDependency);
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/128a5058/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java
----------------------------------------------------------------------
diff --git a/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java
b/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java
index 744d45b..97ee3ad 100644
--- a/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java
+++ b/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java
@@ -34,7 +34,7 @@ public class ProtocolTrackerTest {
       IMocksControl c = EasyMock.createControl();
       BundleContext context = c.createMock(BundleContext.class);
       String[] requiredProtocols = {"a", "b"};
-      ProtocolTrackerCallBack callback = c.createMock(ProtocolTrackerCallBack.class);
+      ServerTrackerCallBack callback = c.createMock(ServerTrackerCallBack.class);
 
       RefFact protA = new RefFact(c, context, new String[]{"a"});
       RefFact protB = new RefFact(c, context, new String[]{"b"});


Mime
View raw message