OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestServiceProvider.java
index 1464509c06d7af4566394f1f4eb83b9b8dcf87e6..3aa5ecf58f5c79969f77c45ff8f2295343de194f 100644 (file)
@@ -8,11 +8,11 @@
 
 package org.opendaylight.openflowplugin.test;
 
-import java.util.concurrent.Future;
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
@@ -39,12 +39,18 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
     private static final Logger LOG = LoggerFactory
             .getLogger(OpenflowpluginTestServiceProvider.class);
 
-    private DataBroker dataService;
+    private final DataBroker dataService;
     private RoutedRpcRegistration<SalFlowService> flowRegistration;
-    private NotificationProviderService notificationProviderService;
+    private final NotificationProviderService notificationProviderService;
+
+    public OpenflowpluginTestServiceProvider(DataBroker dataService,
+            NotificationProviderService notificationProviderService) {
+        this.dataService = dataService;
+        this.notificationProviderService = notificationProviderService;
+    }
 
     /**
-     * get data service
+     * Get data service.
      *
      * @return {@link #dataService}
      */
@@ -53,16 +59,7 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
     }
 
     /**
-     * set {@link #dataService}
-     *
-     * @param dataService
-     */
-    public void setDataService(final DataBroker dataService) {
-        this.dataService = dataService;
-    }
-
-    /**
-     * get flow registration
+     * Get flow registration.
      *
      * @return {@link #flowRegistration}
      */
@@ -71,9 +68,7 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
     }
 
     /**
-     * set {@link #flowRegistration}
-     *
-     * @param flowRegistration
+     * Set {@link #flowRegistration}.
      */
     public void setFlowRegistration(
             final RoutedRpcRegistration<SalFlowService> flowRegistration) {
@@ -81,7 +76,7 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
     }
 
     /**
-     * get notification service
+     * Get notification service.
      *
      * @return {@link #notificationProviderService}
      */
@@ -89,21 +84,6 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
         return notificationProviderService;
     }
 
-    /**
-     * set {@link #notificationProviderService}
-     *
-     * @param notificationProviderService
-     */
-    public void setNotificationService(
-            final NotificationProviderService notificationProviderService) {
-        this.notificationProviderService = notificationProviderService;
-    }
-
-    public void start() {
-        OpenflowpluginTestServiceProvider.LOG
-                .info("SalFlowServiceProvider Started.");
-    }
-
     /*
      * (non-Javadoc)
      *
@@ -126,9 +106,8 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
      * service.rev130819.AddFlowInput)
      */
     @Override
-    public Future<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
-        String plus = ("addFlow - " + input);
-        OpenflowpluginTestServiceProvider.LOG.info(plus);
+    public ListenableFuture<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
+        OpenflowpluginTestServiceProvider.LOG.info("addFlow - {}", input);
         return null;
     }
 
@@ -142,9 +121,8 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
      * .service.rev130819.RemoveFlowInput)
      */
     @Override
-    public Future<RpcResult<RemoveFlowOutput>> removeFlow(RemoveFlowInput input) {
-        String plus = ("removeFlow - " + input);
-        OpenflowpluginTestServiceProvider.LOG.info(plus);
+    public ListenableFuture<RpcResult<RemoveFlowOutput>> removeFlow(RemoveFlowInput input) {
+        OpenflowpluginTestServiceProvider.LOG.info("removeFlow - {}", input);
         return null;
     }
 
@@ -158,32 +136,25 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
      * .service.rev130819.UpdateFlowInput)
      */
     @Override
-    public Future<RpcResult<UpdateFlowOutput>> updateFlow(UpdateFlowInput input) {
-        String plus = ("updateFlow - " + input);
-        OpenflowpluginTestServiceProvider.LOG.info(plus);
+    public ListenableFuture<RpcResult<UpdateFlowOutput>> updateFlow(UpdateFlowInput input) {
+        OpenflowpluginTestServiceProvider.LOG.info("updateFlow - {}", input);
         return null;
     }
 
-    /**
-     * @param ctx
-     * @return {@link ObjectRegistration}
-     */
-    public ObjectRegistration<OpenflowpluginTestServiceProvider> register(
-            final ProviderContext ctx) {
-        RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx
-                .<SalFlowService> addRoutedRpcImplementation(
-                        SalFlowService.class, this);
+    public ObjectRegistration<OpenflowpluginTestServiceProvider> register(RpcProviderRegistry rpcRegistry) {
+        RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation =
+                rpcRegistry.addRoutedRpcImplementation(SalFlowService.class, this);
 
         setFlowRegistration(addRoutedRpcImplementation);
 
         InstanceIdentifierBuilder<Nodes> builderII = InstanceIdentifier
-                .<Nodes> builder(Nodes.class);
+                .<Nodes>builder(Nodes.class);
 
         NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
         NodeKey nodeKey = new NodeKey(nodeId);
 
         InstanceIdentifierBuilder<Node> nodeIdentifier = builderII
-                .<Node, NodeKey> child(Node.class, nodeKey);
+                .<Node, NodeKey>child(Node.class, nodeKey);
 
         InstanceIdentifier<Node> instance = nodeIdentifier.build();