cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amic...@apache.org
Subject svn commit: r1499161 - in /cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe: InterfaceMonitor.java InterfaceMonitorManager.java
Date Wed, 03 Jul 2013 00:24:11 GMT
Author: amichai
Date: Wed Jul  3 00:24:10 2013
New Revision: 1499161

URL: http://svn.apache.org/r1499161
Log:
DOSGI-198 Fix imported service disappearing after client bundle is restarted

Modified:
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java?rev=1499161&r1=1499160&r2=1499161&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
Wed Jul  3 00:24:10 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.dosgi.discovery.zookeeper.subscribe;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -69,6 +70,15 @@ public class InterfaceMonitor implements
                 new Object[] {recursive ? "(recursive)" : "", scope, objClass});
     }
 
+    /**
+     * Returns all endpoints that are currently known to this monitor.
+     *
+     * @return all endpoints that are currently known to this monitor
+     */
+    public synchronized List<EndpointDescription> getEndpoints() {
+        return new ArrayList<EndpointDescription>(nodes.values());
+    }
+
     public void start() {
         watch();
     }
@@ -146,7 +156,7 @@ public class InterfaceMonitor implements
         LOG.info("Processing change on node: {}", znode);
 
         Map<String, EndpointDescription> newNodes = new HashMap<String, EndpointDescription>();
-        Map<String, EndpointDescription> prevNodes = nodes;
+        Map<String, EndpointDescription> prevNodes = new HashMap<String, EndpointDescription>(nodes);
         processChildren(znode, newNodes, prevNodes);
 
         // whatever is left in prevNodes now has been removed from Discovery

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java?rev=1499161&r1=1499160&r2=1499161&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
Wed Jul  3 00:24:10 2013
@@ -19,6 +19,7 @@
 package org.apache.cxf.dosgi.discovery.zookeeper.subscribe;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -81,9 +82,16 @@ public class InterfaceMonitorManager {
             interest.listeners.add(sref); // add it before monitor starts so we don't miss
events
             interest.im = createInterfaceMonitor(scope, objClass, interest);
             interest.im.start();
-        } else if (!interest.listeners.contains(sref)) {
+        } else {
             // interest already exists, so just add listener to it
-            interest.listeners.add(sref);
+            if (!interest.listeners.contains(sref)) {
+                interest.listeners.add(sref);
+            }
+            // notify listener of all known endpoints for given scope
+            // (as EndpointListener contract requires of all added/modified listeners)
+            for (EndpointDescription endpoint : interest.im.getEndpoints()) {
+                notifyListeners(endpoint, scope, true, Arrays.asList(sref));
+            }
         }
 
         // add scope to listener's scopes list



Mime
View raw message