Remove DOMRpcImplementationRegistration 07/109207/4
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 7 Dec 2023 15:53:54 +0000 (16:53 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 8 Dec 2023 18:47:13 +0000 (19:47 +0100)
DOMRpcImplementationRegistration is a completely unnecessary
specialization of Registration. Remove it and update
DOMRpcProviderService to simplify implementations.

This change renders AbstractDOMRpcProviderService and
AbstractDOMRpcImplementationRegistration superfluous and hence we remove
them.

JIRA: MDSAL-843
Change-Id: I51871aa0a4a9831acfb6c096cb9b72dbf5aa27d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMRpcImplementationRegistration.java [deleted file]
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMRpcProviderService.java
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistration.java [deleted file]
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderService.java [deleted file]
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcProviderService.java
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistrationTest.java [deleted file]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderServiceTest.java [deleted file]

diff --git a/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMRpcImplementationRegistration.java b/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMRpcImplementationRegistration.java
deleted file mode 100644 (file)
index 883085e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.api;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * A registration of a {@link DOMRpcImplementation}. Used to track and revoke a registration
- * with a {@link DOMRpcProviderService}.
- *
- * @param <T> RPC implementation type
- */
-// FIXME: reconsider usefulness of this capture
-public interface DOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends ObjectRegistration<T> {
-
-}
index 90a470f492cb455c0ef311241c3df3a305ba51c5..b22c89fd3bc79cdb44cd1c6860da243d5cdd30da 100644 (file)
@@ -30,27 +30,27 @@ public interface DOMRpcProviderService extends DOMService<DOMRpcProviderService,
      * @param implementation RPC implementation, must not be null
      * @param rpcs Array of supported RPC identifiers. Must not be null, empty, or contain a null element.
      *             Each identifier is added exactly once, no matter how many times it occurs.
-     * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
+     * @return A {@link Registration} object, guaranteed to be non-null.
      * @throws NullPointerException if implementation or types is null
      * @throws IllegalArgumentException if types is empty or contains a null element.
      */
-    // FIXME: just Registration and forward to set
-    // FIXME: single-instance specialization
-    @NonNull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
-        registerRpcImplementation(@NonNull T implementation, @NonNull DOMRpcIdentifier... rpcs);
+    default @NonNull Registration registerRpcImplementation(final @NonNull DOMRpcImplementation implementation,
+            final @NonNull DOMRpcIdentifier... rpcs) {
+        return registerRpcImplementation(implementation, Set.of(rpcs));
+    }
 
     /**
      * Register an {@link DOMRpcImplementation} object with this service.
      *
      * @param implementation RPC implementation, must not be null
      * @param rpcs Set of supported RPC identifiers. Must not be null, empty, or contain a null element.
-     * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
+     * @return A {@link Registration} object, guaranteed to be non-null.
      * @throws NullPointerException if implementation or types is null
      * @throws IllegalArgumentException if types is empty or contains a null element.
      */
-    // FIXME: just Registration and forward to set
-    @NonNull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
-        registerRpcImplementation(@NonNull T implementation, @NonNull Set<DOMRpcIdentifier> rpcs);
+    // FIXME: just Registration and forward to Map
+    @NonNull Registration registerRpcImplementation(@NonNull DOMRpcImplementation implementation,
+        @NonNull Set<DOMRpcIdentifier> rpcs);
 
     /**
      * Register a set of {@link DOMRpcImplementation}s with this service. The registration is performed atomically.
index 3d9544673df06dfd55c3fa161159df37c87da7dc..ce2d1a081bc8f0992eac498cdb3ca7a51cc208d0 100644 (file)
@@ -52,12 +52,10 @@ import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
 import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.mdsal.dom.spi.AbstractDOMRpcImplementationRegistration;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
@@ -481,14 +479,8 @@ public final class DOMRpcRouter extends AbstractRegistration implements Effectiv
 
     private final class RpcProviderServiceFacade implements DOMRpcProviderService {
         @Override
-        public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
-                final T implementation, final DOMRpcIdentifier... rpcs) {
-            return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs));
-        }
-
-        @Override
-        public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
-                final T implementation, final Set<DOMRpcIdentifier> rpcs) {
+        public Registration registerRpcImplementation(final DOMRpcImplementation implementation,
+                final Set<DOMRpcIdentifier> rpcs) {
 
             synchronized (DOMRpcRouter.this) {
                 final DOMRpcRoutingTable oldTable = routingTable;
@@ -498,10 +490,10 @@ public final class DOMRpcRouter extends AbstractRegistration implements Effectiv
                 listenerNotifier.execute(() -> notifyAdded(newTable, implementation));
             }
 
-            return new AbstractDOMRpcImplementationRegistration<>(implementation) {
+            return new AbstractRegistration() {
                 @Override
                 protected void removeRegistration() {
-                    removeRpcImplementation(getInstance(), rpcs);
+                    removeRpcImplementation(implementation, rpcs);
                 }
             };
         }
diff --git a/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistration.java b/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistration.java
deleted file mode 100644 (file)
index 5df087f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.spi;
-
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-
-/**
- * Abstract base class for {@link DOMRpcImplementationRegistration} implementations.
- */
-public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends
-        AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
-    protected AbstractDOMRpcImplementationRegistration(final T instance) {
-        super(instance);
-    }
-}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderService.java b/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderService.java
deleted file mode 100644 (file)
index 9479cee..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.spi;
-
-import com.google.common.collect.ImmutableSet;
-import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
-
-/**
- * Convenience abstract base class for {@link DOMRpcProviderService} implementations.
- */
-public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
-    @Override
-    public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
-            registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
-        return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
-    }
-}
index 96c7a40a7f5432ec112a18a10330e1822f6c3211..cf111f0177928b8a1449d0f062b4ed8b17f0ac29 100644 (file)
@@ -13,7 +13,6 @@ import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.yangtools.concepts.Registration;
 
@@ -26,14 +25,14 @@ public abstract class ForwardingDOMRpcProviderService extends ForwardingObject i
     protected abstract @NonNull DOMRpcProviderService delegate();
 
     @Override
-    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
-            final T implementation, final DOMRpcIdentifier... types) {
+    public Registration registerRpcImplementation(final DOMRpcImplementation implementation,
+            final DOMRpcIdentifier... types) {
         return delegate().registerRpcImplementation(implementation, types);
     }
 
     @Override
-    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
-            final T implementation, final Set<DOMRpcIdentifier> types) {
+    public Registration registerRpcImplementation(final DOMRpcImplementation implementation,
+            final Set<DOMRpcIdentifier> types) {
         return delegate().registerRpcImplementation(implementation, types);
     }
 
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistrationTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistrationTest.java
deleted file mode 100644 (file)
index 2565e39..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.spi;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-
-public class AbstractDOMRpcImplementationRegistrationTest
-        extends AbstractDOMRpcImplementationRegistration<DOMRpcImplementation> {
-
-    private static final DOMRpcImplementation DOM_RPC_IMPLEMENTATION = mock(DOMRpcImplementation.class);
-
-    public AbstractDOMRpcImplementationRegistrationTest() {
-        super(DOM_RPC_IMPLEMENTATION);
-    }
-
-    @Test
-    public void basicTest() throws Exception {
-        AbstractDOMRpcImplementationRegistration<?> abstractDOMRpcImplementationRegistration =
-                new AbstractDOMRpcImplementationRegistrationTest();
-        assertEquals(DOM_RPC_IMPLEMENTATION, abstractDOMRpcImplementationRegistration.getInstance());
-        abstractDOMRpcImplementationRegistration.close();
-    }
-
-    @Override
-    protected void removeRegistration() {
-        // NOOP
-    }
-}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderServiceTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderServiceTest.java
deleted file mode 100644 (file)
index 5f0dd4f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.spi;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import java.util.Map;
-import java.util.Set;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
-
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class AbstractDOMRpcProviderServiceTest extends AbstractDOMRpcProviderService {
-    @Mock(name = "domRpcImplementationRegistration")
-    public DOMRpcImplementationRegistration<?> domRpcImplementationRegistration;
-
-    @Test
-    public void registerRpcImplementation() throws Exception {
-        assertEquals(domRpcImplementationRegistration, this.registerRpcImplementation(
-            mock(DOMRpcImplementation.class)));
-    }
-
-    @Override
-    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
-            final T implementation, final Set<DOMRpcIdentifier> rpcs) {
-        return (DOMRpcImplementationRegistration<T>) domRpcImplementationRegistration;
-    }
-
-    @Override
-    public Registration registerRpcImplementations(final Map<DOMRpcIdentifier, DOMRpcImplementation> map) {
-        throw new UnsupportedOperationException();
-    }
-}
\ No newline at end of file