X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fclient%2FTcpClientChannelInitializer.java;h=c241e17656736052b4cbe3bf48012c8891e02ea4;hb=6c911783fcdac163bb6efc8ff7dbf56cbfb2ad22;hp=7558758efebecccbfe82990905860ed1e236faa8;hpb=4c0c091813aea131d32dc70c5121a450eb9b7291;p=netconf.git diff --git a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TcpClientChannelInitializer.java b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TcpClientChannelInitializer.java index 7558758efe..c241e17656 100644 --- a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TcpClientChannelInitializer.java +++ b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TcpClientChannelInitializer.java @@ -17,7 +17,6 @@ import io.netty.util.concurrent.GenericFutureListener; import io.netty.util.concurrent.Promise; import java.net.SocketAddress; import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer; -import org.opendaylight.protocol.framework.SessionListenerFactory; class TcpClientChannelInitializer extends AbstractChannelInitializer { @@ -42,29 +41,24 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer> negotiationFutureListener; @Override - public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, - final ChannelPromise channelPromise) throws Exception { + public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, + final SocketAddress localAddress, + final ChannelPromise channelPromise) { connectPromise = channelPromise; ChannelPromise tcpConnectFuture = new DefaultChannelPromise(ch); - negotiationFutureListener = new GenericFutureListener>() { - @Override - public void operationComplete(final Future future) throws Exception { - if (future.isSuccess()) { - connectPromise.setSuccess(); - } + negotiationFutureListener = future -> { + if (future.isSuccess()) { + channelPromise.setSuccess(); } }; - tcpConnectFuture.addListener(new GenericFutureListener>() { - @Override - public void operationComplete(final Future future) throws Exception { - if(future.isSuccess()) { - //complete connection promise with netconf negotiation future - negotiationFuture.addListener(negotiationFutureListener); - } else { - connectPromise.setFailure(future.cause()); - } + tcpConnectFuture.addListener(future -> { + if (future.isSuccess()) { + //complete connection promise with netconf negotiation future + negotiationFuture.addListener(negotiationFutureListener); + } else { + channelPromise.setFailure(future.cause()); } }); ctx.connect(remoteAddress, localAddress, tcpConnectFuture); @@ -72,14 +66,19 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer promise) { ch.pipeline().addAfter(NETCONF_MESSAGE_DECODER, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR, - negotiatorFactory.getSessionNegotiator(new SessionListenerFactory() { - @Override - public NetconfClientSessionListener getSessionListener() { - return sessionListener; - } - }, ch, promise)); + negotiatorFactory.getSessionNegotiator(() -> sessionListener, ch, promise)); } }