Merge "Modify config code generator to write JmxAttribute as static fields."
[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 java.util.Collection;
12
13 import org.opendaylight.controller.netconf.util.AbstractNetconfSession;
14 import org.opendaylight.controller.netconf.util.handler.NetconfEXICodec;
15 import org.opendaylight.controller.netconf.util.handler.NetconfEXIToMessageDecoder;
16 import org.opendaylight.controller.netconf.util.handler.NetconfMessageToEXIEncoder;
17 import org.opendaylight.controller.netconf.util.handler.NetconfMessageToXMLEncoder;
18 import org.opendaylight.controller.netconf.util.handler.NetconfXMLToMessageDecoder;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 import io.netty.channel.Channel;
23
24 public final class NetconfClientSession extends AbstractNetconfSession<NetconfClientSession, NetconfClientSessionListener> {
25
26     private static final Logger logger = LoggerFactory.getLogger(NetconfClientSession.class);
27     private final Collection<String> capabilities;
28
29     public NetconfClientSession(NetconfClientSessionListener sessionListener, Channel channel, long sessionId,
30             Collection<String> capabilities) {
31         super(sessionListener, channel, sessionId);
32         this.capabilities = capabilities;
33         logger.debug("Client Session {} created", toString());
34     }
35
36     public Collection<String> getServerCapabilities() {
37         return capabilities;
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 }