Deprecate websocket-client 47/51847/2
authorRobert Varga <rovarga@cisco.com>
Tue, 14 Feb 2017 09:28:15 +0000 (10:28 +0100)
committerRobert Varga <rovarga@cisco.com>
Wed, 15 Feb 2017 12:50:09 +0000 (13:50 +0100)
This component is no longer used anywhere and has no place in yangtools,
deprecate it, pending removal in 2.0.0.

Change-Id: I0b58fa7576798e4224be1f3f04fc5d49b9ed2290
Signed-off-by: Robert Varga <rovarga@cisco.com>
websocket/websocket-client/src/main/java/org/opendaylight/yangtools/websocket/client/WebSocketClientHandler.java
websocket/websocket-client/src/main/java/org/opendaylight/yangtools/websocket/client/WebSocketIClient.java
websocket/websocket-client/src/main/java/org/opendaylight/yangtools/websocket/client/callback/ClientMessageCallback.java
websocket/websocket-client/src/test/java/org/opendaylight/yangtools/websocket/WebSocketClientTest.java
websocket/websocket-client/src/test/java/org/opendaylight/yangtools/websocket/server/WebSocketServer.java
websocket/websocket-client/src/test/java/org/opendaylight/yangtools/websocket/server/WebSocketServerHandler.java
websocket/websocket-client/src/test/java/org/opendaylight/yangtools/websocket/server/WebSocketServerInitializer.java

index 8c1acc1c38e53d8ab93d5c1f2f6e5b6392a7a0e3..451a9d203b7a6544872e71ece37e33f17f06dd05 100644 (file)
@@ -27,14 +27,17 @@ import org.slf4j.LoggerFactory;
  * {@link WebSocketClientHandler} is implementation of
  * {@link SimpleChannelInboundHandler} which handle {@link TextWebSocketFrame},
  * {@link PongWebSocketFrame} and {@link CloseWebSocketFrame} messages.
+ *
+ * @deprecated This code is deprecated without replacement.
  */
+@Deprecated
 public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object> {
 
-    private static final Logger LOGGER = LoggerFactory
-            .getLogger(WebSocketClientHandler.class.toString());
+    private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketClientHandler.class.toString());
     private final WebSocketClientHandshaker handshaker;
+    private final ClientMessageCallback messageListener;
+
     private ChannelPromise handshakeFuture;
-    private ClientMessageCallback messageListener;
 
     /**
      * Create new Web Socket Client Handler.
@@ -45,8 +48,7 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object>
      *
      *
      */
-    public WebSocketClientHandler(WebSocketClientHandshaker handshaker,
-            ClientMessageCallback listener) {
+    public WebSocketClientHandler(final WebSocketClientHandshaker handshaker, final ClientMessageCallback listener) {
         this.handshaker = handshaker;
         this.messageListener = listener;
     }
@@ -61,22 +63,22 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object>
     }
 
     @Override
-    public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
+    public void handlerAdded(final ChannelHandlerContext ctx) throws Exception {
         handshakeFuture = ctx.newPromise();
     }
 
     @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+    public void channelActive(final ChannelHandlerContext ctx) throws Exception {
         handshaker.handshake(ctx.channel());
     }
 
     @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+    public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
         LOGGER.info("WebSocket Client disconnected!");
     }
 
     @Override
-    public void channelRead0(ChannelHandlerContext ctx, Object msg)
+    public void channelRead0(final ChannelHandlerContext ctx, final Object msg)
             throws Exception {
         Channel ch = ctx.channel();
         if (!handshaker.isHandshakeComplete()) {
@@ -111,7 +113,7 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object>
     }
 
     @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
+    public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause)
             throws Exception {
         if (!handshakeFuture.isDone()) {
             handshakeFuture.setFailure(cause);
index b26f5003b8720f144c84a3e476b0a7d1e44cbe7e..e113fb63784d0152dedda7c992e22cfe98c320b5 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.websocket.client;
 
+import com.google.common.base.Preconditions;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.Channel;
@@ -24,16 +25,15 @@ import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
 import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
 import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
 import io.netty.handler.codec.http.websocketx.WebSocketVersion;
-
 import java.net.URI;
-
 import org.opendaylight.yangtools.websocket.client.callback.ClientMessageCallback;
 
-import com.google.common.base.Preconditions;
-
 /**
  * Implementation of web socket client that supports WS and HTTP protocols.
+ *
+ * @deprecated This code is deprecated without replacement.
  */
+@Deprecated
 public class WebSocketIClient {
     private final EventLoopGroup group = new NioEventLoopGroup();
     private final Bootstrap bootstrap = new Bootstrap();
@@ -52,10 +52,8 @@ public class WebSocketIClient {
     public WebSocketIClient(final URI uri, final ClientMessageCallback clientMessageCallback) {
         this.uri = Preconditions.checkNotNull(uri);
         clientHandler = new WebSocketClientHandler(
-                WebSocketClientHandshakerFactory.newHandshaker(uri,
-                        WebSocketVersion.V13, null, false, null),
-                clientMessageCallback); // last null could be replaced with
-                                        // DefaultHttpHeaders
+                WebSocketClientHandshakerFactory.newHandshaker(uri, WebSocketVersion.V13, null, false, null),
+                clientMessageCallback); // last null could be replaced with DefaultHttpHeaders
         initialize();
     }
 
index 12916280cd5149e7323b71ccf438b9cd9fa79224..1617e735f2c6c9ad8bbea3e60762f7650f04fa8c 100644 (file)
@@ -9,7 +9,10 @@ package org.opendaylight.yangtools.websocket.client.callback;
 
 /**
  * {@link ClientMessageCallback} notifies client that some event has occurred.
+ *
+ * @deprecated This code is deprecated without replacement.
  */
+@Deprecated
 public interface ClientMessageCallback {
 
     /**
index 5718e5a8c567c3b46817d1adbc5695a61e048e70..b8548bf287dc1c3087fc16949a4a00795c44947c 100644 (file)
@@ -7,27 +7,22 @@
  */
 package org.opendaylight.yangtools.websocket;
 
+import com.google.common.util.concurrent.SettableFuture;
+import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
 import java.net.URI;
 import java.net.URISyntaxException;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.opendaylight.yangtools.websocket.client.WebSocketIClient;
 import org.opendaylight.yangtools.websocket.server.WebSocketServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
-
-import com.google.common.util.concurrent.SettableFuture;
-
+@Deprecated
 public class WebSocketClientTest {
     private static final Logger logger = LoggerFactory.getLogger(WebSocketClientTest.class.toString());
     private static final String MESSAGE = "Take me to your leader!";
@@ -36,7 +31,7 @@ public class WebSocketClientTest {
     /**
      * Tracks if the message from the server has been received
      */
-    private SettableFuture<Boolean> messageReceived = SettableFuture.create();
+    private final SettableFuture<Boolean> messageReceived = SettableFuture.create();
 
     /**
      * Tracks the port on which the server is listening
@@ -93,7 +88,7 @@ public class WebSocketClientTest {
 
     private class ClientMessageCallback implements org.opendaylight.yangtools.websocket.client.callback.ClientMessageCallback {
         @Override
-        public void onMessageReceived(Object message) {
+        public void onMessageReceived(final Object message) {
             logger.info("received message {}",message);
             messageReceived.set(true);
         }
index 2ba02b7bce3846618dcde10e67e621e4e304b957..819734b64c9d6f4bd87897f33ae5ee1f56230cad 100644 (file)
 package org.opendaylight.yangtools.websocket.server;
 
 import com.google.common.util.concurrent.SettableFuture;
-
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.Channel;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.nio.NioServerSocketChannel;
-
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,6 +47,7 @@ import org.slf4j.LoggerFactory;
  * <li>Firefox 11+ (RFC 6455 aka draft-ietf-hybi-thewebsocketprotocol-17)
  * </ul>
  */
+@Deprecated
 public class WebSocketServer implements Runnable {
 
     /**
index bf1a10533ad2647cc1cd6abf0e76c9f046d5b19a..f5771f9131638b19464373fcbd7e7429b47accad 100644 (file)
  */
 package org.opendaylight.yangtools.websocket.server;
 
+import static io.netty.handler.codec.http.HttpHeaders.isKeepAlive;
+import static io.netty.handler.codec.http.HttpHeaders.setContentLength;
+import static io.netty.handler.codec.http.HttpHeaders.Names.HOST;
+import static io.netty.handler.codec.http.HttpMethod.GET;
+import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
+import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
+import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelFuture;
@@ -34,17 +42,11 @@ import io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory;
 import io.netty.util.CharsetUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import static io.netty.handler.codec.http.HttpHeaders.Names.HOST;
-import static io.netty.handler.codec.http.HttpHeaders.isKeepAlive;
-import static io.netty.handler.codec.http.HttpHeaders.setContentLength;
-import static io.netty.handler.codec.http.HttpMethod.GET;
-import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
-import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
-import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
 
 /**
  * Handles handshakes and messages
  */
+@Deprecated
 public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object> {
     private static final Logger logger = LoggerFactory.getLogger(WebSocketServerHandler.class.getName());
 
@@ -53,7 +55,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
     private WebSocketServerHandshaker handshaker;
 
     @Override
-    public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
+    public void channelRead0(final ChannelHandlerContext ctx, final Object msg) throws Exception {
         if (msg instanceof FullHttpRequest) {
             handleHttpRequest(ctx, (FullHttpRequest) msg);
         } else if (msg instanceof WebSocketFrame) {
@@ -62,11 +64,11 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
     }
 
     @Override
-    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+    public void channelReadComplete(final ChannelHandlerContext ctx) throws Exception {
         ctx.flush();
     }
 
-    private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
+    private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) throws Exception {
         // Handle a bad request.
         if (!req.getDecoderResult().isSuccess()) {
             sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
@@ -91,7 +93,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
         }
     }
 
-    private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
+    private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame frame) {
 
         // Check for closing frame
         if (frame instanceof CloseWebSocketFrame) {
@@ -114,7 +116,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
     }
 
     private static void sendHttpResponse(
-            ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) {
+            final ChannelHandlerContext ctx, final FullHttpRequest req, final FullHttpResponse res) {
         // Generate an error page if response getStatus code is not OK (200).
         if (res.getStatus().code() != 200) {
             ByteBuf buf = Unpooled.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8);
@@ -131,12 +133,12 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
     }
 
     @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+    public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
         logger.info("Exception caught {}",cause);
         ctx.close();
     }
 
-    private static String getWebSocketLocation(FullHttpRequest req) {
+    private static String getWebSocketLocation(final FullHttpRequest req) {
         return "ws://" + req.headers().get(HOST) + WEBSOCKET_PATH;
     }
 
index 4c7f0ce92f07a190a8ba7206b29f108e4f12f4e9..eb15971a1f470d77d9da4c6dd8c61ba17f4b46e8 100644 (file)
@@ -20,11 +20,11 @@ import io.netty.channel.ChannelPipeline;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.handler.codec.http.HttpObjectAggregator;
 import io.netty.handler.codec.http.HttpServerCodec;
-import org.opendaylight.yangtools.websocket.server.WebSocketServerHandler;
 
+@Deprecated
 public class WebSocketServerInitializer extends ChannelInitializer<SocketChannel> {
     @Override
-    public void initChannel(SocketChannel ch) throws Exception {
+    public void initChannel(final SocketChannel ch) throws Exception {
         ChannelPipeline pipeline = ch.pipeline();
         pipeline.addLast("codec-http", new HttpServerCodec());
         pipeline.addLast("aggregator", new HttpObjectAggregator(65536));