Merge "bug 741 - Make sure to stop threads on bundle stop on TopologyServiceShim"
[controller.git] / opendaylight / netconf / netconf-client / src / main / java / org / opendaylight / controller / netconf / client / NetconfClientSession.java
1 /*
2  * Copyright (c) 2013 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.controller.netconf.client;
10
11 import io.netty.channel.Channel;
12 import org.opendaylight.controller.netconf.util.AbstractNetconfSession;
13 import org.opendaylight.controller.netconf.util.handler.NetconfEXICodec;
14 import org.opendaylight.controller.netconf.util.handler.NetconfEXIToMessageDecoder;
15 import org.opendaylight.controller.netconf.util.handler.NetconfMessageToEXIEncoder;
16 import org.opendaylight.controller.netconf.util.handler.NetconfMessageToXMLEncoder;
17 import org.opendaylight.controller.netconf.util.handler.NetconfXMLToMessageDecoder;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 import java.util.Collection;
22
23 public final class NetconfClientSession extends AbstractNetconfSession<NetconfClientSession, NetconfClientSessionListener> {
24
25     private static final Logger logger = LoggerFactory.getLogger(NetconfClientSession.class);
26     private final Collection<String> capabilities;
27
28     public NetconfClientSession(NetconfClientSessionListener sessionListener, Channel channel, long sessionId,
29             Collection<String> capabilities) {
30         super(sessionListener, channel, sessionId);
31         this.capabilities = capabilities;
32         logger.debug("Client Session {} created", toString());
33     }
34
35     public Collection<String> getServerCapabilities() {
36         return capabilities;
37     }
38
39
40     @Override
41     protected NetconfClientSession thisInstance() {
42         return this;
43     }
44
45     @Override
46     protected void addExiHandlers(NetconfEXICodec exiCodec) {
47         // TODO used only in negotiator, client supports only auto start-exi
48         replaceMessageDecoder(new NetconfEXIToMessageDecoder(exiCodec));
49         replaceMessageEncoder(new NetconfMessageToEXIEncoder(exiCodec));
50     }
51
52     @Override
53     public void stopExiCommunication() {
54         // TODO never used, Netconf client does not support stop-exi
55         replaceMessageDecoder(new NetconfXMLToMessageDecoder());
56         replaceMessageEncoder(new NetconfMessageToXMLEncoder());
57     }
58 }