X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2FNetconfServerDispatcher.java;h=ee9009762e8cda9d3f2ac8896f2df8bced568f83;hp=c73840132f67856b296de749cbe60a961a6a2023;hb=b66923141fce710094cb8e61bf794f9f0e678f50;hpb=f8e25f0e3d6196b5d3625c94a52ed5a6ab3fe5a7 diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java index c73840132f..ee9009762e 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java @@ -8,64 +8,59 @@ package org.opendaylight.controller.netconf.impl; -import com.google.common.base.Optional; import io.netty.channel.ChannelFuture; +import io.netty.channel.EventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.util.concurrent.Promise; -import org.opendaylight.controller.netconf.api.NetconfSession; -import org.opendaylight.controller.netconf.impl.util.DeserializerExceptionHandler; -import org.opendaylight.controller.netconf.util.AbstractSslChannelInitializer; -import org.opendaylight.protocol.framework.AbstractDispatcher; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; import java.net.InetSocketAddress; -public class NetconfServerDispatcher extends AbstractDispatcher { +import org.opendaylight.controller.netconf.impl.util.DeserializerExceptionHandler; +import org.opendaylight.controller.netconf.util.AbstractChannelInitializer; +import org.opendaylight.protocol.framework.AbstractDispatcher; - private final ServerSslChannelInitializer initializer; +public class NetconfServerDispatcher extends AbstractDispatcher { - public NetconfServerDispatcher(final Optional maybeContext, - NetconfServerSessionNegotiatorFactory serverNegotiatorFactory, - NetconfServerSessionListenerFactory listenerFactory) { - this.initializer = new ServerSslChannelInitializer(maybeContext, serverNegotiatorFactory, listenerFactory); - } + private final ServerChannelInitializer initializer; - // FIXME change headers for all new source code files + public NetconfServerDispatcher(ServerChannelInitializer serverChannelInitializer, EventLoopGroup bossGroup, + EventLoopGroup workerGroup) { + super(bossGroup, workerGroup); + this.initializer = serverChannelInitializer; + } - // TODO test create server with same address twice public ChannelFuture createServer(InetSocketAddress address) { - return super.createServer(address, new PipelineInitializer() { + return super.createServer(address, new PipelineInitializer() { @Override - public void initializeChannel(final SocketChannel ch, final Promise promise) { + public void initializeChannel(final SocketChannel ch, final Promise promise) { initializer.initialize(ch, promise); } }); } - private static class ServerSslChannelInitializer extends AbstractSslChannelInitializer { + public static class ServerChannelInitializer extends AbstractChannelInitializer { + + public static final String DESERIALIZER_EX_HANDLER_KEY = "deserializerExHandler"; private final NetconfServerSessionNegotiatorFactory negotiatorFactory; private final NetconfServerSessionListenerFactory listenerFactory; - private ServerSslChannelInitializer(Optional maybeContext, - NetconfServerSessionNegotiatorFactory negotiatorFactory, + public ServerChannelInitializer(NetconfServerSessionNegotiatorFactory negotiatorFactory, NetconfServerSessionListenerFactory listenerFactory) { - super(maybeContext); this.negotiatorFactory = negotiatorFactory; this.listenerFactory = listenerFactory; } @Override - protected void initializeAfterDecoder(SocketChannel ch, Promise promise) { - ch.pipeline().addLast("deserializerExHandler", new DeserializerExceptionHandler()); - ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise)); + protected void initializeMessageDecoder(SocketChannel ch) { + super.initializeMessageDecoder(ch); + ch.pipeline().addLast(DESERIALIZER_EX_HANDLER_KEY, new DeserializerExceptionHandler()); } @Override - protected void initSslEngine(SSLEngine sslEngine) { - sslEngine.setUseClientMode(false); + protected void initializeSessionNegotiator(SocketChannel ch, Promise promise) { + ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR, negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise)); } }