Make DOMSchemaService operate of EffectiveModelContext
[mdsal.git] / dom / mdsal-dom-broker / src / main / java / org / opendaylight / mdsal / dom / broker / DOMRpcRouter.java
index 02d8d00f956198befc5d9ec133e4fe7b2ba8d5a7..2128bd7fa986ec4248d5fce2dd4b2c80ecbab18d 100644 (file)
@@ -24,6 +24,7 @@ import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -68,13 +69,13 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class DOMRpcRouter extends AbstractRegistration implements SchemaContextListener {
+public final class DOMRpcRouter extends AbstractRegistration implements EffectiveModelContextListener {
     private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat(
             "DOMRpcRouter-listener-%s").setDaemon(true).build();
 
@@ -118,6 +119,8 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
         return rpcProviderService;
     }
 
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private synchronized void removeRpcImplementation(final DOMRpcImplementation implementation,
             final Set<DOMRpcIdentifier> rpcs) {
         final DOMRpcRoutingTable oldTable = routingTable;
@@ -127,6 +130,8 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
         listenerNotifier.execute(() -> notifyRemoved(newTable, implementation));
     }
 
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private synchronized void removeActionImplementation(final DOMActionImplementation implementation,
             final Set<DOMActionInstance> actions) {
         final DOMActionRoutingTable oldTable = actionRoutingTable;
@@ -136,14 +141,20 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
         listenerNotifier.execute(() -> notifyActionChanged(newTable, implementation));
     }
 
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private synchronized void removeListener(final ListenerRegistration<? extends DOMRpcAvailabilityListener> reg) {
         listeners = ImmutableList.copyOf(Collections2.filter(listeners, input -> !reg.equals(input)));
     }
 
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private synchronized void removeActionListener(final ListenerRegistration<? extends AvailabilityListener> reg) {
         actionListeners = ImmutableList.copyOf(Collections2.filter(actionListeners, input -> !reg.equals(input)));
     }
 
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private synchronized void notifyAdded(final DOMRpcRoutingTable newTable, final DOMRpcImplementation impl) {
         for (Registration<?> l : listeners) {
             l.addRpc(newTable, impl);
@@ -164,13 +175,14 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
     }
 
     @Override
-    public synchronized void onGlobalContextUpdated(final SchemaContext context) {
+    public synchronized void onModelContextUpdated(final EffectiveModelContext newModelContext) {
         final DOMRpcRoutingTable oldTable = routingTable;
-        final DOMRpcRoutingTable newTable = (DOMRpcRoutingTable) oldTable.setSchemaContext(context);
+        final DOMRpcRoutingTable newTable = (DOMRpcRoutingTable) oldTable.setSchemaContext(newModelContext);
         routingTable = newTable;
 
         final DOMActionRoutingTable oldActionTable = actionRoutingTable;
-        final DOMActionRoutingTable newActionTable = (DOMActionRoutingTable) oldActionTable.setSchemaContext(context);
+        final DOMActionRoutingTable newActionTable =
+                (DOMActionRoutingTable) oldActionTable.setSchemaContext(newModelContext);
         actionRoutingTable = newActionTable;
     }
 
@@ -402,7 +414,7 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
                 listenerNotifier.execute(() -> notifyActionChanged(newTable, implementation));
             }
 
-            return new AbstractObjectRegistration<T>(implementation) {
+            return new AbstractObjectRegistration<>(implementation) {
                 @Override
                 protected void removeRegistration() {
                     removeActionImplementation(getInstance(), instances);
@@ -458,7 +470,7 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
                 listenerNotifier.execute(() -> notifyAdded(newTable, implementation));
             }
 
-            return new AbstractDOMRpcImplementationRegistration<T>(implementation) {
+            return new AbstractDOMRpcImplementationRegistration<>(implementation) {
                 @Override
                 protected void removeRegistration() {
                     removeRpcImplementation(getInstance(), rpcs);
@@ -515,7 +527,7 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
                     // Find a DOMRpcImplementation for a wild card. Usually remote-rpc-connector would register an
                     // implementation this way
                     final List<DOMRpcImplementation> mayBeRemoteImpls =
-                        entry.getImplementations(YangInstanceIdentifier.EMPTY);
+                        entry.getImplementations(YangInstanceIdentifier.empty());
 
                     if (mayBeRemoteImpls != null) {
                         return mayBeRemoteImpls.get(0)
@@ -539,7 +551,7 @@ public final class DOMRpcRouter extends AbstractRegistration implements SchemaCo
 
         private static ListenableFuture<DOMRpcResult> invokeGlobalRpc(final GlobalDOMRpcRoutingTableEntry entry,
                 final NormalizedNode<?, ?> input) {
-            return entry.getImplementations(YangInstanceIdentifier.EMPTY).get(0).invokeRpc(entry.getRpcId(), input);
+            return entry.getImplementations(YangInstanceIdentifier.empty()).get(0).invokeRpc(entry.getRpcId(), input);
         }
     }
 }