BUG-8733: eliminate ProxyRegistration 46/61046/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 2 Aug 2017 14:53:09 +0000 (16:53 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 2 Aug 2017 15:20:16 +0000 (17:20 +0200)
This class does not serve any real purpose and just clutters the code.
Get rid of it.

Change-Id: I43b88bc8eb777199a43283c3b232a299436cd74d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java

index 95476475e78e975f87430b1f9619eccd82d33401..298328c9935add933e1b0c794bb986b6c28b6cc5 100644 (file)
@@ -45,7 +45,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFai
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DistributedShardChangePublisher
+final class DistributedShardChangePublisher
         extends AbstractRegistrationTree<AbstractDOMDataTreeChangeListenerRegistration<?>>
         implements DOMStoreTreeChangePublisher {
 
@@ -62,10 +62,8 @@ public class DistributedShardChangePublisher
     @GuardedBy("this")
     private final DataTree dataTree;
 
-    public DistributedShardChangePublisher(final DataStoreClient client,
-                                           final AbstractDataStore distributedDataStore,
-                                           final DOMDataTreeIdentifier prefix,
-                                           final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) {
+    DistributedShardChangePublisher(final DataStoreClient client, final AbstractDataStore distributedDataStore,
+            final DOMDataTreeIdentifier prefix, final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) {
         this.client = client;
         this.distributedDataStore = distributedDataStore;
         // TODO keeping the whole dataTree thats contained in subshards doesn't seem like a good idea
@@ -139,8 +137,8 @@ public class DistributedShardChangePublisher
                 findNodeFor(listenerPath.getPathArguments());
 
         // register listener in CDS
-        final ProxyRegistration proxyReg = new ProxyRegistration(distributedDataStore
-                .registerProxyListener(shardLookup, listenerPath, listener), listener);
+        final ListenerRegistration<?> dsReg = distributedDataStore.registerProxyListener(shardLookup, listenerPath,
+            listener);
 
         @SuppressWarnings("unchecked")
         final AbstractDOMDataTreeChangeListenerRegistration<L> registration =
@@ -150,7 +148,7 @@ public class DistributedShardChangePublisher
                     listener.close();
                     DistributedShardChangePublisher.this.removeRegistration(node, this);
                     registrationRemoved(this);
-                    proxyReg.close();
+                    dsReg.close();
                 }
             };
         addRegistration(node, registration);
@@ -179,30 +177,6 @@ public class DistributedShardChangePublisher
         return listenerPathArgs;
     }
 
-    private static class ProxyRegistration implements ListenerRegistration<DOMDataTreeChangeListener> {
-
-        private final ListenerRegistration<org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener> proxy;
-        private final DOMDataTreeChangeListener listener;
-
-        private ProxyRegistration(
-                final ListenerRegistration<
-                        org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener> proxy,
-                final DOMDataTreeChangeListener listener) {
-            this.proxy = proxy;
-            this.listener = listener;
-        }
-
-        @Override
-        public DOMDataTreeChangeListener getInstance() {
-            return listener;
-        }
-
-        @Override
-        public void close() {
-            proxy.close();
-        }
-    }
-
     synchronized DataTreeCandidate applyChanges(final YangInstanceIdentifier listenerPath,
             final Collection<DataTreeCandidate> changes) throws DataValidationFailedException {
         final DataTreeModification modification = dataTree.takeSnapshot().newModification();