Change return type of events
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / mastership / ReconciliationFrameworkServiceDelegate.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.impl.mastership;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
13 import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFrameworkEvent;
14 import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFrameworkRegistration;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public class ReconciliationFrameworkServiceDelegate implements ReconciliationFrameworkEvent, ReconciliationFrameworkRegistration {
20
21     private static final Logger LOG = LoggerFactory.getLogger(ReconciliationFrameworkServiceDelegate.class);
22
23     private final ReconciliationFrameworkEvent service;
24     private final AutoCloseable unregister;
25
26     ReconciliationFrameworkServiceDelegate(final ReconciliationFrameworkEvent service,
27                                            final AutoCloseable unregisterService) {
28         LOG.debug("Reconciliation framework service registered: {}", service);
29         this.service = service;
30         this.unregister = unregisterService;
31     }
32
33     @Override
34     public void close() throws Exception {
35         LOG.debug("Reconciliation framework service un-registered: {}", service);
36         this.unregister.close();
37         this.service.close();
38     }
39
40     @Override
41     public ListenableFuture<ResultState> onDevicePrepared(@Nonnull DeviceInfo deviceInfo) {
42         return this.service.onDevicePrepared(deviceInfo);
43     }
44
45     @Override
46     public ListenableFuture<Void> onDeviceDisconnected(@Nonnull DeviceInfo deviceInfo) {
47         return this.service.onDeviceDisconnected(deviceInfo);
48     }
49
50     @Override
51     public String toString() {
52         return service.toString();
53     }
54 }