X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2FNetconfServerSession.java;h=a4d7e747234ce07804a1405ff4f96ff31ecd35e5;hb=d542617f3486541cf9937009fb6aa1e3f2c9f0e2;hp=1ae3fabbb9a31bf5275b63f1bc27da15e8a72d88;hpb=a92d9d6a21a0f6ca8d2153795721f500eaf29ee9;p=controller.git diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSession.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSession.java index 1ae3fabbb9..a4d7e74723 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSession.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSession.java @@ -9,77 +9,18 @@ package org.opendaylight.controller.netconf.impl; import io.netty.channel.Channel; -import org.opendaylight.controller.netconf.api.NetconfMessage; + import org.opendaylight.controller.netconf.api.NetconfSession; -import org.opendaylight.controller.netconf.api.NetconfTerminationReason; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.protocol.framework.SessionListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; - public class NetconfServerSession extends NetconfSession { - private final SessionListener sessionListener; - private final Channel channel; - private static final Logger logger = LoggerFactory.getLogger(NetconfServerSession.class); - private final long sessionId; - private boolean up = false; public NetconfServerSession(SessionListener sessionListener, Channel channel, long sessionId) { - this.sessionListener = sessionListener; - this.channel = channel; - this.sessionId = sessionId; + super(sessionListener,channel,sessionId); logger.debug("Session {} created", toString()); } - - @Override - public void close() { - channel.close(); - sessionListener.onSessionTerminated(this, new NetconfTerminationReason("Session closed")); - } - - @Override - protected void handleMessage(NetconfMessage netconfMessage) { - logger.debug("Session {} received message {}", toString(), XmlUtil.toString(netconfMessage.getDocument())); - sessionListener.onMessage(this, netconfMessage); - } - - public void sendMessage(NetconfMessage netconfMessage) { - channel.writeAndFlush(netconfMessage); - } - - @Override - protected void endOfInput() { - logger.debug("Session {} end of input detected while session was in state {}", toString(), isUp() ? "up" - : "initialized"); - if (isUp()) { - this.sessionListener.onSessionDown(this, new IOException("End of input detected. Close the session.")); - } - } - - @Override - protected void sessionUp() { - logger.debug("Session {} up", toString()); - sessionListener.onSessionUp(this); - this.up = true; - } - - @Override - public String toString() { - final StringBuffer sb = new StringBuffer("ServerNetconfSession{"); - sb.append("sessionId=").append(sessionId); - sb.append('}'); - return sb.toString(); - } - - public boolean isUp() { - return up; - } - - public long getSessionId() { - return sessionId; - } }