Merge "Fixed typo in SnapshotBackedWriteTransaction class"
[controller.git] / opendaylight / netconf / netconf-client / src / main / java / org / opendaylight / controller / netconf / client / NetconfClientSession.java
index 5ee89fec40ab12fe3fbd104130eef0dc31d56d8e..f4efb1fc7dc9bf56cd3176c769f72c312ee351d2 100644 (file)
@@ -8,25 +8,27 @@
 
 package org.opendaylight.controller.netconf.client;
 
-import io.netty.channel.Channel;
-
 import java.util.Collection;
 
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.api.NetconfSession;
-import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
-import org.opendaylight.protocol.framework.SessionListener;
+import org.opendaylight.controller.netconf.util.AbstractNetconfSession;
+import org.opendaylight.controller.netconf.util.handler.NetconfEXICodec;
+import org.opendaylight.controller.netconf.util.handler.NetconfEXIToMessageDecoder;
+import org.opendaylight.controller.netconf.util.handler.NetconfMessageToEXIEncoder;
+import org.opendaylight.controller.netconf.util.handler.NetconfMessageToXMLEncoder;
+import org.opendaylight.controller.netconf.util.handler.NetconfXMLToMessageDecoder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfClientSession extends NetconfSession {
+import io.netty.channel.Channel;
+
+public final class NetconfClientSession extends AbstractNetconfSession<NetconfClientSession, NetconfClientSessionListener> {
 
     private static final Logger logger = LoggerFactory.getLogger(NetconfClientSession.class);
     private final Collection<String> capabilities;
 
-    public NetconfClientSession(SessionListener<NetconfMessage, NetconfSession, NetconfTerminationReason> sessionListener, Channel channel, long sessionId,
+    public NetconfClientSession(NetconfClientSessionListener sessionListener, Channel channel, long sessionId,
             Collection<String> capabilities) {
-        super(sessionListener,channel,sessionId);
+        super(sessionListener, channel, sessionId);
         this.capabilities = capabilities;
         logger.debug("Client Session {} created", toString());
     }
@@ -35,4 +37,22 @@ public class NetconfClientSession extends NetconfSession {
         return capabilities;
     }
 
+    @Override
+    protected NetconfClientSession thisInstance() {
+        return this;
+    }
+
+    @Override
+    protected void addExiHandlers(NetconfEXICodec exiCodec) {
+        // TODO used only in negotiator, client supports only auto start-exi
+        replaceMessageDecoder(new NetconfEXIToMessageDecoder(exiCodec));
+        replaceMessageEncoder(new NetconfMessageToEXIEncoder(exiCodec));
+    }
+
+    @Override
+    public void stopExiCommunication() {
+        // TODO never used, Netconf client does not support stop-exi
+        replaceMessageDecoder(new NetconfXMLToMessageDecoder());
+        replaceMessageEncoder(new NetconfMessageToXMLEncoder());
+    }
 }