Remove reliance on org.opendaylight.controller.sal.core.api.Broker 00/51300/6
authorRobert Varga <rovarga@cisco.com>
Wed, 1 Feb 2017 13:07:05 +0000 (14:07 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 10 Feb 2017 12:23:24 +0000 (12:23 +0000)
Broker-related interfaces are no longer used, as we are activating
via blueprint. Remove references to them.

Change-Id: I67552c986c31e0214cb35d8fc2b60cca536ecbb5
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/org/opendaylight/blueprint/remote-rpc.xml
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/AbstractRpcTest.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java

index e4f6a21..51e56d0 100644 (file)
@@ -12,12 +12,8 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.PoisonPill;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
-import java.util.Collection;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sal.core.api.Provider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -25,28 +21,25 @@ import org.slf4j.LoggerFactory;
  * This is the base class which initialize all the actors, listeners and
  * default RPc implementation so remote invocation of rpcs.
  */
-public class RemoteRpcProvider implements AutoCloseable, Provider {
+public class RemoteRpcProvider implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(RemoteRpcProvider.class);
 
     private final DOMRpcProviderService rpcProvisionRegistry;
     private final RemoteRpcProviderConfig config;
     private final ActorSystem actorSystem;
+    private final DOMRpcService rpcService;
 
-    private DOMRpcService rpcService;
     private ActorRef rpcManager;
 
     public RemoteRpcProvider(final ActorSystem actorSystem, final DOMRpcProviderService rpcProvisionRegistry,
-            final RemoteRpcProviderConfig config) {
-        this.actorSystem = actorSystem;
-        this.rpcProvisionRegistry = rpcProvisionRegistry;
+            final DOMRpcService rpcService, final RemoteRpcProviderConfig config) {
+        this.actorSystem = Preconditions.checkNotNull(actorSystem);
+        this.rpcProvisionRegistry = Preconditions.checkNotNull(rpcProvisionRegistry);
+        this.rpcService = Preconditions.checkNotNull(rpcService);
         this.config = Preconditions.checkNotNull(config);
     }
 
-    public void setRpcService(final DOMRpcService rpcService) {
-        this.rpcService = rpcService;
-    }
-
     @Override
     public void close() {
         if (rpcManager != null) {
@@ -56,17 +49,6 @@ public class RemoteRpcProvider implements AutoCloseable, Provider {
         }
     }
 
-    @Override
-    public void onSessionInitiated(final Broker.ProviderSession session) {
-        rpcService = session.getService(DOMRpcService.class);
-        start();
-    }
-
-    @Override
-    public Collection<ProviderFunctionality> getProviderFunctionality() {
-        return ImmutableSet.of();
-    }
-
     public void start() {
         LOG.info("Starting Remote RPC service...");
         rpcManager = actorSystem.actorOf(RpcManager.props(rpcProvisionRegistry, rpcService, config),
index c6ec928..226faf2 100644 (file)
@@ -10,11 +10,12 @@ package org.opendaylight.controller.remote.rpc;
 
 import akka.actor.ActorSystem;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 
 public class RemoteRpcProviderFactory {
     public static RemoteRpcProvider createInstance(final DOMRpcProviderService rpcProviderService,
-            final ActorSystem actorSystem, final RemoteRpcProviderConfig config) {
+            final DOMRpcService rpcService, final ActorSystem actorSystem, final RemoteRpcProviderConfig config) {
 
-        return new RemoteRpcProvider(actorSystem, rpcProviderService, config);
+        return new RemoteRpcProvider(actorSystem, rpcProviderService, rpcService, config);
     }
 }
index f12a289..233d7b8 100644 (file)
@@ -29,9 +29,9 @@
   <bean id="remoteRpcProvider" class="org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory"
           factory-method="createInstance" init-method="start" destroy-method="close">
     <argument ref="domRpcRegistry"/>
+    <argument ref="domRpcService"/>
     <argument ref="actorSystem"/>
     <argument ref="remoteRpcProviderConfig"/>
-    <property name="rpcService" ref="domRpcService"/>
   </bean>
 
 </blueprint>
index 438c742..32b54c4 100644 (file)
@@ -26,7 +26,6 @@ import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
@@ -72,7 +71,6 @@ public class AbstractRpcTest {
     protected JavaTestKit rpcRegistry1Probe;
     protected ActorRef rpcInvoker2;
     protected JavaTestKit rpcRegistry2Probe;
-    protected Broker.ProviderSession brokerSession;
     protected SchemaContext schemaContext;
     protected RemoteRpcImplementation remoteRpcImpl1;
     protected RemoteRpcImplementation remoteRpcImpl2;
index 76e63c4..45fc9ff 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.controller.remote.rpc;
 
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
@@ -23,7 +22,6 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker;
 import scala.concurrent.Await;
 import scala.concurrent.duration.Duration;
 
@@ -49,11 +47,9 @@ public class RemoteRpcProviderTest {
     @Test
     public void testRemoteRpcProvider() throws Exception {
         try (final RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(DOMRpcProviderService.class),
-                new RemoteRpcProviderConfig(system.settings().config()))) {
-            final Broker.ProviderSession session = mock(Broker.ProviderSession.class);
-            when(session.getService(DOMRpcService.class)).thenReturn(mock(DOMRpcService.class));
+            mock(DOMRpcService.class), new RemoteRpcProviderConfig(system.settings().config()))) {
 
-            rpcProvider.onSessionInitiated(session);
+            rpcProvider.start();
 
             final ActorRef actorRef = Await.result(
                     system.actorSelection(moduleConfig.getRpcManagerPath()).resolveOne(