Remove deprecated MD-SAL APIs
[controller.git] / opendaylight / md-sal / samples / clustering-test-app / provider / src / main / java / org / opendaylight / controller / clustering / it / provider / PurchaseCarProvider.java
index 457d8193b7c68184b31ce47ef32cd51465387ca1..dc6b47da900e0b421b46171ee0112707f6dd5c67 100644 (file)
@@ -5,12 +5,12 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
  * 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.controller.clustering.it.provider;
 
 package org.opendaylight.controller.clustering.it.provider;
 
+import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutputBuilder;
@@ -25,10 +25,10 @@ public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class);
 
 
     private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class);
 
-    private NotificationProviderService notificationProvider;
+    private NotificationPublishService notificationProvider;
 
 
 
 
-    public void setNotificationProvider(final NotificationProviderService salService) {
+    public void setNotificationProvider(final NotificationPublishService salService) {
         this.notificationProvider = salService;
     }
 
         this.notificationProvider = salService;
     }
 
@@ -36,13 +36,13 @@ public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable {
     @Override
     public ListenableFuture<RpcResult<BuyCarOutput>> buyCar(final BuyCarInput input) {
         LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
     @Override
     public ListenableFuture<RpcResult<BuyCarOutput>> buyCar(final BuyCarInput input) {
         LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
-        final SettableFuture<RpcResult<BuyCarOutput>> futureResult = SettableFuture.create();
-        CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder();
-        carBoughtBuilder.setCarId(input.getCarId());
-        carBoughtBuilder.setPersonId(input.getPersonId());
-        notificationProvider.publish(carBoughtBuilder.build());
-        futureResult.set(RpcResultBuilder.success(new BuyCarOutputBuilder().build()).build());
-        return futureResult;
+
+        return Futures.transform(notificationProvider.offerNotification(new CarBoughtBuilder()
+            .setCarId(input.getCarId())
+            .setPersonId(input.getPersonId())
+            .build()),
+            result -> RpcResultBuilder.success(new BuyCarOutputBuilder().build()).build(),
+            MoreExecutors.directExecutor());
     }
 
     @Override
     }
 
     @Override