2 * Copyright (c) 2013 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.netconf.client;
11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
12 import io.netty.channel.Channel;
13 import io.netty.handler.codec.ByteToMessageDecoder;
14 import io.netty.handler.codec.MessageToByteEncoder;
15 import java.util.Collection;
16 import org.opendaylight.netconf.api.NetconfMessage;
17 import org.opendaylight.netconf.nettyutil.AbstractNetconfSession;
18 import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
19 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class NetconfClientSession extends AbstractNetconfSession<NetconfClientSession, NetconfClientSessionListener> {
25 private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSession.class);
26 private final Collection<String> capabilities;
29 * Construct a new session.
31 * @param sessionListener Netconf client session listener.
32 * @param channel Channel.
33 * @param sessionId Session Id.
34 * @param capabilities Set of advertised capabilities. Expected to be immutable.
36 @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "'this' passed to logger")
37 public NetconfClientSession(final NetconfClientSessionListener sessionListener, final Channel channel,
38 final long sessionId, final Collection<String> capabilities) {
39 super(sessionListener, channel, sessionId);
40 this.capabilities = capabilities;
41 LOG.debug("Client Session {} created", this);
44 public Collection<String> getServerCapabilities() {
49 protected NetconfClientSession thisInstance() {
54 protected void addExiHandlers(final ByteToMessageDecoder decoder,
55 final MessageToByteEncoder<NetconfMessage> encoder) {
56 // TODO used only in negotiator, client supports only auto start-exi
57 replaceMessageDecoder(decoder);
58 replaceMessageEncoder(encoder);
62 public void stopExiCommunication() {
63 // TODO never used, Netconf client does not support stop-exi
64 replaceMessageDecoder(new NetconfXMLToMessageDecoder());
65 replaceMessageEncoder(new NetconfMessageToXMLEncoder());