X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2Fssh%2FSshHandler.java;fp=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2Fssh%2FSshHandler.java;h=49d5a05ae22a6939f992c4637f123f550fb3a4e7;hp=0d9096c02a3abd1b33204665cb72dc4cbd10e805;hb=b925756421ea8565637d8575d8143dbf46db5a86;hpb=81387f0ae5898b196a54493f9bf4305993f39d1c diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java index 0d9096c02a..49d5a05ae2 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java @@ -29,6 +29,8 @@ import org.opendaylight.controller.netconf.util.handler.ssh.virtualsocket.Virtua * stops at instance of this class. All downstream events are handed of to wrapped {@link org.opendaylight.controller.netconf.util.handler.ssh.client.SshClientAdapter}; */ public class SshHandler extends ChannelOutboundHandlerAdapter { + private static final String SOCKET = "socket"; + private final VirtualSocket virtualSocket = new VirtualSocket(); private final SshClientAdapter sshClientAdapter; @@ -39,20 +41,20 @@ public class SshHandler extends ChannelOutboundHandlerAdapter { @Override public void handlerAdded(ChannelHandlerContext ctx){ - if (ctx.channel().pipeline().get("socket") == null) { - ctx.channel().pipeline().addFirst("socket", virtualSocket); + if (ctx.channel().pipeline().get(SOCKET) == null) { + ctx.channel().pipeline().addFirst(SOCKET, virtualSocket); } } @Override - public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { - if (ctx.channel().pipeline().get("socket") != null) { - ctx.channel().pipeline().remove("socket"); + public void handlerRemoved(ChannelHandlerContext ctx) { + if (ctx.channel().pipeline().get(SOCKET) != null) { + ctx.channel().pipeline().remove(SOCKET); } } @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws IOException { this.sshClientAdapter.write((ByteBuf) msg); } @@ -60,18 +62,18 @@ public class SshHandler extends ChannelOutboundHandlerAdapter { public void connect(final ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, - ChannelPromise promise) throws Exception { + ChannelPromise promise) { ctx.connect(remoteAddress, localAddress, promise); promise.addListener(new ChannelFutureListener() { - public void operationComplete(ChannelFuture channelFuture) throws Exception { + public void operationComplete(ChannelFuture channelFuture) { sshClientAdapter.start(ctx); }} ); } @Override - public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { + public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) { sshClientAdapter.stop(promise); } }