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 io.netty.channel.Channel;
12 import io.netty.handler.codec.ByteToMessageDecoder;
13 import io.netty.handler.codec.MessageToByteEncoder;
14 import java.util.Collection;
15 import org.opendaylight.netconf.api.NetconfMessage;
16 import org.opendaylight.netconf.nettyutil.AbstractNetconfSession;
17 import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
18 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class NetconfClientSession extends AbstractNetconfSession<NetconfClientSession, NetconfClientSessionListener> {
24 private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSession.class);
25 private final Collection<String> capabilities;
28 * Construct a new session.
30 * @param sessionListener Netconf client session listener.
31 * @param channel Channel.
32 * @param sessionId Session Id.
33 * @param capabilities Set of advertised capabilities. Expected to be immutable.
35 public NetconfClientSession(final NetconfClientSessionListener sessionListener, final Channel channel,
36 final long sessionId, final Collection<String> capabilities) {
37 super(sessionListener, channel, sessionId);
38 this.capabilities = capabilities;
39 LOG.debug("Client Session {} created", this);
42 public Collection<String> getServerCapabilities() {
47 protected NetconfClientSession thisInstance() {
52 protected void addExiHandlers(final ByteToMessageDecoder decoder,
53 final MessageToByteEncoder<NetconfMessage> encoder) {
54 // TODO used only in negotiator, client supports only auto start-exi
55 replaceMessageDecoder(decoder);
56 replaceMessageEncoder(encoder);
60 public void stopExiCommunication() {
61 // TODO never used, Netconf client does not support stop-exi
62 replaceMessageDecoder(new NetconfXMLToMessageDecoder());
63 replaceMessageEncoder(new NetconfMessageToXMLEncoder());