Bug 6714 - Use singleton service in clustered netconf topology
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / utils / NetconfConnectorDTO.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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
9 package org.opendaylight.netconf.topology.singleton.impl.utils;
10
11 import org.opendaylight.netconf.client.NetconfClientSessionListener;
12 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
13 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
14 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
15
16 public class NetconfConnectorDTO implements AutoCloseable {
17
18     private final NetconfDeviceCommunicator communicator;
19     private final RemoteDeviceHandler<NetconfSessionPreferences> facade;
20
21     public NetconfConnectorDTO(final NetconfDeviceCommunicator communicator,
22                                final RemoteDeviceHandler<NetconfSessionPreferences> facade) {
23         this.communicator = communicator;
24         this.facade = facade;
25     }
26
27     public NetconfDeviceCommunicator getCommunicator() {
28         return communicator;
29     }
30
31     public RemoteDeviceHandler<NetconfSessionPreferences> getFacade() {
32         return facade;
33     }
34
35     public NetconfClientSessionListener getSessionListener() {
36         return communicator;
37     }
38
39     @Override
40     public void close() throws Exception {
41         if (communicator != null) {
42             communicator.close();
43         }
44         if (facade != null) {
45             facade.close();
46         }
47     }
48 }