X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2FAbstractChannelInitializer.java;h=52c59a2b31dd15b4711b9cc9bab14d4634f5bde3;hb=36bba533c00f2a912bd6c95d7b091a94a1fc1707;hp=5d082c92cda6c59a86fdd557206cb6817a4d4f6e;hpb=e6bcd06e610be274e8f2df901b61789bb17c442a;p=controller.git diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/AbstractChannelInitializer.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/AbstractChannelInitializer.java index 5d082c92cd..52c59a2b31 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/AbstractChannelInitializer.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/AbstractChannelInitializer.java @@ -8,41 +8,19 @@ package org.opendaylight.controller.netconf.util; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; +import io.netty.channel.socket.SocketChannel; +import io.netty.util.concurrent.Promise; -import org.opendaylight.controller.netconf.api.NetconfMessage; 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; -import org.opendaylight.protocol.framework.ProtocolHandlerFactory; -import org.opendaylight.protocol.framework.ProtocolMessageDecoder; -import org.opendaylight.protocol.framework.ProtocolMessageEncoder; - -import com.google.common.base.Optional; - -import io.netty.channel.ChannelHandler; -import io.netty.channel.socket.SocketChannel; -import io.netty.handler.ssl.SslHandler; -import io.netty.util.concurrent.Promise; public abstract class AbstractChannelInitializer { - private final Optional maybeContext; - private final NetconfHandlerFactory handlerFactory; - - public AbstractChannelInitializer(Optional maybeContext) { - this.maybeContext = maybeContext; - this.handlerFactory = new NetconfHandlerFactory(new NetconfMessageFactory()); - } - - public void initialize(SocketChannel ch, Promise promise) { - if (maybeContext.isPresent()) { - initSsl(ch); - } - + public void initialize(SocketChannel ch, Promise promise){ + NetconfHandlerFactory handlerFactory = new NetconfHandlerFactory(); ch.pipeline().addLast("aggregator", new NetconfMessageAggregator(FramingMechanism.EOM)); ch.pipeline().addLast(handlerFactory.getDecoders()); initializeAfterDecoder(ch, promise); @@ -52,29 +30,4 @@ public abstract class AbstractChannelInitializer { protected abstract void initializeAfterDecoder(SocketChannel ch, Promise promise); - private void initSsl(SocketChannel ch) { - SSLEngine sslEngine = maybeContext.get().createSSLEngine(); - initSslEngine(sslEngine); - final SslHandler handler = new SslHandler(sslEngine); - ch.pipeline().addLast("ssl", handler); - } - - protected abstract void initSslEngine(SSLEngine sslEngine); - - private static final class NetconfHandlerFactory extends ProtocolHandlerFactory { - - public NetconfHandlerFactory(final NetconfMessageFactory msgFactory) { - super(msgFactory); - } - - @Override - public ChannelHandler[] getEncoders() { - return new ChannelHandler[] { new ProtocolMessageEncoder(this.msgFactory) }; - } - - @Override - public ChannelHandler[] getDecoders() { - return new ChannelHandler[] { new ProtocolMessageDecoder(this.msgFactory) }; - } - } }