cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amic...@apache.org
Subject svn commit: r1499698 - in /cxf/dosgi/trunk: discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/ discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/ disc...
Date Thu, 04 Jul 2013 09:14:29 GMT
Author: amichai
Date: Thu Jul  4 09:14:29 2013
New Revision: 1499698

URL: http://svn.apache.org/r1499698
Log:
Standardize EndpointListener variable naming

Modified:
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/EndpointListenerTrackerCustomizer.java
    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
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java
    cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java
    cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/exporter/EndpointListenerNotifier.java

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/EndpointListenerTrackerCustomizer.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/EndpointListenerTrackerCustomizer.java?rev=1499698&r1=1499697&r2=1499698&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/EndpointListenerTrackerCustomizer.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/EndpointListenerTrackerCustomizer.java
Thu Jul  4 09:14:29 2013
@@ -39,38 +39,38 @@ public class EndpointListenerTrackerCust
         this.imManager = imManager;
     }
 
-    public Object addingService(ServiceReference sref) {
-        updateListenerScopes(sref);
-        return sref;
+    public Object addingService(ServiceReference endpointListener) {
+        updateListenerScopes(endpointListener);
+        return endpointListener;
     }
 
-    public void modifiedService(ServiceReference sref, Object service) {
+    public void modifiedService(ServiceReference endpointListener, Object service) {
         // called when an EndpointListener updates its service properties,
         // e.g. when its interest scope is expanded/reduced
-        updateListenerScopes(sref);
+        updateListenerScopes(endpointListener);
     }
 
-    public void removedService(ServiceReference sref, Object service) {
-        LOG.info("removing EndpointListener interests: {}", sref);
-        imManager.removeInterest(sref);
+    public void removedService(ServiceReference endpointListener, Object service) {
+        LOG.info("removing EndpointListener interests: {}", endpointListener);
+        imManager.removeInterest(endpointListener);
     }
 
-    private void updateListenerScopes(ServiceReference sref) {
-        if (isOurOwnEndpointListener(sref)) {
+    private void updateListenerScopes(ServiceReference endpointListener) {
+        if (isOurOwnEndpointListener(endpointListener)) {
             LOG.debug("Skipping our own EndpointListener");
             return;
         }
 
-        LOG.info("updating EndpointListener interests: {}", sref);
+        LOG.info("updating EndpointListener interests: {}", endpointListener);
         if (LOG.isDebugEnabled()) {
-            LOG.debug("updated EndpointListener properties: {}", Utils.getProperties(sref));
+            LOG.debug("updated EndpointListener properties: {}", Utils.getProperties(endpointListener));
         }
 
-        imManager.addInterest(sref);
+        imManager.addInterest(endpointListener);
     }
 
-    private static boolean isOurOwnEndpointListener(ServiceReference sref) {
+    private static boolean isOurOwnEndpointListener(ServiceReference endpointListener) {
         return Boolean.parseBoolean(String.valueOf(
-                sref.getProperty(ZooKeeperDiscovery.DISCOVERY_ZOOKEEPER_ID)));
+                endpointListener.getProperty(ZooKeeperDiscovery.DISCOVERY_ZOOKEEPER_ID)));
     }
 }

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=1499698&r1=1499697&r2=1499698&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
Thu Jul  4 09:14:29 2013
@@ -54,18 +54,18 @@ public class InterfaceMonitor implements
 
     private final String znode;
     private final ZooKeeper zookeeper;
-    private final EndpointListener listener;
+    private final EndpointListener endpointListener;
     private final boolean recursive;
     private volatile boolean closed;
 
     // This map reference changes, so don't synchronize on it
     private Map<String, EndpointDescription> nodes = new HashMap<String, EndpointDescription>();
 
-    public InterfaceMonitor(ZooKeeper zk, String objClass, EndpointListener listener, String
scope) {
+    public InterfaceMonitor(ZooKeeper zk, String objClass, EndpointListener endpointListener,
String scope) {
         this.zookeeper = zk;
         this.znode = Utils.getZooKeeperPath(objClass);
         this.recursive = objClass == null || objClass.isEmpty();
-        this.listener = listener;
+        this.endpointListener = endpointListener;
         LOG.debug("Creating new InterfaceMonitor {} for scope [{}] and objectClass [{}]",
                 new Object[] {recursive ? "(recursive)" : "", scope, objClass});
     }
@@ -144,7 +144,7 @@ public class InterfaceMonitor implements
     public synchronized void close() {
         closed = true;
         for (EndpointDescription epd : nodes.values()) {
-            listener.endpointRemoved(epd, null);
+            endpointListener.endpointRemoved(epd, null);
         }
         nodes.clear();
     }
@@ -162,7 +162,7 @@ public class InterfaceMonitor implements
         // whatever is left in prevNodes now has been removed from Discovery
         LOG.debug("processChildren done. Nodes that are missing now and need to be removed:
{}", prevNodes.values());
         for (EndpointDescription epd : prevNodes.values()) {
-            listener.endpointRemoved(epd, null);
+            endpointListener.endpointRemoved(epd, null);
         }
         nodes = newNodes;
     }
@@ -196,7 +196,7 @@ public class InterfaceMonitor implements
                     LOG.debug("Properties: {}", epd.getProperties());
                     if (prevEpd == null) {
                         // This guy is new
-                        listener.endpointAdded(epd, null);
+                        endpointListener.endpointAdded(epd, null);
                     } else if (!prevEpd.getProperties().equals(epd.getProperties())) {
                         // TODO
                     }

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=1499698&r1=1499697&r2=1499698&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
Thu Jul  4 09:14:29 2013
@@ -50,13 +50,14 @@ public class InterfaceMonitorManager {
     private final BundleContext bctx;
     private final ZooKeeper zooKeeper;
     // map of EndpointListeners and the scopes they are interested in
-    private final Map<ServiceReference, List<String>> listenerScopes = new HashMap<ServiceReference,
List<String>>();
+    private final Map<ServiceReference, List<String>> endpointListenerScopes
=
+            new HashMap<ServiceReference, List<String>>();
     // map of scopes and their interest data
     private final Map<String, Interest> interests = new HashMap<String, Interest>();
 
     protected static class Interest {
-        List<ServiceReference> listeners = new CopyOnWriteArrayList<ServiceReference>();
-        InterfaceMonitor im;
+        List<ServiceReference> endpointListeners = new CopyOnWriteArrayList<ServiceReference>();
+        InterfaceMonitor monitor;
     }
 
     public InterfaceMonitorManager(BundleContext bctx, ZooKeeper zooKeeper) {
@@ -64,49 +65,49 @@ public class InterfaceMonitorManager {
         this.zooKeeper = zooKeeper;
     }
 
-    public void addInterest(ServiceReference sref) {
-        for (String scope : Utils.getScopes(sref)) {
+    public void addInterest(ServiceReference endpointListener) {
+        for (String scope : Utils.getScopes(endpointListener)) {
             String objClass = Utils.getObjectClass(scope);
             LOG.debug("Adding interest in scope {}, objectClass {}", scope, objClass);
-            addInterest(sref, scope, objClass);
+            addInterest(endpointListener, scope, objClass);
         }
     }
 
-    public synchronized void addInterest(ServiceReference sref, String scope, String objClass)
{
+    public synchronized void addInterest(ServiceReference endpointListener, String scope,
String objClass) {
         // get or create interest for given scope and add listener to it
         Interest interest = interests.get(scope);
         if (interest == null) {
             // create interest, add listener and start monitor
             interest = new Interest();
             interests.put(scope, interest);
-            interest.listeners.add(sref); // add it before monitor starts so we don't miss
events
-            interest.im = createInterfaceMonitor(scope, objClass, interest);
-            interest.im.start();
+            interest.endpointListeners.add(endpointListener); // add it before monitor starts
so we don't miss events
+            interest.monitor = createInterfaceMonitor(scope, objClass, interest);
+            interest.monitor.start();
         } else {
             // interest already exists, so just add listener to it
-            if (!interest.listeners.contains(sref)) {
-                interest.listeners.add(sref);
+            if (!interest.endpointListeners.contains(endpointListener)) {
+                interest.endpointListeners.add(endpointListener);
             }
             // 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));
+            for (EndpointDescription endpoint : interest.monitor.getEndpoints()) {
+                notifyListeners(endpoint, scope, true, Arrays.asList(endpointListener));
             }
         }
 
         // add scope to listener's scopes list
-        List<String> scopes = listenerScopes.get(sref);
+        List<String> scopes = endpointListenerScopes.get(endpointListener);
         if (scopes == null) {
             scopes = new ArrayList<String>(1);
-            listenerScopes.put(sref, scopes);
+            endpointListenerScopes.put(endpointListener, scopes);
         }
         if (!scopes.contains(scope)) {
             scopes.add(scope);
         }
     }
 
-    public synchronized void removeInterest(ServiceReference sref) {
-        List<String> scopes = listenerScopes.get(sref);
+    public synchronized void removeInterest(ServiceReference endpointListener) {
+        List<String> scopes = endpointListenerScopes.get(endpointListener);
         if (scopes == null) {
             return;
         }
@@ -114,73 +115,73 @@ public class InterfaceMonitorManager {
         for (String scope : scopes) {
             Interest interest = interests.get(scope);
             if (interest != null) {
-                interest.listeners.remove(sref);
-                if (interest.listeners.isEmpty()) {
-                    interest.im.close();
+                interest.endpointListeners.remove(endpointListener);
+                if (interest.endpointListeners.isEmpty()) {
+                    interest.monitor.close();
                     interests.remove(scope);
                 }
             }
         }
-        listenerScopes.remove(sref);
+        endpointListenerScopes.remove(endpointListener);
     }
 
     private InterfaceMonitor createInterfaceMonitor(final String scope, String objClass,
final Interest interest) {
         // holding this object's lock in the callbacks can lead to a deadlock with InterfaceMonitor
-        EndpointListener listener = new EndpointListener() {
+        EndpointListener endpointListener = new EndpointListener() {
 
             public void endpointRemoved(EndpointDescription endpoint, String matchedFilter)
{
-                notifyListeners(endpoint, scope, false, interest.listeners);
+                notifyListeners(endpoint, scope, false, interest.endpointListeners);
             }
 
             public void endpointAdded(EndpointDescription endpoint, String matchedFilter)
{
-                notifyListeners(endpoint, scope, true, interest.listeners);
+                notifyListeners(endpoint, scope, true, interest.endpointListeners);
             }
         };
-        return new InterfaceMonitor(zooKeeper, objClass, listener, scope);
+        return new InterfaceMonitor(zooKeeper, objClass, endpointListener, scope);
     }
 
     private void notifyListeners(EndpointDescription epd, String currentScope, boolean isAdded,
-            List<ServiceReference> listeners) {
-        for (ServiceReference sref : listeners) {
-            Object service = bctx.getService(sref);
+            List<ServiceReference> endpointListeners) {
+        for (ServiceReference endpointListenerRef : endpointListeners) {
+            Object service = bctx.getService(endpointListenerRef);
             try {
                 if (service instanceof EndpointListener) {
-                    EndpointListener epl = (EndpointListener) service;
+                    EndpointListener endpointListener = (EndpointListener) service;
                     LOG.trace("matching {} against {}", epd, currentScope);
                     if (matchFilter(bctx, currentScope, epd)) {
                         LOG.debug("Matched {} against {}", epd, currentScope);
-                        notifyListener(epd, currentScope, isAdded, sref.getBundle(), epl);
+                        notifyListener(epd, currentScope, isAdded, endpointListenerRef.getBundle(),
endpointListener);
                     }
                 }
             } finally {
                 if (service != null) {
-                    bctx.ungetService(sref);
+                    bctx.ungetService(endpointListenerRef);
                 }
             }
         }
     }
 
     private void notifyListener(EndpointDescription epd, String currentScope, boolean isAdded,
-                                Bundle eplBundle, EndpointListener epl) {
-        if (eplBundle == null) {
+                                Bundle endpointListenerBundle, EndpointListener endpointListener)
{
+        if (endpointListenerBundle == null) {
             LOG.info("listening service was unregistered, ignoring");
         } else if (isAdded) {
-            LOG.info("calling EndpointListener.endpointAdded: " + epl + " from bundle "
-                    + eplBundle.getSymbolicName() + " for endpoint: " + epd);
-            epl.endpointAdded(epd, currentScope);
+            LOG.info("calling EndpointListener.endpointAdded: " + endpointListener + " from
bundle "
+                    + endpointListenerBundle.getSymbolicName() + " for endpoint: " + epd);
+            endpointListener.endpointAdded(epd, currentScope);
         } else {
-            LOG.info("calling EndpointListener.endpointRemoved: " + epl + " from bundle "
-                    + eplBundle.getSymbolicName() + " for endpoint: " + epd);
-            epl.endpointRemoved(epd, currentScope);
+            LOG.info("calling EndpointListener.endpointRemoved: " + endpointListener + "
from bundle "
+                    + endpointListenerBundle.getSymbolicName() + " for endpoint: " + epd);
+            endpointListener.endpointRemoved(epd, currentScope);
         }
     }
 
     public synchronized void close() {
         for (Interest interest : interests.values()) {
-            interest.im.close();
+            interest.monitor.close();
         }
         interests.clear();
-        listenerScopes.clear();
+        endpointListenerScopes.clear();
     }
 
     /**
@@ -193,7 +194,7 @@ public class InterfaceMonitorManager {
     /**
      * Only for test case!
      */
-    protected synchronized Map<ServiceReference, List<String>> getListenerScopes()
{
-        return listenerScopes;
+    protected synchronized Map<ServiceReference, List<String>> getEndpointListenerScopes()
{
+        return endpointListenerScopes;
     }
 }

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java?rev=1499698&r1=1499697&r2=1499698&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
Thu Jul  4 09:14:29 2013
@@ -93,51 +93,51 @@ public class InterfaceMonitorManagerTest
 
         // sref has no scope -> nothing should happen
 
-        assertEquals(0, eltc.getListenerScopes().size());
+        assertEquals(0, eltc.getEndpointListenerScopes().size());
         assertEquals(0, eltc.getInterests().size());
 
         //p.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, );
 
         eltc.addInterest(sref, "(objectClass=mine)", "mine");
 
-        assertEquals(1, eltc.getListenerScopes().size());
-        assertEquals(1, eltc.getListenerScopes().get(sref).size());
-        assertEquals("(objectClass=mine)", eltc.getListenerScopes().get(sref).get(0));
+        assertEquals(1, eltc.getEndpointListenerScopes().size());
+        assertEquals(1, eltc.getEndpointListenerScopes().get(sref).size());
+        assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref).get(0));
         assertEquals(1, eltc.getInterests().size());
 
         eltc.addInterest(sref, "(objectClass=mine)", "mine");
 
-        assertEquals(1, eltc.getListenerScopes().size());
-        assertEquals(1, eltc.getListenerScopes().get(sref).size());
-        assertEquals("(objectClass=mine)", eltc.getListenerScopes().get(sref).get(0));
+        assertEquals(1, eltc.getEndpointListenerScopes().size());
+        assertEquals(1, eltc.getEndpointListenerScopes().get(sref).size());
+        assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref).get(0));
         assertEquals(1, eltc.getInterests().size());
 
         eltc.addInterest(sref2, "(objectClass=mine)", "mine");
 
-        assertEquals(2, eltc.getListenerScopes().size());
-        assertEquals(1, eltc.getListenerScopes().get(sref).size());
-        assertEquals(1, eltc.getListenerScopes().get(sref2).size());
-        assertEquals("(objectClass=mine)", eltc.getListenerScopes().get(sref).get(0));
-        assertEquals("(objectClass=mine)", eltc.getListenerScopes().get(sref2).get(0));
+        assertEquals(2, eltc.getEndpointListenerScopes().size());
+        assertEquals(1, eltc.getEndpointListenerScopes().get(sref).size());
+        assertEquals(1, eltc.getEndpointListenerScopes().get(sref2).size());
+        assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref).get(0));
+        assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref2).get(0));
         assertEquals(1, eltc.getInterests().size());
 
         eltc.removeInterest(sref);
 
-        assertEquals(1, eltc.getListenerScopes().size());
-        assertEquals(1, eltc.getListenerScopes().get(sref2).size());
-        assertEquals("(objectClass=mine)", eltc.getListenerScopes().get(sref2).get(0));
+        assertEquals(1, eltc.getEndpointListenerScopes().size());
+        assertEquals(1, eltc.getEndpointListenerScopes().get(sref2).size());
+        assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref2).get(0));
         assertEquals(1, eltc.getInterests().size());
 
         eltc.removeInterest(sref);
 
-        assertEquals(1, eltc.getListenerScopes().size());
-        assertEquals(1, eltc.getListenerScopes().get(sref2).size());
-        assertEquals("(objectClass=mine)", eltc.getListenerScopes().get(sref2).get(0));
+        assertEquals(1, eltc.getEndpointListenerScopes().size());
+        assertEquals(1, eltc.getEndpointListenerScopes().get(sref2).size());
+        assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref2).get(0));
         assertEquals(1, eltc.getInterests().size());
 
         eltc.removeInterest(sref2);
 
-        assertEquals(0, eltc.getListenerScopes().size());
+        assertEquals(0, eltc.getEndpointListenerScopes().size());
         assertEquals(0, eltc.getInterests().size());
 
         c.verify();

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java?rev=1499698&r1=1499697&r2=1499698&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java
Thu Jul  4 09:14:29 2013
@@ -48,8 +48,8 @@ public class InterfaceMonitorTest extend
         String interf = "es.schaaf.test";
         String node = Utils.getZooKeeperPath(interf);
 
-        EndpointListener epListener = c.createMock(EndpointListener.class);
-        InterfaceMonitor im = new InterfaceMonitor(zk, interf, epListener, scope);
+        EndpointListener endpointListener = c.createMock(EndpointListener.class);
+        InterfaceMonitor im = new InterfaceMonitor(zk, interf, endpointListener, scope);
         zk.exists(eq(node), eq(im), eq(im), EasyMock.anyObject());
         EasyMock.expectLastCall().once();
 

Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java?rev=1499698&r1=1499697&r2=1499698&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java
(original)
+++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java
Thu Jul  4 09:14:29 2013
@@ -102,36 +102,37 @@ public class LocalDiscovery implements B
 
     void registerTracker(ServiceReference reference, Object svc) {
         if (svc instanceof EndpointListener) {
-            EndpointListener listener = (EndpointListener) svc;
-            Collection<String> filters = addListener(reference, listener);
-            triggerCallbacks(filters, listener);
+            EndpointListener endpointListener = (EndpointListener) svc;
+            Collection<String> filters = addListener(reference, endpointListener);
+            triggerCallbacks(filters, endpointListener);
         }
     }
 
     void clearTracker(Object svc) {
         if (svc instanceof EndpointListener) {
-            EndpointListener listener = (EndpointListener) svc;
-            removeListener(listener);
+            EndpointListener endpointListener = (EndpointListener) svc;
+            removeListener(endpointListener);
             // If the tracker was removed or the scope was changed this doesn't require
             // additional callbacks on the tracker. Its the responsibility of the tracker
             // itself to clean up any orphans. See Remote Service Admin spec 122.6.3
         }
     }
 
-    private Collection<String> addListener(ServiceReference reference, EndpointListener
listener) {
-        List<String> filters = Utils.getStringPlusProperty(reference, EndpointListener.ENDPOINT_LISTENER_SCOPE);
+    private Collection<String> addListener(ServiceReference endpointListenerRef, EndpointListener
endpointListener) {
+        List<String> filters = Utils.getStringPlusProperty(endpointListenerRef,
+                EndpointListener.ENDPOINT_LISTENER_SCOPE);
         if (filters.isEmpty()) {
             return filters;
         }
 
-        listenerToFilters.put(listener, filters);
+        listenerToFilters.put(endpointListener, filters);
         for (String filter : filters) {
             Collection<EndpointListener> listeners = filterToListeners.get(filter);
             if (listeners != null) {
-                listeners.add(listener);
+                listeners.add(endpointListener);
             } else {
                 List<EndpointListener> list = new ArrayList<EndpointListener>();
-                list.add(listener);
+                list.add(endpointListener);
                 filterToListeners.put(filter, list);
             }
         }
@@ -139,16 +140,16 @@ public class LocalDiscovery implements B
         return filters;
     }
 
-    private void removeListener(EndpointListener listener) {
-        Collection<String> filters = listenerToFilters.remove(listener);
+    private void removeListener(EndpointListener endpointListener) {
+        Collection<String> filters = listenerToFilters.remove(endpointListener);
         if (filters == null) {
             return;
         }
 
         for (String filter : filters) {
-            Collection<EndpointListener> listeners = filterToListeners.get(filter);
-            if (listeners != null) {
-                listeners.remove(listener);
+            Collection<EndpointListener> endpointListeners = filterToListeners.get(filter);
+            if (endpointListeners != null) {
+                endpointListeners.remove(endpointListener);
             }
         }
     }
@@ -206,23 +207,23 @@ public class LocalDiscovery implements B
         }
     }
 
-    private void triggerCallbacks(EndpointListener listener, String toMatch,
+    private void triggerCallbacks(EndpointListener endpointListener, String toMatch,
             EndpointDescription ed, boolean added) {
         if (!Utils.matchFilter(bundleContext, toMatch, ed)) {
             return;
         }
 
         if (added) {
-            listener.endpointAdded(ed, toMatch);
+            endpointListener.endpointAdded(ed, toMatch);
         } else {
-            listener.endpointRemoved(ed, toMatch);
+            endpointListener.endpointRemoved(ed, toMatch);
         }
     }
 
-    private void triggerCallbacks(Collection<String> filters, EndpointListener listener)
{
+    private void triggerCallbacks(Collection<String> filters, EndpointListener endpointListener)
{
         for (String filter : filters) {
             for (EndpointDescription ed : endpointDescriptions.keySet()) {
-                triggerCallbacks(listener, filter, ed, true);
+                triggerCallbacks(endpointListener, filter, ed, true);
             }
         }
     }

Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java?rev=1499698&r1=1499697&r2=1499698&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
(original)
+++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
Thu Jul  4 09:14:29 2013
@@ -165,11 +165,11 @@ public class LocalDiscoveryTest extends 
         }).anyTimes();
         EasyMock.replay(sr);
 
-        EndpointListener el = EasyMock.createMock(EndpointListener.class);
-        el.endpointAdded((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
+        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
+        endpointListener.endpointAdded((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
         EasyMock.expectLastCall();
-        EasyMock.replay(el);
-        ld.registerTracker(sr, el);
+        EasyMock.replay(endpointListener);
+        ld.registerTracker(sr, endpointListener);
 
         // Start the bundle
         BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle);
@@ -179,19 +179,19 @@ public class LocalDiscoveryTest extends 
         assertEquals("http://somewhere:12345", ed.getId());
         assertSame(bundle, ld.endpointDescriptions.get(ed));
 
-        EasyMock.verify(el);
+        EasyMock.verify(endpointListener);
 
         // Stop the bundle
-        EasyMock.reset(el);
-        el.endpointRemoved((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
+        EasyMock.reset(endpointListener);
+        endpointListener.endpointRemoved((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
         EasyMock.expectLastCall();
-        EasyMock.replay(el);
+        EasyMock.replay(endpointListener);
 
         BundleEvent be1 = new BundleEvent(BundleEvent.STOPPED, bundle);
         ld.bundleChanged(be1);
         assertEquals(0, ld.endpointDescriptions.size());
 
-        EasyMock.verify(el);
+        EasyMock.verify(endpointListener);
     }
 
     public void testEndpointListenerService() throws Exception {
@@ -305,17 +305,17 @@ public class LocalDiscoveryTest extends 
         }).anyTimes();
         EasyMock.replay(sr);
 
-        EndpointListener el = EasyMock.createMock(EndpointListener.class);
-        EasyMock.replay(el);
+        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
+        EasyMock.replay(endpointListener);
 
         assertEquals("Precondition failed", 0, ld.listenerToFilters.size());
         assertEquals("Precondition failed", 0, ld.filterToListeners.size());
-        ld.registerTracker(sr, el);
+        ld.registerTracker(sr, endpointListener);
 
         assertEquals(1, ld.listenerToFilters.size());
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(el));
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
         assertEquals(1, ld.filterToListeners.size());
-        assertEquals(Collections.singletonList(el), ld.filterToListeners.get("(objectClass=Aaaa)"));
+        assertEquals(Collections.singletonList(endpointListener), ld.filterToListeners.get("(objectClass=Aaaa)"));
 
         // Add another one with the same scope filter
         ServiceReference sr2 = EasyMock.createMock(ServiceReference.class);
@@ -327,16 +327,17 @@ public class LocalDiscoveryTest extends 
         }).anyTimes();
         EasyMock.replay(sr2);
 
-        EndpointListener el2 = EasyMock.createMock(EndpointListener.class);
-        EasyMock.replay(el2);
-        ld.registerTracker(sr2, el2);
+        EndpointListener endpointListener2 = EasyMock.createMock(EndpointListener.class);
+        EasyMock.replay(endpointListener2);
+        ld.registerTracker(sr2, endpointListener2);
 
         assertEquals(2, ld.listenerToFilters.size());
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(el));
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(el2));
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2));
 
         assertEquals(1, ld.filterToListeners.size());
-        assertEquals(Arrays.asList(el, el2), ld.filterToListeners.get("(objectClass=Aaaa)"));
+        List<EndpointListener> endpointListeners12 = Arrays.asList(endpointListener,
endpointListener2);
+        assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)"));
 
         // Add another listener with a multi-value scope
         final Map<String, Object> props2 = new Hashtable<String, Object>();
@@ -350,28 +351,30 @@ public class LocalDiscoveryTest extends 
         }).anyTimes();
         EasyMock.replay(sr3);
 
-        EndpointListener el3 = EasyMock.createMock(EndpointListener.class);
-        EasyMock.replay(el3);
-        ld.registerTracker(sr3, el3);
+        EndpointListener endpointListener3 = EasyMock.createMock(EndpointListener.class);
+        EasyMock.replay(endpointListener3);
+        ld.registerTracker(sr3, endpointListener3);
 
         assertEquals(3, ld.listenerToFilters.size());
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(el));
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(el2));
-        assertEquals(Arrays.asList("(objectClass=X)", "(objectClass=Y)"), ld.listenerToFilters.get(el3));
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2));
+        assertEquals(Arrays.asList("(objectClass=X)", "(objectClass=Y)"), ld.listenerToFilters.get(endpointListener3));
 
         assertEquals(3, ld.filterToListeners.size());
-        assertEquals(Arrays.asList(el, el2), ld.filterToListeners.get("(objectClass=Aaaa)"));
-        assertEquals(Collections.singletonList(el3), ld.filterToListeners.get("(objectClass=X)"));
-        assertEquals(Collections.singletonList(el3), ld.filterToListeners.get("(objectClass=Y)"));
+        assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)"));
+        assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=X)"));
+        assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=Y)"));
     }
 
     public void testClearTracker() throws Exception {
         LocalDiscovery ld = getLocalDiscovery();
 
-        EndpointListener el = EasyMock.createMock(EndpointListener.class);
-        ld.listenerToFilters.put(el, new ArrayList<String>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)")));
-        ld.filterToListeners.put("(a=b)", new ArrayList<EndpointListener>(Arrays.asList(el)));
-        ld.filterToListeners.put("(objectClass=foo.bar.Bheuaark)", new ArrayList<EndpointListener>(Arrays.asList(el)));
+        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
+        ld.listenerToFilters.put(endpointListener,
+                new ArrayList<String>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)")));
+        ld.filterToListeners.put("(a=b)", new ArrayList<EndpointListener>(Arrays.asList(endpointListener)));
+        ld.filterToListeners.put("(objectClass=foo.bar.Bheuaark)",
+                new ArrayList<EndpointListener>(Arrays.asList(endpointListener)));
 
         ld.clearTracker("foobar"); // should not barf
 
@@ -382,7 +385,7 @@ public class LocalDiscoveryTest extends 
         assertEquals(1, ld.listenerToFilters.size());
         assertEquals(2, ld.filterToListeners.size());
         assertEquals(1, ld.filterToListeners.values().iterator().next().size());
-        ld.clearTracker(el);
+        ld.clearTracker(endpointListener);
         assertEquals(0, ld.listenerToFilters.size());
         assertEquals(2, ld.filterToListeners.size());
         assertEquals(0, ld.filterToListeners.values().iterator().next().size());

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/exporter/EndpointListenerNotifier.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/exporter/EndpointListenerNotifier.java?rev=1499698&r1=1499697&r2=1499698&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/exporter/EndpointListenerNotifier.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/exporter/EndpointListenerNotifier.java
Thu Jul  4 09:14:29 2013
@@ -102,28 +102,28 @@ public class EndpointListenerNotifier {
      * Notifies an endpoint listener about endpoints being added or removed.
      *
      * @param added specifies whether endpoints were added (true) or removed (false)
-     * @param eplReference the ServiceReference of an EndpointListener to notify
+     * @param endpointListenerRef the ServiceReference of an EndpointListener to notify
      * @param endpoints the endpoints the listener should be notified about
      */
-    void notifyListener(boolean added, ServiceReference eplReference,
+    void notifyListener(boolean added, ServiceReference endpointListenerRef,
                                 Collection<EndpointDescription> endpoints) {
-        List<Filter> filters = getFiltersFromEndpointListenerScope(eplReference, bctx);
-        EndpointListener epl = (EndpointListener)bctx.getService(eplReference);
+        List<Filter> filters = getFiltersFromEndpointListenerScope(endpointListenerRef,
bctx);
+        EndpointListener endpointListener = (EndpointListener)bctx.getService(endpointListenerRef);
         try {
             LOG.debug("notifyListener (added={})", added);
             for (EndpointDescription endpoint : endpoints) {
                 List<Filter> matchingFilters = getMatchingFilters(filters, endpoint);
                 for (Filter filter : matchingFilters) {
                     if (added) {
-                        epl.endpointAdded(endpoint, filter.toString());
+                        endpointListener.endpointAdded(endpoint, filter.toString());
                     } else {
-                        epl.endpointRemoved(endpoint, filter.toString());
+                        endpointListener.endpointRemoved(endpoint, filter.toString());
                     }
                 }
             }
         } finally {
-            if (epl != null) {
-                bctx.ungetService(eplReference);
+            if (endpointListener != null) {
+                bctx.ungetService(endpointListenerRef);
             }
         }
     }



Mime
View raw message