package org.opendaylight.controller.netconf.impl;
+import com.google.common.annotations.VisibleForTesting;
+import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
+import io.netty.channel.local.LocalAddress;
+import io.netty.channel.local.LocalChannel;
+import io.netty.channel.local.LocalServerChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.util.concurrent.Promise;
+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 java.net.InetSocketAddress;
-
public class NetconfServerDispatcher extends AbstractDispatcher<NetconfServerSession, NetconfServerSessionListener> {
private final ServerChannelInitializer initializer;
this.initializer = serverChannelInitializer;
}
+ @VisibleForTesting
public ChannelFuture createServer(InetSocketAddress address) {
return super.createServer(address, new PipelineInitializer<NetconfServerSession>() {
});
}
+ public ChannelFuture createLocalServer(LocalAddress address) {
+ return super.createServer(address, LocalServerChannel.class, new ChannelPipelineInitializer<LocalChannel, NetconfServerSession>() {
+ @Override
+ public void initializeChannel(final LocalChannel ch, final Promise<NetconfServerSession> promise) {
+ initializer.initialize(ch, promise);
+ }
+ });
+ }
+
public static class ServerChannelInitializer extends AbstractChannelInitializer<NetconfServerSession> {
public static final String DESERIALIZER_EX_HANDLER_KEY = "deserializerExHandler";
}
@Override
- protected void initializeMessageDecoder(SocketChannel ch) {
+ protected void initializeMessageDecoder(Channel ch) {
super.initializeMessageDecoder(ch);
ch.pipeline().addLast(DESERIALIZER_EX_HANDLER_KEY, new DeserializerExceptionHandler());
}
@Override
- protected void initializeSessionNegotiator(SocketChannel ch, Promise<NetconfServerSession> promise) {
+ protected void initializeSessionNegotiator(Channel ch, Promise<NetconfServerSession> promise) {
ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR,
negotiatorFactory.getSessionNegotiator(null, ch, promise));
}
}
-
}