Add DOMExtensibleService.getExtensions() implementations 37/73937/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jul 2018 13:22:08 +0000 (15:22 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jul 2018 13:24:54 +0000 (15:24 +0200)
This adds implementations so we can switchover the base interface
and require getExtensions() to be implemented. Also take advantage
of the improvement introduced in getExtensions() return type.

Change-Id: I67f05782d311b895088e248119e77832a8892724
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/MockSchemaService.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/compat/LegacyDOMDataBrokerAdapter.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java

index cd89c4e..6662e2d 100644 (file)
@@ -7,7 +7,11 @@
  */
 package org.opendaylight.controller.sal.binding.test.util;
 
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import java.util.Map;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.util.ListenerRegistry;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -41,6 +45,17 @@ public final class MockSchemaService implements DOMSchemaService, SchemaContextP
         return schemaContext;
     }
 
+    @Override
+    @Deprecated
+    public Map<Class<? extends DOMSchemaServiceExtension>, DOMSchemaServiceExtension> getSupportedExtensions() {
+        return ImmutableClassToInstanceMap.of();
+    }
+
+    @Override
+    public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
+        return ImmutableClassToInstanceMap.of();
+    }
+
     public synchronized void changeSchema(final SchemaContext newContext) {
         schemaContext = newContext;
         for (ListenerRegistration<SchemaContextListener> listener : listeners) {
index c2c604e..119ac79 100644 (file)
@@ -103,10 +103,16 @@ public abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DO
     }
 
     @Override
+    @Deprecated
     public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
         return extensions;
     }
 
+    @Override
+    public ClassToInstanceMap<DOMDataBrokerExtension> getExtensions() {
+        return extensions;
+    }
+
     @Override
     public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
         checkNotClosed();
index 4555b87..b01a21d 100644 (file)
@@ -84,9 +84,8 @@ public class LegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMD
     public LegacyDOMDataBrokerAdapter(AbstractDOMBroker delegate) {
         this.delegate = delegate;
 
-        Map<Class<? extends org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension>,
-            org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> delegateExtensions =
-                delegate.getSupportedExtensions();
+        ClassToInstanceMap<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> delegateExtensions =
+                delegate.getExtensions();
 
         Builder<DOMDataBrokerExtension> extBuilder = ImmutableClassToInstanceMap.builder();
         final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService delegateTreeChangeService =
index e61fc52..0348e7a 100644 (file)
@@ -21,6 +21,7 @@ import akka.util.Timeout;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
+import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ForwardingObject;
 import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.FutureCallback;
@@ -288,10 +289,16 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat
     }
 
     @Override
+    @Deprecated
     public Map<Class<? extends DOMDataTreeServiceExtension>, DOMDataTreeServiceExtension> getSupportedExtensions() {
         return ImmutableClassToInstanceMap.of();
     }
 
+    @Override
+    public ClassToInstanceMap<DOMDataTreeServiceExtension> getExtensions() {
+        return ImmutableClassToInstanceMap.of();
+    }
+
     @Nonnull
     @Override
     public DOMDataTreeProducer createProducer(@Nonnull final Collection<DOMDataTreeIdentifier> subtrees) {
index bf551bb..7b3634f 100644 (file)
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import com.google.common.base.Throwables;
+import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
@@ -33,7 +34,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.SynchronousQueue;
@@ -584,12 +584,11 @@ public class ConcurrentDOMDataBrokerTest {
                 LogicalDatastoreType.OPERATIONAL, mockOperStore,
                 LogicalDatastoreType.CONFIGURATION, mockConfigStore), futureExecutor)) {
 
-            Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> supportedExtensions =
-                    dataBroker.getSupportedExtensions();
-            assertNotNull(supportedExtensions.get(DOMDataTreeChangeService.class));
+            ClassToInstanceMap<DOMDataBrokerExtension> supportedExtensions = dataBroker.getExtensions();
+            assertNotNull(supportedExtensions.getInstance(DOMDataTreeChangeService.class));
 
-            DOMDataTreeCommitCohortRegistry cohortRegistry =
-                    (DOMDataTreeCommitCohortRegistry) supportedExtensions.get(DOMDataTreeCommitCohortRegistry.class);
+            DOMDataTreeCommitCohortRegistry cohortRegistry = supportedExtensions.getInstance(
+                DOMDataTreeCommitCohortRegistry.class);
             assertNotNull(cohortRegistry);
 
             DOMDataTreeCommitCohort mockCohort = mock(DOMDataTreeCommitCohort.class);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.