- remove TLS/SSL support from netconf server and client
[controller.git] / opendaylight / netconf / netconf-util / src / main / java / org / opendaylight / controller / netconf / util / AbstractChannelInitializer.java
index caee5421525515a2b9cef2b136cf00d2f5944fd5..aeee2fb04baea1c4bd1535d7b677fb1f50957d8e 100644 (file)
@@ -11,10 +11,22 @@ package org.opendaylight.controller.netconf.util;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.util.concurrent.Promise;
 import org.opendaylight.controller.netconf.api.NetconfSession;
+import org.opendaylight.controller.netconf.util.handler.FramingMechanismHandlerFactory;
+import org.opendaylight.controller.netconf.util.handler.NetconfHandlerFactory;
+import org.opendaylight.controller.netconf.util.handler.NetconfMessageAggregator;
+import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
+import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory;
 
 public abstract class AbstractChannelInitializer {
 
-    public abstract void initialize(SocketChannel ch, Promise<? extends NetconfSession> promise);
+    public void initialize(SocketChannel ch, Promise<? extends NetconfSession> promise){
+        NetconfHandlerFactory handlerFactory = new NetconfHandlerFactory(new NetconfMessageFactory());
+        ch.pipeline().addLast("aggregator", new NetconfMessageAggregator(FramingMechanism.EOM));
+        ch.pipeline().addLast(handlerFactory.getDecoders());
+        initializeAfterDecoder(ch, promise);
+        ch.pipeline().addLast("frameEncoder", FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
+        ch.pipeline().addLast(handlerFactory.getEncoders());
+    }
 
     protected abstract void initializeAfterDecoder(SocketChannel ch, Promise<? extends NetconfSession> promise);