Switch to MD-SAL APIs
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginGroupTestServiceProvider.java
index fb75736a36a0a4ac67ac9005dc97dd05f8771dc8..7f12e32b604c5416cfac4235e688962f3a3be508 100644 (file)
@@ -1,17 +1,16 @@
-/**
+/*
  * Copyright (c) 2013 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.openflowplugin.test;
 
-import java.util.concurrent.Future;
-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 com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
@@ -19,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Rem
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@@ -27,7 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,44 +34,38 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
 
     private static final Logger LOG = LoggerFactory
             .getLogger(OpenflowpluginGroupTestServiceProvider.class);
-    private RoutedRpcRegistration<SalGroupService> groupRegistration;
-    private NotificationProviderService notificationService;
+    private ObjectRegistration<SalGroupService> groupRegistration;
+    private NotificationPublishService notificationService;
 
     /**
-     * get group registration
+     * Get group registration.
      *
      * @return {@link #groupRegistration}
      */
-    public RoutedRpcRegistration<SalGroupService> getGroupRegistration() {
+    public ObjectRegistration<SalGroupService> getGroupRegistration() {
         return groupRegistration;
     }
 
     /**
-     * set {@link #groupRegistration}
-     *
-     * @param groupRegistration
+     * Set {@link #groupRegistration}.
      */
-    public void setGroupRegistration(
-            final RoutedRpcRegistration<SalGroupService> groupRegistration) {
+    public void setGroupRegistration(final ObjectRegistration<SalGroupService> groupRegistration) {
         this.groupRegistration = groupRegistration;
     }
 
     /**
-     * get notification service
+     * Get notification service.
      *
      * @return {@link #notificationService}
      */
-    public NotificationProviderService getNotificationService() {
+    public NotificationPublishService getNotificationService() {
         return notificationService;
     }
 
     /**
-     * set {@link #notificationService}
-     *
-     * @param notificationService
+     * Set {@link #notificationService}.
      */
-    public void setNotificationService(
-            final NotificationProviderService notificationService) {
+    public void setNotificationService(final NotificationPublishService notificationService) {
         this.notificationService = notificationService;
     }
 
@@ -105,9 +96,8 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
      * .service.rev130918.AddGroupInput)
      */
     @Override
-    public Future<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
-        String plus = ("addGroup - " + input);
-        OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
+    public ListenableFuture<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
+        OpenflowpluginGroupTestServiceProvider.LOG.info("addGroup - {}", input);
         return null;
     }
 
@@ -121,10 +111,9 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
      * .group.service.rev130918.RemoveGroupInput)
      */
     @Override
-    public Future<RpcResult<RemoveGroupOutput>> removeGroup(
+    public ListenableFuture<RpcResult<RemoveGroupOutput>> removeGroup(
             RemoveGroupInput input) {
-        String plus = ("removeGroup - " + input);
-        OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
+        OpenflowpluginGroupTestServiceProvider.LOG.info("removeGroup - {}", input);
         return null;
     }
 
@@ -138,42 +127,22 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
      * .group.service.rev130918.UpdateGroupInput)
      */
     @Override
-    public Future<RpcResult<UpdateGroupOutput>> updateGroup(
+    public ListenableFuture<RpcResult<UpdateGroupOutput>> updateGroup(
             UpdateGroupInput input) {
-        String plus = ("updateGroup - " + input);
-        OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
+        OpenflowpluginGroupTestServiceProvider.LOG.info("updateGroup - {}", input);
         return null;
     }
 
-    /**
-     * @param ctx
-     * @return {@link ObjectRegistration}
-     */
-    public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
-            final ProviderContext ctx) {
-        RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = ctx
-                .<SalGroupService> addRoutedRpcImplementation(
-                        SalGroupService.class, this);
-        setGroupRegistration(addRoutedRpcImplementation);
-
-        InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier
-                .<Nodes> builder(Nodes.class);
+    public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(final RpcProviderService rpcRegistry) {
+        setGroupRegistration(rpcRegistry.registerRpcImplementation(SalGroupService.class, this, ImmutableSet.of(
+            InstanceIdentifier.create(Nodes.class)
+            .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID))))));
 
-        NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
-        NodeKey nodeKey = new NodeKey(nodeId);
-
-        InstanceIdentifierBuilder<Node> nodeIndentifier = builder1
-                .<Node, NodeKey> child(Node.class, nodeKey);
-        InstanceIdentifier<Node> instance = nodeIndentifier.build();
-        groupRegistration.registerPath(NodeContext.class, instance);
-        RoutedRpcRegistration<SalGroupService> groupRegistration1 = this
-                .getGroupRegistration();
         return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {
             @Override
             protected void removeRegistration() {
-                groupRegistration1.close();
+                groupRegistration.close();
             }
         };
     }
-
 }