Permalink
Browse files

[#873] [#868] Split ChannelFuture into ChannelFuture and ChannelPromise

  • Loading branch information...
1 parent 0909878 commit 4e77bacdf793dc647552a3c21b75da04a2eba20b @normanmaurer normanmaurer committed with trustin Dec 30, 2012
Showing with 1,189 additions and 1,096 deletions.
  1. +5 −4 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java
  2. +5 −4 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java
  3. +5 −4 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java
  4. +5 −4 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java
  5. +5 −4 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java
  6. +9 −8 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java
  7. +7 −6 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java
  8. +6 −5 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker07.java
  9. +8 −7 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java
  10. +8 −7 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java
  11. +12 −11 codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java
  12. +2 −1 ...http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java
  13. +3 −3 codec/src/main/java/io/netty/handler/codec/ByteToByteCodec.java
  14. +3 −3 codec/src/main/java/io/netty/handler/codec/ByteToByteEncoder.java
  15. +3 −3 codec/src/main/java/io/netty/handler/codec/ByteToMessageCodec.java
  16. +3 −3 codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java
  17. +2 −2 codec/src/main/java/io/netty/handler/codec/MessageToMessageCodec.java
  18. +3 −3 codec/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java
  19. +9 −8 codec/src/main/java/io/netty/handler/codec/compression/JZlibEncoder.java
  20. +12 −11 codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
  21. +2 −1 codec/src/main/java/io/netty/handler/codec/compression/ZlibEncoder.java
  22. +3 −3 codec/src/main/java/io/netty/handler/codec/sctp/SctpOutboundByteStreamHandler.java
  23. +3 −2 example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClientHandler.java
  24. +3 −3 handler/src/main/java/io/netty/handler/logging/ByteLoggingHandler.java
  25. +13 −13 handler/src/main/java/io/netty/handler/logging/LoggingHandler.java
  26. +3 −3 handler/src/main/java/io/netty/handler/logging/MessageLoggingHandler.java
  27. +69 −48 handler/src/main/java/io/netty/handler/ssl/SslHandler.java
  28. +7 −6 handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java
  29. +18 −16 handler/src/main/java/io/netty/handler/timeout/IdleStateHandler.java
  30. +9 −8 handler/src/main/java/io/netty/handler/timeout/WriteTimeoutHandler.java
  31. +5 −5 handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java
  32. +4 −3 transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java
  33. +4 −3 transport/src/main/java/io/netty/bootstrap/Bootstrap.java
  34. +2 −1 transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java
  35. +105 −85 transport/src/main/java/io/netty/channel/AbstractChannel.java
  36. +6 −6 transport/src/main/java/io/netty/channel/AbstractServerChannel.java
  37. +18 −18 transport/src/main/java/io/netty/channel/Channel.java
  38. +14 −14 ...c/main/java/io/netty/channel/{ChannelFlushFutureNotifier.java → ChannelFlushPromiseNotifier.java}
  39. +2 −52 transport/src/main/java/io/netty/channel/ChannelFuture.java
  40. +14 −14 transport/src/main/java/io/netty/channel/ChannelHandlerAdapter.java
  41. +14 −14 transport/src/main/java/io/netty/channel/ChannelOperationHandler.java
  42. +21 −21 transport/src/main/java/io/netty/channel/ChannelOperationHandlerAdapter.java
  43. +26 −26 transport/src/main/java/io/netty/channel/ChannelOutboundInvoker.java
  44. +102 −0 transport/src/main/java/io/netty/channel/ChannelPromise.java
  45. +18 −23 ...ort/src/main/java/io/netty/channel/{ChannelFutureAggregator.java → ChannelPromiseAggregator.java}
  46. +15 −26 transport/src/main/java/io/netty/channel/{ChannelFutureNotifier.java → ChannelPromiseNotifier.java}
  47. +2 −2 transport/src/main/java/io/netty/channel/ChannelPropertyAccess.java
  48. +14 −14 transport/src/main/java/io/netty/channel/CombinedChannelHandler.java
  49. +2 −32 transport/src/main/java/io/netty/channel/CompleteChannelFuture.java
  50. +84 −0 transport/src/main/java/io/netty/channel/CompleteChannelPromise.java
  51. +31 −31 transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java
  52. +90 −90 transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java
  53. +88 −109 transport/src/main/java/io/netty/channel/{DefaultChannelFuture.java → DefaultChannelPromise.java}
  54. +1 −1 transport/src/main/java/io/netty/channel/EventLoopGroup.java
  55. +0 −13 transport/src/main/java/io/netty/channel/FailedChannelFuture.java
  56. +2 −2 transport/src/main/java/io/netty/channel/MultithreadEventLoopGroup.java
  57. +7 −7 transport/src/main/java/io/netty/channel/SingleThreadEventLoop.java
  58. +0 −13 transport/src/main/java/io/netty/channel/SucceededChannelFuture.java
  59. +16 −31 transport/src/main/java/io/netty/channel/{VoidChannelFuture.java → VoidChannelPromise.java}
  60. +3 −3 transport/src/main/java/io/netty/channel/embedded/AbstractEmbeddedChannel.java
  61. +5 −4 transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java
  62. +11 −11 transport/src/main/java/io/netty/channel/local/LocalChannel.java
  63. +9 −8 transport/src/main/java/io/netty/channel/socket/DatagramChannel.java
  64. +3 −2 transport/src/main/java/io/netty/channel/socket/SctpChannel.java
  65. +3 −2 transport/src/main/java/io/netty/channel/socket/SocketChannel.java
  66. +17 −17 transport/src/main/java/io/netty/channel/socket/aio/AbstractAioChannel.java
  67. +2 −1 transport/src/main/java/io/netty/channel/socket/aio/AioEventLoop.java
  68. +3 −3 transport/src/main/java/io/netty/channel/socket/aio/AioServerSocketChannel.java
  69. +21 −20 transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java
  70. +13 −13 transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java
  71. +15 −15 transport/src/main/java/io/netty/channel/socket/nio/AbstractNioChannel.java
  72. +36 −35 transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java
  73. +13 −12 transport/src/main/java/io/netty/channel/socket/nio/NioSctpChannel.java
  74. +7 −6 transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java
  75. +6 −6 transport/src/main/java/io/netty/channel/socket/oio/AbstractOioChannel.java
  76. +33 −32 transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java
  77. +3 −2 transport/src/main/java/io/netty/channel/socket/oio/OioEventLoop.java
  78. +8 −5 transport/src/main/java/io/netty/channel/socket/oio/OioEventLoopGroup.java
  79. +13 −12 transport/src/main/java/io/netty/channel/socket/oio/OioSctpChannel.java
  80. +6 −5 transport/src/main/java/io/netty/channel/socket/oio/OioSocketChannel.java
  81. +0 −15 transport/src/test/java/io/netty/channel/CompleteChannelFutureTest.java
  82. +1 −1 transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java
  83. +6 −6 transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java
@@ -17,6 +17,7 @@
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.HttpResponse;
import java.net.URI;
@@ -126,18 +127,18 @@ public ChannelFuture handshake(Channel channel) {
if (channel == null) {
throw new NullPointerException("channel");
}
- return handshake(channel, channel.newFuture());
+ return handshake(channel, channel.newPromise());
}
/**
* Begins the opening handshake
*
* @param channel
* Channel
- * @param future
- * the {@link ChannelFuture} to be notified when the opening handshake is sent
+ * @param promise
+ * the {@link ChannelPromise} to be notified when the opening handshake is sent
*/
- public abstract ChannelFuture handshake(Channel channel, ChannelFuture future);
+ public abstract ChannelFuture handshake(Channel channel, ChannelPromise promise);
/**
* Validates and finishes the opening handshake initiated by {@link #handshake}}.
@@ -20,6 +20,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values;
@@ -91,7 +92,7 @@ public WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, S
* Channel into which we can write our request
*/
@Override
- public ChannelFuture handshake(Channel channel, final ChannelFuture handshakeFuture) {
+ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
// Make keys
int spaces1 = WebSocketUtil.randomNumber(1, 12);
int spaces2 = WebSocketUtil.randomNumber(1, 12);
@@ -183,14 +184,14 @@ public void operationComplete(ChannelFuture future) {
"ws-encoder", new WebSocket00FrameEncoder());
if (future.isSuccess()) {
- handshakeFuture.setSuccess();
+ promise.setSuccess();
} else {
- handshakeFuture.setFailure(future.cause());
+ promise.setFailure(future.cause());
}
}
});
- return handshakeFuture;
+ return promise;
}
/**
@@ -19,6 +19,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values;
@@ -97,7 +98,7 @@ public WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, S
* Channel into which we can write our request
*/
@Override
- public ChannelFuture handshake(Channel channel, final ChannelFuture handshakeFuture) {
+ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
// Get path
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
@@ -161,14 +162,14 @@ public void operationComplete(ChannelFuture future) {
"ws-encoder", new WebSocket07FrameEncoder(true));
if (future.isSuccess()) {
- handshakeFuture.setSuccess();
+ promise.setSuccess();
} else {
- handshakeFuture.setFailure(future.cause());
+ promise.setFailure(future.cause());
}
}
});
- return handshakeFuture;
+ return promise;
}
/**
@@ -19,6 +19,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values;
@@ -97,7 +98,7 @@ public WebSocketClientHandshaker08(URI webSocketURL, WebSocketVersion version, S
* Channel into which we can write our request
*/
@Override
- public ChannelFuture handshake(Channel channel, final ChannelFuture handshakeFuture) {
+ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
// Get path
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
@@ -161,14 +162,14 @@ public void operationComplete(ChannelFuture future) {
"ws-encoder", new WebSocket08FrameEncoder(true));
if (future.isSuccess()) {
- handshakeFuture.setSuccess();
+ promise.setSuccess();
} else {
- handshakeFuture.setFailure(future.cause());
+ promise.setFailure(future.cause());
}
}
});
- return handshakeFuture;
+ return promise;
}
/**
@@ -19,6 +19,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values;
@@ -97,7 +98,7 @@ public WebSocketClientHandshaker13(URI webSocketURL, WebSocketVersion version, S
* Channel into which we can write our request
*/
@Override
- public ChannelFuture handshake(Channel channel, final ChannelFuture handshakeFuture) {
+ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
// Get path
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
@@ -161,13 +162,13 @@ public void operationComplete(ChannelFuture future) {
"ws-encoder", new WebSocket13FrameEncoder(true));
if (future.isSuccess()) {
- handshakeFuture.setSuccess();
+ promise.setSuccess();
} else {
- handshakeFuture.setFailure(future.cause());
+ promise.setFailure(future.cause());
}
}
});
- return handshakeFuture;
+ return promise;
}
/**
@@ -17,6 +17,7 @@
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.util.internal.StringUtil;
@@ -115,7 +116,7 @@ public ChannelFuture handshake(Channel channel, HttpRequest req) {
if (channel == null) {
throw new NullPointerException("channel");
}
- return handshake(channel, req, channel.newFuture());
+ return handshake(channel, req, channel.newPromise());
}
/**
@@ -125,10 +126,10 @@ public ChannelFuture handshake(Channel channel, HttpRequest req) {
* Channel
* @param req
* HTTP Request
- * @param future
- * the {@link ChannelFuture} to be notified when the opening handshake is done
+ * @param promise
+ * the {@link ChannelPromise} to be notified when the opening handshake is done
*/
- public abstract ChannelFuture handshake(Channel channel, HttpRequest req, ChannelFuture future);
+ public abstract ChannelFuture handshake(Channel channel, HttpRequest req, ChannelPromise promise);
/**
* Performs the closing handshake
@@ -142,7 +143,7 @@ public ChannelFuture close(Channel channel, CloseWebSocketFrame frame) {
if (channel == null) {
throw new NullPointerException("channel");
}
- return close(channel, frame, channel.newFuture());
+ return close(channel, frame, channel.newPromise());
}
/**
@@ -152,10 +153,10 @@ public ChannelFuture close(Channel channel, CloseWebSocketFrame frame) {
* Channel
* @param frame
* Closing Frame that was received
- * @param future
- * the {@link ChannelFuture} to be notified when the closing handshake is done
+ * @param promise
+ * the {@link ChannelPromise} to be notified when the closing handshake is done
*/
- public abstract ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelFuture future);
+ public abstract ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise);
/**
* Selects the first matching supported sub protocol
@@ -21,6 +21,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.HttpChunkAggregator;
import io.netty.handler.codec.http.HttpHeaders.Names;
@@ -118,7 +119,7 @@ public WebSocketServerHandshaker00(String webSocketURL, String subprotocols, int
* HTTP request
*/
@Override
- public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelFuture future) {
+ public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelPromise promise) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Channel %s WS Version 00 server handshake", channel.id()));
@@ -180,8 +181,8 @@ public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelFuture f
}
// Upgrade the connection and send the handshake response.
- channel.write(res, future);
- future.addListener(new ChannelFutureListener() {
+ channel.write(res, promise);
+ promise.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.channel().pipeline();
@@ -195,7 +196,7 @@ public void operationComplete(ChannelFuture future) {
}
});
- return future;
+ return promise;
}
/**
@@ -207,7 +208,7 @@ public void operationComplete(ChannelFuture future) {
* Web Socket frame that was received
*/
@Override
- public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelFuture future) {
- return channel.write(frame, future);
+ public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise) {
+ return channel.write(frame, promise);
}
}
@@ -19,6 +19,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.HttpChunkAggregator;
import io.netty.handler.codec.http.HttpHeaders.Names;
@@ -108,7 +109,7 @@ public WebSocketServerHandshaker07(
* HTTP request
*/
@Override
- public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelFuture future) {
+ public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelPromise promise) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Channel %s WS Version 7 server handshake", channel.id()));
@@ -143,10 +144,10 @@ public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelFuture f
}
}
- channel.write(res, future);
+ channel.write(res, promise);
// Upgrade the connection and send the handshake response.
- future.addListener(new ChannelFutureListener() {
+ promise.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.channel().pipeline();
@@ -160,7 +161,7 @@ public void operationComplete(ChannelFuture future) {
}
});
- return future;
+ return promise;
}
/**
@@ -172,7 +173,7 @@ public void operationComplete(ChannelFuture future) {
* Web Socket frame that was received
*/
@Override
- public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelFuture future) {
+ public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise future) {
future.addListener(ChannelFutureListener.CLOSE);
return channel.write(frame, future);
}
@@ -19,6 +19,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.HttpChunkAggregator;
import io.netty.handler.codec.http.HttpHeaders.Names;
@@ -109,7 +110,7 @@ public WebSocketServerHandshaker08(
* HTTP request
*/
@Override
- public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelFuture future) {
+ public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelPromise promise) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Channel %s WS Version 8 server handshake", channel.id()));
@@ -144,10 +145,10 @@ public ChannelFuture handshake(Channel channel, HttpRequest req, ChannelFuture f
}
}
- channel.write(res, future);
+ channel.write(res, promise);
// Upgrade the connection and send the handshake response.
- future.addListener(new ChannelFutureListener() {
+ promise.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.channel().pipeline();
@@ -161,7 +162,7 @@ public void operationComplete(ChannelFuture future) {
}
});
- return future;
+ return promise;
}
/**
@@ -173,8 +174,8 @@ public void operationComplete(ChannelFuture future) {
* Web Socket frame that was received
*/
@Override
- public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelFuture future) {
- future.addListener(ChannelFutureListener.CLOSE);
- return channel.write(frame, future);
+ public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise) {
+ promise.addListener(ChannelFutureListener.CLOSE);
+ return channel.write(frame, promise);
}
}
Oops, something went wrong.

0 comments on commit 4e77bac

Please sign in to comment.