X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2FNetconfServerDispatcher.java;h=de3dee14437b804fd18819bb20302a962fd213e2;hb=b80124e3f7b11cf2f5e5bd4a6b033d855ff4d0d4;hp=324da56ca58474ecc2b338e0b4e8a3cc29755d1f;hpb=a92d9d6a21a0f6ca8d2153795721f500eaf29ee9;p=controller.git 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 324da56ca5..de3dee1443 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,57 @@ 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 java.net.InetSocketAddress; import org.opendaylight.controller.netconf.impl.util.DeserializerExceptionHandler; -import org.opendaylight.controller.netconf.util.AbstractChannelInitializer; +import org.opendaylight.controller.netconf.nettyutil.AbstractChannelInitializer; 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 { +public class NetconfServerDispatcher extends AbstractDispatcher { private final ServerChannelInitializer initializer; - public NetconfServerDispatcher(final Optional maybeContext, - NetconfServerSessionNegotiatorFactory serverNegotiatorFactory, - NetconfServerSessionListenerFactory listenerFactory) { - this.initializer = new ServerChannelInitializer(maybeContext, serverNegotiatorFactory, listenerFactory); + public NetconfServerDispatcher(ServerChannelInitializer serverChannelInitializer, EventLoopGroup bossGroup, + EventLoopGroup workerGroup) { + super(bossGroup, workerGroup); + this.initializer = serverChannelInitializer; } - // FIXME change headers for all new source code files - - // 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 ServerChannelInitializer extends AbstractChannelInitializer { + public static class ServerChannelInitializer extends AbstractChannelInitializer { + + public static final String DESERIALIZER_EX_HANDLER_KEY = "deserializerExHandler"; private final NetconfServerSessionNegotiatorFactory negotiatorFactory; - private final NetconfServerSessionListenerFactory listenerFactory; - private ServerChannelInitializer(Optional maybeContext, - NetconfServerSessionNegotiatorFactory negotiatorFactory, - NetconfServerSessionListenerFactory listenerFactory) { - super(maybeContext); + + public ServerChannelInitializer(NetconfServerSessionNegotiatorFactory negotiatorFactory) { 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(null, ch, promise)); } }