2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.clustering.it.provider;
11 import com.google.common.util.concurrent.SettableFuture;
12 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarBoughtBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarPurchaseService;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
17 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 import java.util.concurrent.Future;
24 public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable{
26 private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class);
28 private NotificationProviderService notificationProvider;
31 public void setNotificationProvider(final NotificationProviderService salService) {
32 this.notificationProvider = salService;
37 public Future<RpcResult<Void>> buyCar(BuyCarInput input) {
38 LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
39 SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
40 CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder();
41 carBoughtBuilder.setCarId(input.getCarId());
42 carBoughtBuilder.setPersonId(input.getPersonId());
43 notificationProvider.publish(carBoughtBuilder.build());
44 futureResult.set(RpcResultBuilder.<Void>success().build());
49 public void close() throws Exception {