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=caee5421525515a2b9cef2b136cf00d2f5944fd5;hb=e7c8982a45c9ee5789d7ba25bb0324065efbe23e;hp=317a126bbae392c46b8bd699f8023a03f858d4d0;hpb=a92d9d6a21a0f6ca8d2153795721f500eaf29ee9;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 317a126bba..caee542152 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,69 +8,14 @@ package org.opendaylight.controller.netconf.util; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; - -import org.opendaylight.controller.netconf.api.NetconfMessage; -import org.opendaylight.controller.netconf.api.NetconfSession; -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; +import org.opendaylight.controller.netconf.api.NetconfSession; 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); - } - - ch.pipeline().addLast("frameDecoder", NetconfMessageFactory.getDelimiterFrameDecoder()); - ch.pipeline().addLast(handlerFactory.getDecoders()); - initializeAfterDecoder(ch, promise); - ch.pipeline().addLast(handlerFactory.getEncoders()); - } + public abstract void initialize(SocketChannel ch, Promise promise); 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) }; - } - } }