* // The composite type is compatible with the component type.
- * {@link ByteBuf} message = {@link Unpooled}.wrappedBuffer(header, body);
+ * {@link io.netty.buffer.ByteBuf} message = {@link io.netty.buffer.Unpooled}.wrappedBuffer(header, body);
*
* // Therefore, you can even create a composite by mixing a composite and an
* // ordinary buffer.
- * {@link ByteBuf} messageWithFooter = {@link Unpooled}.wrappedBuffer(message, footer);
+ * {@link io.netty.buffer.ByteBuf} messageWithFooter = {@link io.netty.buffer.Unpooled}.wrappedBuffer(message, footer);
*
- * // Because the composite is still a {@link ByteBuf}, you can access its content
+ * // Because the composite is still a {@link io.netty.buffer.ByteBuf}, you can access its content
* // easily, and the accessor method will behave just like it's a single buffer
* // even if the region you want to access spans over multiple components. The
* // unsigned integer being read here is located across body and footer.
@@ -100,7 +100,7 @@
*
* // A new dynamic buffer is created. Internally, the actual buffer is created
* // lazily to avoid potentially wasted memory space.
- * {@link ByteBuf} b = {@link Unpooled}.buffer(4);
+ * {@link io.netty.buffer.ByteBuf} b = {@link io.netty.buffer.Unpooled}.buffer(4);
*
* // When the first write attempt is made, the internal buffer is created with
* // the specified initial capacity (4).
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java
index e7a7610a9d..177b580cc5 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java
@@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.CombinedChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAppender;
import io.netty.handler.codec.PrematureChannelClosureException;
import java.util.ArrayDeque;
@@ -40,8 +40,7 @@ import java.util.concurrent.atomic.AtomicLong;
*
* @see HttpServerCodec
*/
-public final class HttpClientCodec
- extends CombinedChannelDuplexHandler {
+public final class HttpClientCodec extends ChannelHandlerAppender {
/** A queue that is used for correlating a request and a response. */
private final Queue queue = new ArrayDeque();
@@ -61,14 +60,6 @@ public final class HttpClientCodec
this(4096, 8192, 8192, false);
}
- public void setSingleDecode(boolean singleDecode) {
- inboundHandler().setSingleDecode(singleDecode);
- }
-
- public boolean isSingleDecode() {
- return inboundHandler().isSingleDecode();
- }
-
/**
* Creates a new instance with the specified decoder options.
*/
@@ -90,10 +81,22 @@ public final class HttpClientCodec
public HttpClientCodec(
int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
boolean validateHeaders) {
- init(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders), new Encoder());
+ add(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders), new Encoder());
this.failOnMissingResponse = failOnMissingResponse;
}
+ private Decoder decoder() {
+ return handlerAt(0);
+ }
+
+ public void setSingleDecode(boolean singleDecode) {
+ decoder().setSingleDecode(singleDecode);
+ }
+
+ public boolean isSingleDecode() {
+ return decoder().isSingleDecode();
+ }
+
private final class Encoder extends HttpRequestEncoder {
@Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java
index ad0d73bcc3..f4af2f5365 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java
@@ -16,7 +16,6 @@
package io.netty.handler.codec.http;
import io.netty.buffer.ByteBuf;
-import io.netty.util.CharsetUtil;
import static io.netty.handler.codec.http.HttpConstants.*;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java
index c10185a51b..0b14fa26e1 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java
@@ -15,7 +15,7 @@
*/
package io.netty.handler.codec.http;
-import io.netty.channel.CombinedChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAppender;
/**
@@ -24,8 +24,7 @@ import io.netty.channel.CombinedChannelDuplexHandler;
*
* @see HttpClientCodec
*/
-public final class HttpServerCodec
- extends CombinedChannelDuplexHandler {
+public final class HttpServerCodec extends ChannelHandlerAppender {
/**
* Creates a new instance with the default decoder options
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java
index 40dd991b3d..fc8e4e38a0 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandler.java
@@ -15,8 +15,8 @@
*/
package io.netty.handler.codec.http.websocketx;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpHeaders;
@@ -34,7 +34,7 @@ import java.util.List;
* This implementation will establish the websocket connection once the connection to the remote server was complete.
*
* To know once a handshake was done you can intercept the
- * {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)} and check if the event was of type
+ * {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)} and check if the event was of type
* {@link ClientHandshakeStateEvent#HANDSHAKE_ISSUED} or {@link ClientHandshakeStateEvent#HANDSHAKE_COMPLETE}.
*/
public class WebSocketClientProtocolHandler extends WebSocketProtocolHandler {
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java
index 1ea168c543..27165a1bc7 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java
@@ -17,11 +17,11 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.http.FullHttpResponse;
-class WebSocketClientProtocolHandshakeHandler extends ChannelInboundHandlerAdapter {
+class WebSocketClientProtocolHandshakeHandler extends ChannelHandlerAdapter {
private final WebSocketClientHandshaker handshaker;
public WebSocketClientProtocolHandshakeHandler(WebSocketClientHandshaker handshaker) {
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameDecoder.java
index 8c8142ec4e..6ba5356e79 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameDecoder.java
@@ -15,7 +15,7 @@
*/
package io.netty.handler.codec.http.websocketx;
-import io.netty.channel.ChannelInboundHandler;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
/**
@@ -23,5 +23,4 @@ import io.netty.channel.ChannelPipeline;
*
* This makes it easier to access the added encoder later in the {@link ChannelPipeline}.
*/
-public interface WebSocketFrameDecoder extends ChannelInboundHandler {
-}
+public interface WebSocketFrameDecoder extends ChannelHandler { }
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameEncoder.java
index da1df6b394..f33c4cd80b 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameEncoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrameEncoder.java
@@ -15,7 +15,7 @@
*/
package io.netty.handler.codec.http.websocketx;
-import io.netty.channel.ChannelOutboundHandler;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
/**
@@ -23,5 +23,5 @@ import io.netty.channel.ChannelPipeline;
*
* This makes it easier to access the added encoder later in the {@link ChannelPipeline}.
*/
-public interface WebSocketFrameEncoder extends ChannelOutboundHandler {
+public interface WebSocketFrameEncoder extends ChannelHandler {
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java
index 378398c359..c21694b7f1 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java
@@ -18,9 +18,8 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpRequest;
@@ -45,7 +44,7 @@ import static io.netty.handler.codec.http.HttpVersion.*;
* to the io.netty.example.http.websocketx.server.WebSocketServer example.
*
* To know once a handshake was done you can intercept the
- * {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)} and check if the event was of type
+ * {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)} and check if the event was of type
* {@link ServerHandshakeStateEvent#HANDSHAKE_COMPLETE}.
*/
public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {
@@ -122,7 +121,7 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {
}
static ChannelHandler forbiddenHttpRequestResponder() {
- return new ChannelInboundHandlerAdapter() {
+ return new ChannelHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpRequest) {
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java
index 5dfb065c5c..bcd2531eb7 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java
@@ -17,8 +17,8 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpRequest;
@@ -35,8 +35,7 @@ import static io.netty.handler.codec.http.HttpVersion.*;
/**
* Handles the HTTP handshake (the HTTP Upgrade request) for {@link WebSocketServerProtocolHandler}.
*/
-class WebSocketServerProtocolHandshakeHandler
- extends ChannelInboundHandlerAdapter {
+class WebSocketServerProtocolHandshakeHandler extends ChannelHandlerAdapter {
private final String websocketPath;
private final String subprotocols;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java
index 41c64d2a8d..b663a7ecfd 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java
@@ -16,7 +16,6 @@
package io.netty.handler.codec.spdy;
import io.netty.buffer.ByteBuf;
-import io.netty.util.CharsetUtil;
final class SpdyCodecUtil {
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java
index e0b40bd9a4..fbbd70aa10 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java
@@ -15,12 +15,12 @@
*/
package io.netty.handler.codec.spdy;
-import io.netty.channel.CombinedChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAppender;
/**
* A combination of {@link SpdyFrameDecoder} and {@link SpdyFrameEncoder}.
*/
-public final class SpdyFrameCodec extends CombinedChannelDuplexHandler {
+public final class SpdyFrameCodec extends ChannelHandlerAppender {
/**
* Creates a new instance with the specified {@code version} and
* the default decoder and encoder options
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpCodec.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpCodec.java
index efb2dd426d..4d7ab23353 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpCodec.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpCodec.java
@@ -15,13 +15,12 @@
*/
package io.netty.handler.codec.spdy;
-import io.netty.channel.CombinedChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAppender;
/**
* A combination of {@link SpdyHttpDecoder} and {@link SpdyHttpEncoder}
*/
-public final class SpdyHttpCodec
- extends CombinedChannelDuplexHandler {
+public final class SpdyHttpCodec extends ChannelHandlerAppender {
/**
* Creates a new instance with the specified decoder options.
*/
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java
index 717182b5e9..75203b761d 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java
@@ -18,7 +18,6 @@ package io.netty.handler.codec.spdy;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.http.HttpObjectAggregator;
@@ -30,7 +29,7 @@ import javax.net.ssl.SSLEngine;
import java.util.List;
/**
- * {@link ChannelInboundHandler} which is responsible to setup the {@link ChannelPipeline} either for
+ * {@link ChannelHandler} which is responsible to setup the {@link ChannelPipeline} either for
* HTTP or SPDY. This offers an easy way for users to support both at the same time while not care to
* much about the low-level details.
*/
@@ -125,21 +124,21 @@ public abstract class SpdyOrHttpChooser extends ByteToMessageDecoder {
}
/**
- * Create the {@link ChannelInboundHandler} that is responsible for handling the http requests
+ * Create the {@link ChannelHandler} that is responsible for handling the http requests
* when the {@link SelectedProtocol} was {@link SelectedProtocol#HTTP_1_0} or
* {@link SelectedProtocol#HTTP_1_1}
*/
- protected abstract ChannelInboundHandler createHttpRequestHandlerForHttp();
+ protected abstract ChannelHandler createHttpRequestHandlerForHttp();
/**
- * Create the {@link ChannelInboundHandler} that is responsible for handling the http responses
+ * Create the {@link ChannelHandler} that is responsible for handling the http responses
* when the {@link SelectedProtocol} was {@link SelectedProtocol#SPDY_3} or
* {@link SelectedProtocol#SPDY_3_1}.
*
* By default this getMethod will just delecate to {@link #createHttpRequestHandlerForHttp()}, but
* sub-classes may override this to change the behaviour.
*/
- protected ChannelInboundHandler createHttpRequestHandlerForSpdy() {
+ protected ChannelHandler createHttpRequestHandlerForSpdy() {
return createHttpRequestHandlerForHttp();
}
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java
index 6a62ab7fb5..be70763cba 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java
@@ -15,22 +15,21 @@
*/
package io.netty.handler.codec.spdy;
-import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.util.internal.EmptyArrays;
import java.util.concurrent.atomic.AtomicInteger;
-import static io.netty.handler.codec.spdy.SpdyCodecUtil.SPDY_SESSION_STREAM_ID;
+import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
/**
* Manages streams within a SPDY session.
*/
-public class SpdySessionHandler
- extends ChannelDuplexHandler {
+public class SpdySessionHandler extends ChannelHandlerAdapter {
private static final SpdyProtocolException PROTOCOL_EXCEPTION = new SpdyProtocolException();
private static final SpdyProtocolException STREAM_CLOSED = new SpdyProtocolException("Stream closed");
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java
index 78373c73df..df37a8671f 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java
@@ -16,9 +16,8 @@
package io.netty.handler.codec.http.websocketx;
import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.http.DefaultFullHttpRequest;
@@ -143,7 +142,7 @@ public class WebSocketServerProtocolHandlerTest {
return new String(response.content().array());
}
- private class MockOutboundHandler extends ChannelOutboundHandlerAdapter {
+ private class MockOutboundHandler extends ChannelHandlerAdapter {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
@@ -156,7 +155,7 @@ public class WebSocketServerProtocolHandlerTest {
}
}
- private static class CustomTextFrameHandler extends ChannelInboundHandlerAdapter {
+ private static class CustomTextFrameHandler extends ChannelHandlerAdapter {
private String content;
@Override
diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java
index aec20912a5..e4cbb017bc 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java
@@ -18,8 +18,8 @@ package io.netty.handler.codec.spdy;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
@@ -128,7 +128,7 @@ public class SpdyFrameDecoderTest {
frame.headers().add(headerName.toString(), headerValue.toString());
}
- private static class CaptureHandler extends ChannelInboundHandlerAdapter {
+ private static class CaptureHandler extends ChannelHandlerAdapter {
public volatile Object message;
@Override
diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java
index 55346cbc32..9e13f49a51 100644
--- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java
@@ -15,8 +15,8 @@
*/
package io.netty.handler.codec.spdy;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -330,7 +330,7 @@ public class SpdySessionHandlerTest {
// Echo Handler opens 4 half-closed streams on session connection
// and then sets the number of concurrent streams to 1
- private static class EchoHandler extends ChannelInboundHandlerAdapter {
+ private static class EchoHandler extends ChannelHandlerAdapter {
private final int closeSignal;
private final boolean server;
diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java
index 5afc506ce6..e4b3072e05 100644
--- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java
+++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java
@@ -17,7 +17,7 @@ package io.netty.handler.codec.memcache.binary;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.CombinedChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAppender;
import io.netty.handler.codec.PrematureChannelClosureException;
import io.netty.handler.codec.memcache.LastMemcacheContent;
@@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicLong;
* will be passed up the pipeline and not queued up to the chunk size.
*/
public final class BinaryMemcacheClientCodec
- extends CombinedChannelDuplexHandler {
+ extends ChannelHandlerAppender {
private final boolean failOnMissingResponse;
private final AtomicLong requestResponseCounter = new AtomicLong();
@@ -65,7 +65,7 @@ public final class BinaryMemcacheClientCodec
*/
public BinaryMemcacheClientCodec(int decodeChunkSize, boolean failOnMissingResponse) {
this.failOnMissingResponse = failOnMissingResponse;
- init(new Decoder(decodeChunkSize), new Encoder());
+ add(new Decoder(decodeChunkSize), new Encoder());
}
private final class Encoder extends BinaryMemcacheRequestEncoder {
@@ -116,5 +116,4 @@ public final class BinaryMemcacheClientCodec
}
}
}
-
}
diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java
index 0dfb0aef3a..ccc6dd17f5 100644
--- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java
+++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java
@@ -15,7 +15,7 @@
*/
package io.netty.handler.codec.memcache.binary;
-import io.netty.channel.CombinedChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAppender;
/**
* The full server codec that combines the correct encoder and decoder.
@@ -24,14 +24,13 @@ import io.netty.channel.CombinedChannelDuplexHandler;
* Internally, it combines the {@link BinaryMemcacheRequestDecoder} and the
* {@link BinaryMemcacheResponseEncoder} to request decoding and response encoding.
*/
-public class BinaryMemcacheServerCodec
- extends CombinedChannelDuplexHandler {
+public class BinaryMemcacheServerCodec extends ChannelHandlerAppender {
public BinaryMemcacheServerCodec() {
this(BinaryMemcacheDecoder.DEFAULT_MAX_CHUNK_SIZE);
}
public BinaryMemcacheServerCodec(int decodeChunkSize) {
- init(new BinaryMemcacheRequestDecoder(decodeChunkSize), new BinaryMemcacheResponseEncoder());
+ add(new BinaryMemcacheRequestDecoder(decodeChunkSize), new BinaryMemcacheResponseEncoder());
}
}
diff --git a/codec/src/main/java/io/netty/handler/codec/ByteToMessageCodec.java b/codec/src/main/java/io/netty/handler/codec/ByteToMessageCodec.java
index c095d8a654..6392b16960 100644
--- a/codec/src/main/java/io/netty/handler/codec/ByteToMessageCodec.java
+++ b/codec/src/main/java/io/netty/handler/codec/ByteToMessageCodec.java
@@ -16,7 +16,7 @@
package io.netty.handler.codec;
import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.util.internal.TypeParameterMatcher;
@@ -31,7 +31,7 @@ import java.util.List;
* Be aware that sub-classes of {@link ByteToMessageCodec} MUST NOT
* annotated with {@link @Sharable}.
*/
-public abstract class ByteToMessageCodec extends ChannelDuplexHandler {
+public abstract class ByteToMessageCodec extends ChannelHandlerAdapter {
private final TypeParameterMatcher outboundMsgMatcher;
private final MessageToByteEncoder encoder;
diff --git a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java
index a40bdb196c..50dc125886 100644
--- a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java
@@ -17,15 +17,16 @@ package io.netty.handler.codec;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.internal.RecyclableArrayList;
import io.netty.util.internal.StringUtil;
import java.util.List;
/**
- * {@link ChannelInboundHandlerAdapter} which decodes bytes in a stream-like fashion from one {@link ByteBuf} to an
+ * A {@link ChannelHandler} which decodes bytes in a stream-like fashion from one {@link ByteBuf} to an
* other Message type.
*
* For example here is an implementation which reads all readable bytes from
@@ -44,7 +45,7 @@ import java.util.List;
* Be aware that sub-classes of {@link ByteToMessageDecoder} MUST NOT
* annotated with {@link @Sharable}.
*/
-public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter {
+public abstract class ByteToMessageDecoder extends ChannelHandlerAdapter {
ByteBuf cumulation;
private boolean singleDecode;
diff --git a/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java b/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java
index f6c506b237..3cf0719215 100644
--- a/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java
@@ -17,9 +17,9 @@ package io.netty.handler.codec;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelOutboundHandler;
-import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.util.ReferenceCountUtil;
@@ -27,7 +27,7 @@ import io.netty.util.internal.TypeParameterMatcher;
/**
- * {@link ChannelOutboundHandlerAdapter} which encodes message in a stream-like fashion from one message to an
+ * {@link ChannelHandlerAdapter} which encodes message in a stream-like fashion from one message to an
* {@link ByteBuf}.
*
*
@@ -43,7 +43,7 @@ import io.netty.util.internal.TypeParameterMatcher;
* }
*
*/
-public abstract class MessageToByteEncoder extends ChannelOutboundHandlerAdapter {
+public abstract class MessageToByteEncoder extends ChannelHandlerAdapter {
private final TypeParameterMatcher matcher;
private final boolean preferDirect;
@@ -89,7 +89,7 @@ public abstract class MessageToByteEncoder extends ChannelOutboundHandlerAdap
/**
* Returns {@code true} if the given message should be handled. If {@code false} it will be passed to the next
- * {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
+ * {@link ChannelHandler} in the {@link ChannelPipeline}.
*/
public boolean acceptOutboundMessage(Object msg) throws Exception {
return matcher.match(msg);
diff --git a/codec/src/main/java/io/netty/handler/codec/MessageToMessageCodec.java b/codec/src/main/java/io/netty/handler/codec/MessageToMessageCodec.java
index 08d4568bd6..2db27f5e30 100644
--- a/codec/src/main/java/io/netty/handler/codec/MessageToMessageCodec.java
+++ b/codec/src/main/java/io/netty/handler/codec/MessageToMessageCodec.java
@@ -15,7 +15,7 @@
*/
package io.netty.handler.codec;
-import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.util.ReferenceCounted;
@@ -52,7 +52,7 @@ import java.util.List;
* are of type {@link ReferenceCounted}. This is needed as the {@link MessageToMessageCodec} will call
* {@link ReferenceCounted#release()} on encoded / decoded messages.
*/
-public abstract class MessageToMessageCodec extends ChannelDuplexHandler {
+public abstract class MessageToMessageCodec extends ChannelHandlerAdapter {
private final MessageToMessageEncoder
*
*
Both inbound and outbound traffic can be shaped independently. This is done by either passing in
* the desired limiting values to the constructors of both the Channel and Global traffic shaping handlers,
- * or by calling the configure method on the {@link AbstractTrafficShapingHandler}. A value of
- * 0 for either parameter indicates that there should be no limitation. This allows you to monitor the
+ * or by calling the configure method on the {@link io.netty.handler.traffic.AbstractTrafficShapingHandler}.
+ * A value of for either parameter indicates that there should be no limitation. This allows you to monitor the
* incoming and outgoing traffic without shaping.
*
*
To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms
@@ -44,11 +45,13 @@
* or even using 0 which means no computation will be done.
*
*
If you want to do anything with these statistics, just override the doAccounting method.
- * This interval can be changed either from the method configure in {@link AbstractTrafficShapingHandler}
- * or directly using the method configure of {@link TrafficCounter}.
+ * This interval can be changed either from the method configure
+ * in {@link io.netty.handler.traffic.AbstractTrafficShapingHandler} or directly using the method configure
+ * of {@link io.netty.handler.traffic.TrafficCounter}.
*
- *
Note that a new {@link ChannelTrafficShapingHandler} must be created for each new channel,
- * but only one {@link GlobalTrafficShapingHandler} must be created for all channels.
+ *
Note that a new {@link io.netty.handler.traffic.ChannelTrafficShapingHandler} must be created
+ * for each new channel, but only one {@link io.netty.handler.traffic.GlobalTrafficShapingHandler} must be created
+ * for all channels.
*
*
Note also that you can create different GlobalTrafficShapingHandler if you want to separate classes of
* channels (for instance either from business point of view or from bind address point of view).
diff --git a/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java b/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java
index 30559e501f..7cb8f1d3e4 100644
--- a/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java
+++ b/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java
@@ -18,8 +18,8 @@ package io.netty.handler.codec.sctp;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.sctp.SctpMessage;
import io.netty.handler.codec.MessageToMessageDecoder;
@@ -30,7 +30,7 @@ import java.util.Map;
/**
* {@link MessageToMessageDecoder} which will take care of handle fragmented {@link SctpMessage}s, so
* only complete {@link SctpMessage}s will be forwarded to the next
- * {@link ChannelInboundHandler}.
+ * {@link ChannelHandler}.
*/
public class SctpMessageCompletionHandler extends MessageToMessageDecoder {
private final Map fragments = new HashMap();
diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java b/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java
index c4deaa6f06..7ec3004a76 100644
--- a/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java
+++ b/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java
@@ -19,8 +19,8 @@ package io.netty.test.udt.util;
import com.yammer.metrics.core.Meter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.udt.nio.NioUdtProvider;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -30,7 +30,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory;
* traffic between the echo client and server by sending the first message to
* the server on activation.
*/
-public class EchoByteHandler extends ChannelInboundHandlerAdapter {
+public class EchoByteHandler extends ChannelHandlerAdapter {
private static final InternalLogger log = InternalLoggerFactory.getInstance(EchoByteHandler.class);
diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/EchoMessageHandler.java b/transport-udt/src/test/java/io/netty/test/udt/util/EchoMessageHandler.java
index c48603a4e8..38466c2a21 100644
--- a/transport-udt/src/test/java/io/netty/test/udt/util/EchoMessageHandler.java
+++ b/transport-udt/src/test/java/io/netty/test/udt/util/EchoMessageHandler.java
@@ -19,8 +19,8 @@ package io.netty.test.udt.util;
import com.yammer.metrics.core.Meter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.udt.UdtMessage;
import io.netty.channel.udt.nio.NioUdtProvider;
import io.netty.util.internal.logging.InternalLogger;
@@ -31,7 +31,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory;
* between the echo peers by sending the first message to the other peer on
* activation.
*/
-public class EchoMessageHandler extends ChannelInboundHandlerAdapter {
+public class EchoMessageHandler extends ChannelHandlerAdapter {
private static final InternalLogger log = InternalLoggerFactory.getInstance(EchoMessageHandler.class);
diff --git a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java
index 38b6be687f..33e388a8c0 100644
--- a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java
+++ b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java
@@ -19,8 +19,8 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
@@ -254,7 +254,7 @@ public final class ServerBootstrap extends AbstractBootstrap, Object>[] childOptions;
diff --git a/transport/src/main/java/io/netty/channel/Channel.java b/transport/src/main/java/io/netty/channel/Channel.java
index fbdfa740cd..6994171539 100644
--- a/transport/src/main/java/io/netty/channel/Channel.java
+++ b/transport/src/main/java/io/netty/channel/Channel.java
@@ -235,7 +235,7 @@ public interface Channel extends AttributeMap, ChannelOutboundOps, ChannelProper
void closeForcibly();
/**
- * Schedules a read operation that fills the inbound buffer of the first {@link ChannelInboundHandler} in the
+ * Schedules a read operation that fills the inbound buffer of the first {@link ChannelHandler} in the
* {@link ChannelPipeline}. If there's already a pending read operation, this method does nothing.
*/
void beginRead();
diff --git a/transport/src/main/java/io/netty/channel/ChannelConfig.java b/transport/src/main/java/io/netty/channel/ChannelConfig.java
index 0e465bd592..edaca712ef 100644
--- a/transport/src/main/java/io/netty/channel/ChannelConfig.java
+++ b/transport/src/main/java/io/netty/channel/ChannelConfig.java
@@ -120,7 +120,7 @@ public interface ChannelConfig {
/**
* Returns the maximum number of messages to read per read loop.
- * a {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object) channelRead()} event.
+ * a {@link ChannelHandler#channelRead(ChannelHandlerContext, Object) channelRead()} event.
* If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages.
*/
int getMaxMessagesPerRead();
diff --git a/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java b/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java
index afea6180c2..c0414d3dc6 100644
--- a/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java
+++ b/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java
@@ -15,94 +15,8 @@
*/
package io.netty.channel;
-import java.net.SocketAddress;
-
/**
- * {@link ChannelHandler} implementation which represents a combination out of a {@link ChannelInboundHandler} and
- * the {@link ChannelOutboundHandler}.
- *
- * It is a good starting point if your {@link ChannelHandler} implementation needs to intercept operations and also
- * state updates.
+ * @deprecated Use {@link ChannelHandlerAdapter} instead.
*/
-public class ChannelDuplexHandler extends ChannelInboundHandlerAdapter implements ChannelOutboundHandler {
-
- /**
- * Calls {@link ChannelHandlerContext#bind(SocketAddress, ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void bind(ChannelHandlerContext ctx, SocketAddress localAddress,
- ChannelPromise future) throws Exception {
- ctx.bind(localAddress, future);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress,
- SocketAddress localAddress, ChannelPromise future) throws Exception {
- ctx.connect(remoteAddress, localAddress, future);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#disconnect(ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void disconnect(ChannelHandlerContext ctx, ChannelPromise future)
- throws Exception {
- ctx.disconnect(future);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#close(ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void close(ChannelHandlerContext ctx, ChannelPromise future) throws Exception {
- ctx.close(future);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#read()} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void read(ChannelHandlerContext ctx) throws Exception {
- ctx.read();
- }
-
- /**
- * Calls {@link ChannelHandlerContext#write(Object, ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
- ctx.write(msg, promise);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#flush()} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void flush(ChannelHandlerContext ctx) throws Exception {
- ctx.flush();
- }
-}
+@Deprecated
+public class ChannelDuplexHandler extends ChannelHandlerAdapter { }
diff --git a/transport/src/main/java/io/netty/channel/ChannelHandler.java b/transport/src/main/java/io/netty/channel/ChannelHandler.java
index 8fef023216..25260f58ad 100644
--- a/transport/src/main/java/io/netty/channel/ChannelHandler.java
+++ b/transport/src/main/java/io/netty/channel/ChannelHandler.java
@@ -24,29 +24,16 @@ import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import java.net.SocketAddress;
/**
* Handles an I/O event or intercepts an I/O operation, and forwards it to its next handler in
* its {@link ChannelPipeline}.
*
- *
Sub-types
+ *
Extend {@link ChannelHandlerAdapter} instead
*
- * {@link ChannelHandler} itself does not provide many methods, but you usually have to implement one of its subtypes:
- *
- *
{@link ChannelInboundHandler} to handle inbound I/O events, and
- *
{@link ChannelOutboundHandler} to handle outbound I/O operations.
- *
- *
- *
- * Alternatively, the following adapter classes are provided for your convenience:
- *
- *
{@link ChannelInboundHandlerAdapter} to handle inbound I/O events,
- *
{@link ChannelOutboundHandlerAdapter} to handle outbound I/O operations, and
- *
{@link ChannelHandlerAdapter} to handle both inbound and outbound events
- *
- *
- *
- * For more information, please refer to the documentation of each subtype.
+ * Because this interface has many methods to implement, you might want to extend {@link ChannelHandlerAdapter}
+ * instead.
*
*
*
The context object
@@ -184,6 +171,10 @@ import java.lang.annotation.Target;
*/
public interface ChannelHandler {
+ ////////////////////////////////
+ // Handler life cycle methods //
+ ////////////////////////////////
+
/**
* Gets called after the {@link ChannelHandler} was added to the actual context and it's ready to handle events.
*/
@@ -195,11 +186,130 @@ public interface ChannelHandler {
*/
void handlerRemoved(ChannelHandlerContext ctx) throws Exception;
+ ///////////////////////////////////
+ // Inbound event handler methods //
+ ///////////////////////////////////
+
/**
* Gets called if a {@link Throwable} was thrown.
*/
void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception;
+ /**
+ * The {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link EventLoop}
+ */
+ void channelRegistered(ChannelHandlerContext ctx) throws Exception;
+
+ /**
+ * The {@link Channel} of the {@link ChannelHandlerContext} is now active
+ */
+ void channelActive(ChannelHandlerContext ctx) throws Exception;
+
+ /**
+ * The {@link Channel} of the {@link ChannelHandlerContext} was registered is now inactive and reached its
+ * end of lifetime.
+ */
+ void channelInactive(ChannelHandlerContext ctx) throws Exception;
+
+ /**
+ * Invoked when the current {@link Channel} has read a message from the peer.
+ */
+ void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception;
+
+ /**
+ * Invoked when the last message read by the current read operation has been consumed by
+ * {@link #channelRead(ChannelHandlerContext, Object)}. If {@link ChannelOption#AUTO_READ} is off, no further
+ * attempt to read an inbound data from the current {@link Channel} will be made until
+ * {@link ChannelHandlerContext#read()} is called.
+ */
+ void channelReadComplete(ChannelHandlerContext ctx) throws Exception;
+
+ /**
+ * Gets called if an user event was triggered.
+ */
+ void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception;
+
+ /**
+ * Gets called once the writable state of a {@link Channel} changed. You can check the state with
+ * {@link Channel#isWritable()}.
+ */
+ void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception;
+
+ ////////////////////////////////////
+ // Outbound event handler methods //
+ ////////////////////////////////////
+
+ /**
+ * Called once a bind operation is made.
+ *
+ * @param ctx the {@link ChannelHandlerContext} for which the bind operation is made
+ * @param localAddress the {@link java.net.SocketAddress} to which it should bound
+ * @param promise the {@link ChannelPromise} to notify once the operation completes
+ * @throws Exception thrown if an error accour
+ */
+ void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception;
+
+ /**
+ * Called once a connect operation is made.
+ *
+ * @param ctx the {@link ChannelHandlerContext} for which the connect operation is made
+ * @param remoteAddress the {@link SocketAddress} to which it should connect
+ * @param localAddress the {@link SocketAddress} which is used as source on connect
+ * @param promise the {@link ChannelPromise} to notify once the operation completes
+ * @throws Exception thrown if an error accour
+ */
+ void connect(
+ ChannelHandlerContext ctx,
+ SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception;
+
+ /**
+ * Called once a disconnect operation is made.
+ *
+ * @param ctx the {@link ChannelHandlerContext} for which the disconnect operation is made
+ * @param promise the {@link ChannelPromise} to notify once the operation completes
+ * @throws Exception thrown if an error accour
+ */
+ void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception;
+
+ /**
+ * Called once a close operation is made.
+ *
+ * @param ctx the {@link ChannelHandlerContext} for which the close operation is made
+ * @param promise the {@link ChannelPromise} to notify once the operation completes
+ * @throws Exception thrown if an error accour
+ */
+ void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception;
+
+ /**
+ * Intercepts {@link ChannelHandlerContext#read()}.
+ */
+ void read(ChannelHandlerContext ctx) throws Exception;
+
+ /**
+ * Called once a write operation is made. The write operation will write the messages through the
+ * {@link ChannelPipeline}. Those are then ready to be flushed to the actual {@link Channel} once
+ * {@link Channel#flush()} is called
+ *
+ * @param ctx the {@link ChannelHandlerContext} for which the write operation is made
+ * @param msg the message to write
+ * @param promise the {@link ChannelPromise} to notify once the operation completes
+ * @throws Exception thrown if an error accour
+ */
+ void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception;
+
+ /**
+ * Called once a flush operation is made. The flush operation will try to flush out all previous written messages
+ * that are pending.
+ *
+ * @param ctx the {@link ChannelHandlerContext} for which the flush operation is made
+ * @throws Exception thrown if an error accour
+ */
+ void flush(ChannelHandlerContext ctx) throws Exception;
+
+ /////////////////
+ // Annotations //
+ /////////////////
+
/**
* Indicates that the same instance of the annotated {@link ChannelHandler}
* can be added to one or more {@link ChannelPipeline}s multiple times
@@ -219,4 +329,41 @@ public interface ChannelHandler {
@interface Sharable {
// no value
}
+
+ /**
+ * Indicates that the annotated event handler method in {@link ChannelHandler} will not be invoked by
+ * {@link ChannelPipeline}. This annotation is only useful when your handler method implementation
+ * only passes the event through to the next handler, like the following:
+ *
+ *
+ * {@code @Skip}
+ * {@code @Override}
+ * public void channelActive({@link ChannelHandlerContext} ctx) {
+ * ctx.fireChannelActive(); // do nothing but passing through to the next handler
+ * }
+ *
+ *
+ * {@link #handlerAdded(ChannelHandlerContext)} and {@link #handlerRemoved(ChannelHandlerContext)} are not able to
+ * pass the event through to the next handler, so they must do nothing when annotated.
+ *
+ *
+ * Note that this annotation is not {@linkplain Inherited inherited}. If you override a method annotated with
+ * {@link Skip}, it will not be skipped anymore. Similarly, you can override a method not annotated with
+ * {@link Skip} and simply pass the event through to the next handler, which reverses the behavior of the
+ * supertype.
+ *
+ */
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Skip {
+ // no value
+ }
}
diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerAdapter.java b/transport/src/main/java/io/netty/channel/ChannelHandlerAdapter.java
index 86a834867d..8b70bc1ba6 100644
--- a/transport/src/main/java/io/netty/channel/ChannelHandlerAdapter.java
+++ b/transport/src/main/java/io/netty/channel/ChannelHandlerAdapter.java
@@ -16,10 +16,12 @@
package io.netty.channel;
+import java.net.SocketAddress;
+
/**
* Skelton implementation of a {@link ChannelHandler}.
*/
-public abstract class ChannelHandlerAdapter implements ChannelHandler {
+public class ChannelHandlerAdapter implements ChannelHandler {
// Not using volatile because it's used only for a sanity check.
boolean added;
@@ -35,6 +37,7 @@ public abstract class ChannelHandlerAdapter implements ChannelHandler {
/**
* Do nothing by default, sub-classes may override this method.
*/
+ @Skip
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
// NOOP
@@ -43,6 +46,7 @@ public abstract class ChannelHandlerAdapter implements ChannelHandler {
/**
* Do nothing by default, sub-classes may override this method.
*/
+ @Skip
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
// NOOP
@@ -54,9 +58,179 @@ public abstract class ChannelHandlerAdapter implements ChannelHandler {
*
* Sub-classes may override this method to change behavior.
*/
+ @Skip
@Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
- throws Exception {
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
ctx.fireExceptionCaught(cause);
}
+
+ /**
+ * Calls {@link ChannelHandlerContext#fireChannelRegistered()} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
+ ctx.fireChannelRegistered();
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#fireChannelActive()} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ ctx.fireChannelActive();
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#fireChannelInactive()} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+ ctx.fireChannelInactive();
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#fireChannelRead(Object)} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+ ctx.fireChannelRead(msg);
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#fireChannelReadComplete()} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+ ctx.fireChannelReadComplete();
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#fireUserEventTriggered(Object)} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+ ctx.fireUserEventTriggered(evt);
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#fireChannelWritabilityChanged()} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
+ ctx.fireChannelWritabilityChanged();
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#bind(java.net.SocketAddress, ChannelPromise)} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
+ ctx.bind(localAddress, promise);
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise)} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void connect(
+ ChannelHandlerContext ctx,
+ SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception {
+ ctx.connect(remoteAddress, localAddress, promise);
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#disconnect(ChannelPromise)} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
+ ctx.disconnect(promise);
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#close(ChannelPromise)} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
+ ctx.close(promise);
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#read()} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void read(ChannelHandlerContext ctx) throws Exception {
+ ctx.read();
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#write(Object)} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
+ ctx.write(msg, promise);
+ }
+
+ /**
+ * Calls {@link ChannelHandlerContext#flush()} to forward
+ * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
+ *
+ * Sub-classes may override this method to change behavior.
+ */
+ @Skip
+ @Override
+ public void flush(ChannelHandlerContext ctx) throws Exception {
+ ctx.flush();
+ }
}
diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerAppender.java b/transport/src/main/java/io/netty/channel/ChannelHandlerAppender.java
new file mode 100644
index 0000000000..475eae6468
--- /dev/null
+++ b/transport/src/main/java/io/netty/channel/ChannelHandlerAppender.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2012 The Netty Project
+ *
+ * The Netty Project licenses this file to you under the Apache License,
+ * version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package io.netty.channel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A {@link ChannelHandler} that appends the specified {@link ChannelHandler}s right next to itself.
+ * By default, it removes itself from the {@link ChannelPipeline} once the specified {@link ChannelHandler}s
+ * are added. Optionally, you can keep it in the {@link ChannelPipeline} by specifying a {@code boolean}
+ * parameter at construction time.
+ */
+public class ChannelHandlerAppender extends ChannelHandlerAdapter {
+
+ private static final class Entry {
+ final String name;
+ final ChannelHandler handler;
+
+ Entry(String name, ChannelHandler handler) {
+ this.name = name;
+ this.handler = handler;
+ }
+ }
+
+ private final boolean selfRemoval;
+ private final List handlers = new ArrayList();
+ private boolean added;
+
+ /**
+ * Creates a new uninitialized instance. A class that extends this handler must invoke
+ * {@link #add(ChannelHandler...)} before adding this handler into a {@link ChannelPipeline}.
+ */
+ protected ChannelHandlerAppender() {
+ this(true);
+ }
+
+ /**
+ * Creates a new uninitialized instance. A class that extends this handler must invoke
+ * {@link #add(ChannelHandler...)} before adding this handler into a {@link ChannelPipeline}.
+ *
+ * @param selfRemoval {@code true} to remove itself from the {@link ChannelPipeline} after appending
+ * the {@link ChannelHandler}s specified via {@link #add(ChannelHandler...)}.
+ */
+ protected ChannelHandlerAppender(boolean selfRemoval) {
+ this.selfRemoval = selfRemoval;
+ }
+
+ /**
+ * Creates a new instance that appends the specified {@link ChannelHandler}s right next to itself.
+ */
+ public ChannelHandlerAppender(Iterable extends ChannelHandler> handlers) {
+ this(true, handlers);
+ }
+
+ /**
+ * Creates a new instance that appends the specified {@link ChannelHandler}s right next to itself.
+ */
+ public ChannelHandlerAppender(ChannelHandler... handlers) {
+ this(true, handlers);
+ }
+
+ /**
+ * Creates a new instance that appends the specified {@link ChannelHandler}s right next to itself.
+ *
+ * @param selfRemoval {@code true} to remove itself from the {@link ChannelPipeline} after appending
+ * the specified {@link ChannelHandler}s
+ */
+ public ChannelHandlerAppender(boolean selfRemoval, Iterable extends ChannelHandler> handlers) {
+ this.selfRemoval = selfRemoval;
+ add(handlers);
+ }
+
+ /**
+ * Creates a new instance that appends the specified {@link ChannelHandler}s right next to itself.
+ *
+ * @param selfRemoval {@code true} to remove itself from the {@link ChannelPipeline} after appending
+ * the specified {@link ChannelHandler}s
+ */
+ public ChannelHandlerAppender(boolean selfRemoval, ChannelHandler... handlers) {
+ this.selfRemoval = selfRemoval;
+ add(handlers);
+ }
+
+ /**
+ * Adds the specified handler to the list of the appended handlers.
+ *
+ * @param name the name of the appended handler. {@code null} to auto-generate
+ * @param handler the handler to append
+ *
+ * @throws IllegalStateException if {@link ChannelHandlerAppender} has been added to the pipeline already
+ */
+ protected final ChannelHandlerAppender add(String name, ChannelHandler handler) {
+ if (handler == null) {
+ throw new NullPointerException("handler");
+ }
+
+ if (added) {
+ throw new IllegalStateException("added to the pipeline already");
+ }
+
+ handlers.add(new Entry(name, handler));
+ return this;
+ }
+
+ /**
+ * Adds the specified handler to the list of the appended handlers with the auto-generated handler name.
+ *
+ * @param handler the handler to append
+ *
+ * @throws IllegalStateException if {@link ChannelHandlerAppender} has been added to the pipeline already
+ */
+ protected final ChannelHandlerAppender add(ChannelHandler handler) {
+ return add(null, handler);
+ }
+
+ /**
+ * Adds the specified handlers to the list of the appended handlers. The handlers' names are auto-generated.
+ *
+ * @throws IllegalStateException if {@link ChannelHandlerAppender} has been added to the pipeline already
+ */
+ @SuppressWarnings("unchecked")
+ protected final ChannelHandlerAppender add(Iterable extends ChannelHandler> handlers) {
+ if (handlers == null) {
+ throw new NullPointerException("handlers");
+ }
+
+ for (ChannelHandler h: handlers) {
+ if (h == null) {
+ break;
+ }
+ add(h);
+ }
+
+ return this;
+ }
+
+ /**
+ * Adds the specified handlers to the list of the appended handlers. The handlers' names are auto-generated.
+ *
+ * @throws IllegalStateException if {@link ChannelHandlerAppender} has been added to the pipeline already
+ */
+ protected final ChannelHandlerAppender add(ChannelHandler... handlers) {
+ if (handlers == null) {
+ throw new NullPointerException("handlers");
+ }
+
+ for (ChannelHandler h: handlers) {
+ if (h == null) {
+ break;
+ }
+
+ add(h);
+ }
+
+ return this;
+ }
+
+ /**
+ * Returns the {@code index}-th appended handler.
+ */
+ @SuppressWarnings("unchecked")
+ protected final T handlerAt(int index) {
+ return (T) handlers.get(index).handler;
+ }
+
+ @Override
+ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
+ added = true;
+
+ DefaultChannelPipeline pipeline = (DefaultChannelPipeline) ctx.pipeline();
+
+ String name = ctx.name();
+ try {
+ for (Entry e: handlers) {
+ String oldName = name;
+ if (e.name == null) {
+ name = pipeline.generateName(e.handler);
+ } else {
+ name = e.name;
+ }
+ pipeline.addAfter(ctx.invoker(), oldName, name, e.handler);
+ }
+ } finally {
+ if (selfRemoval) {
+ pipeline.remove(this);
+ }
+ }
+ }
+}
diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java
index 937a35e940..e1d23ead4f 100644
--- a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java
+++ b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java
@@ -44,7 +44,7 @@ import java.nio.channels.Channels;
* You can keep the {@link ChannelHandlerContext} for later use, such as
* triggering an event outside the handler methods, even from a different thread.
*
- * public class MyHandler extends {@link ChannelDuplexHandler} {
+ * public class MyHandler extends {@link ChannelHandlerAdapter} {
*
* private {@link ChannelHandlerContext} ctx;
*
@@ -79,15 +79,14 @@ import java.nio.channels.Channels;
* as how many times it is added to pipelines, regardless if it is added to the
* same pipeline multiple times or added to different pipelines multiple times:
*
- * public class FactorialHandler extends {@link ChannelInboundHandlerAdapter}<{@link Integer}> {
+ * public class FactorialHandler extends {@link ChannelHandlerAdapter} {
*
- * private final {@link AttributeKey}<{@link Integer}> counter =
- * new {@link AttributeKey}<{@link Integer}>("counter");
+ * private final {@link AttributeKey}<{@link Integer}> counter = {@link AttributeKey}.valueOf("counter");
*
* // This handler will receive a sequence of increasing integers starting
* // from 1.
* {@code @Override}
- * public void channelRead({@link ChannelHandlerContext} ctx, {@link Integer} integer) {
+ * public void channelRead({@link ChannelHandlerContext} ctx, Object msg) {
* {@link Attribute}<{@link Integer}> attr = ctx.getAttr(counter);
* Integer a = ctx.getAttr(counter).get();
*
@@ -95,7 +94,7 @@ import java.nio.channels.Channels;
* a = 1;
* }
*
- * attr.set(a * integer));
+ * attr.set(a * (Integer) msg);
* }
* }
*
@@ -134,6 +133,14 @@ public interface ChannelHandlerContext
*/
EventExecutor executor();
+ /**
+ * Returns the {@link ChannelHandlerInvoker} which is used to trigger an event for the associated
+ * {@link ChannelHandler}. Note that the methods in {@link ChannelHandlerInvoker} are not intended to be called
+ * by a user. Use this method only to obtain the reference to the {@link ChannelHandlerInvoker}
+ * (and not calling its methods) unless you know what you are doing.
+ */
+ ChannelHandlerInvoker invoker();
+
/**
* The unique name of the {@link ChannelHandlerContext}.The name was used when then {@link ChannelHandler}
* was added to the {@link ChannelPipeline}. This name can also be used to access the registered
diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java b/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java
index dc7bc56e5a..145e0eed78 100644
--- a/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java
+++ b/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java
@@ -21,9 +21,9 @@ import io.netty.util.concurrent.EventExecutor;
import java.net.SocketAddress;
/**
- * Invokes the event handler methods of {@link ChannelInboundHandler} and {@link ChannelOutboundHandler}.
+ * Invokes the event handler methods of {@link ChannelHandler}.
* A user can specify a {@link ChannelHandlerInvoker} to implement a custom thread model unsupported by the default
- * implementation.
+ * implementation. Note that the methods in this interface are not intended to be called by a user.
*/
public interface ChannelHandlerInvoker {
@@ -33,21 +33,21 @@ public interface ChannelHandlerInvoker {
EventExecutor executor();
/**
- * Invokes {@link ChannelInboundHandler#channelRegistered(ChannelHandlerContext)}. This method is not for a user
+ * Invokes {@link ChannelHandler#channelRegistered(ChannelHandlerContext)}. This method is not for a user
* but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
* {@link ChannelHandlerContext} instead.
*/
void invokeChannelRegistered(ChannelHandlerContext ctx);
/**
- * Invokes {@link ChannelInboundHandler#channelActive(ChannelHandlerContext)}. This method is not for a user
+ * Invokes {@link ChannelHandler#channelActive(ChannelHandlerContext)}. This method is not for a user
* but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
* {@link ChannelHandlerContext} instead.
*/
void invokeChannelActive(ChannelHandlerContext ctx);
/**
- * Invokes {@link ChannelInboundHandler#channelInactive(ChannelHandlerContext)}. This method is not for a user
+ * Invokes {@link ChannelHandler#channelInactive(ChannelHandlerContext)}. This method is not for a user
* but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
* {@link ChannelHandlerContext} instead.
*/
@@ -61,35 +61,35 @@ public interface ChannelHandlerInvoker {
void invokeExceptionCaught(ChannelHandlerContext ctx, Throwable cause);
/**
- * Invokes {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)}. This method is not for
+ * Invokes {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)}. This method is not for
* a user but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
* {@link ChannelHandlerContext} instead.
*/
void invokeUserEventTriggered(ChannelHandlerContext ctx, Object event);
/**
- * Invokes {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object)}. This method is not for a user
+ * Invokes {@link ChannelHandler#channelRead(ChannelHandlerContext, Object)}. This method is not for a user
* but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
* {@link ChannelHandlerContext} instead.
*/
void invokeChannelRead(ChannelHandlerContext ctx, Object msg);
/**
- * Invokes {@link ChannelInboundHandler#channelReadComplete(ChannelHandlerContext)}. This method is not for a user
+ * Invokes {@link ChannelHandler#channelReadComplete(ChannelHandlerContext)}. This method is not for a user
* but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
* {@link ChannelHandlerContext} instead.
*/
void invokeChannelReadComplete(ChannelHandlerContext ctx);
/**
- * Invokes {@link ChannelInboundHandler#channelWritabilityChanged(ChannelHandlerContext)}. This method is not for
+ * Invokes {@link ChannelHandler#channelWritabilityChanged(ChannelHandlerContext)}. This method is not for
* a user but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
* {@link ChannelHandlerContext} instead.
*/
void invokeChannelWritabilityChanged(ChannelHandlerContext ctx);
/**
- * Invokes {@link ChannelOutboundHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)}.
+ * Invokes {@link ChannelHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)}.
* This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
* To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
*/
@@ -97,7 +97,7 @@ public interface ChannelHandlerInvoker {
/**
* Invokes
- * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}.
+ * {@link ChannelHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}.
* This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
* To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
*/
@@ -105,43 +105,35 @@ public interface ChannelHandlerInvoker {
ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise);
/**
- * Invokes {@link ChannelOutboundHandler#disconnect(ChannelHandlerContext, ChannelPromise)}.
+ * Invokes {@link ChannelHandler#disconnect(ChannelHandlerContext, ChannelPromise)}.
* This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
* To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
*/
void invokeDisconnect(ChannelHandlerContext ctx, ChannelPromise promise);
/**
- * Invokes {@link ChannelOutboundHandler#close(ChannelHandlerContext, ChannelPromise)}.
+ * Invokes {@link ChannelHandler#close(ChannelHandlerContext, ChannelPromise)}.
* This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
* To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
*/
void invokeClose(ChannelHandlerContext ctx, ChannelPromise promise);
/**
- * Invokes {@link ChannelOutboundHandler#read(ChannelHandlerContext)}.
+ * Invokes {@link ChannelHandler#read(ChannelHandlerContext)}.
* This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
* To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
*/
void invokeRead(ChannelHandlerContext ctx);
/**
- * Invokes {@link ChannelOutboundHandler#write(ChannelHandlerContext, Object, ChannelPromise)}.
+ * Invokes {@link ChannelHandler#write(ChannelHandlerContext, Object, ChannelPromise)}.
* This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
* To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
*/
void invokeWrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise);
/**
- * Invokes {@link ChannelOutboundHandler#write(ChannelHandlerContext, Object, ChannelPromise)} and
- * {@link ChannelOutboundHandler#flush(ChannelHandlerContext)} sequentially.
- * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
- * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
- */
- void invokeWriteAndFlush(ChannelHandlerContext ctx, Object msg, ChannelPromise promise);
-
- /**
- * Invokes {@link ChannelOutboundHandler#flush(ChannelHandlerContext)}.
+ * Invokes {@link ChannelHandler#flush(ChannelHandlerContext)}.
* This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
* To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
*/
diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java b/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java
index a72775fcd4..9da461187a 100644
--- a/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java
+++ b/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java
@@ -27,7 +27,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeChannelRegisteredNow(ChannelHandlerContext ctx) {
try {
- ((ChannelInboundHandler) ctx.handler()).channelRegistered(ctx);
+ ctx.handler().channelRegistered(ctx);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -35,7 +35,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeChannelActiveNow(final ChannelHandlerContext ctx) {
try {
- ((ChannelInboundHandler) ctx.handler()).channelActive(ctx);
+ ctx.handler().channelActive(ctx);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -43,7 +43,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeChannelInactiveNow(final ChannelHandlerContext ctx) {
try {
- ((ChannelInboundHandler) ctx.handler()).channelInactive(ctx);
+ ctx.handler().channelInactive(ctx);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -63,7 +63,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeUserEventTriggeredNow(final ChannelHandlerContext ctx, final Object event) {
try {
- ((ChannelInboundHandler) ctx.handler()).userEventTriggered(ctx, event);
+ ctx.handler().userEventTriggered(ctx, event);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -71,7 +71,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeChannelReadNow(final ChannelHandlerContext ctx, final Object msg) {
try {
- ((ChannelInboundHandler) ctx.handler()).channelRead(ctx, msg);
+ ctx.handler().channelRead(ctx, msg);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -79,7 +79,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeChannelReadCompleteNow(final ChannelHandlerContext ctx) {
try {
- ((ChannelInboundHandler) ctx.handler()).channelReadComplete(ctx);
+ ctx.handler().channelReadComplete(ctx);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -87,7 +87,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeChannelWritabilityChangedNow(final ChannelHandlerContext ctx) {
try {
- ((ChannelInboundHandler) ctx.handler()).channelWritabilityChanged(ctx);
+ ctx.handler().channelWritabilityChanged(ctx);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -96,7 +96,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeBindNow(
final ChannelHandlerContext ctx, final SocketAddress localAddress, final ChannelPromise promise) {
try {
- ((ChannelOutboundHandler) ctx.handler()).bind(ctx, localAddress, promise);
+ ctx.handler().bind(ctx, localAddress, promise);
} catch (Throwable t) {
notifyOutboundHandlerException(t, promise);
}
@@ -105,7 +105,7 @@ public final class ChannelHandlerInvokerUtil {
final ChannelHandlerContext ctx,
final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) {
try {
- ((ChannelOutboundHandler) ctx.handler()).connect(ctx, remoteAddress, localAddress, promise);
+ ctx.handler().connect(ctx, remoteAddress, localAddress, promise);
} catch (Throwable t) {
notifyOutboundHandlerException(t, promise);
}
@@ -113,7 +113,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeDisconnectNow(final ChannelHandlerContext ctx, final ChannelPromise promise) {
try {
- ((ChannelOutboundHandler) ctx.handler()).disconnect(ctx, promise);
+ ctx.handler().disconnect(ctx, promise);
} catch (Throwable t) {
notifyOutboundHandlerException(t, promise);
}
@@ -121,7 +121,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeCloseNow(final ChannelHandlerContext ctx, final ChannelPromise promise) {
try {
- ((ChannelOutboundHandler) ctx.handler()).close(ctx, promise);
+ ctx.handler().close(ctx, promise);
} catch (Throwable t) {
notifyOutboundHandlerException(t, promise);
}
@@ -129,7 +129,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeReadNow(final ChannelHandlerContext ctx) {
try {
- ((ChannelOutboundHandler) ctx.handler()).read(ctx);
+ ctx.handler().read(ctx);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
@@ -137,7 +137,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeWriteNow(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
try {
- ((ChannelOutboundHandler) ctx.handler()).write(ctx, msg, promise);
+ ctx.handler().write(ctx, msg, promise);
} catch (Throwable t) {
notifyOutboundHandlerException(t, promise);
}
@@ -145,7 +145,7 @@ public final class ChannelHandlerInvokerUtil {
public static void invokeFlushNow(final ChannelHandlerContext ctx) {
try {
- ((ChannelOutboundHandler) ctx.handler()).flush(ctx);
+ ctx.handler().flush(ctx);
} catch (Throwable t) {
notifyHandlerException(ctx, t);
}
diff --git a/transport/src/main/java/io/netty/channel/ChannelInboundHandler.java b/transport/src/main/java/io/netty/channel/ChannelInboundHandler.java
deleted file mode 100644
index a4e1b97cfa..0000000000
--- a/transport/src/main/java/io/netty/channel/ChannelInboundHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2012 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.channel;
-
-/**
- * {@link ChannelHandler} which adds callbacks for state changes. This allows the user to hook in to state changes
- * easily.
- */
-public interface ChannelInboundHandler extends ChannelHandler {
-
- /**
- * The {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link EventLoop}
- */
- void channelRegistered(ChannelHandlerContext ctx) throws Exception;
-
- /**
- * The {@link Channel} of the {@link ChannelHandlerContext} is now active
- */
- void channelActive(ChannelHandlerContext ctx) throws Exception;
-
- /**
- * The {@link Channel} of the {@link ChannelHandlerContext} was registered is now inactive and reached its
- * end of lifetime.
- */
- void channelInactive(ChannelHandlerContext ctx) throws Exception;
-
- /**
- * Invoked when the current {@link Channel} has read a message from the peer.
- */
- void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception;
-
- /**
- * Invoked when the last message read by the current read operation has been consumed by
- * {@link #channelRead(ChannelHandlerContext, Object)}. If {@link ChannelOption#AUTO_READ} is off, no further
- * attempt to read an inbound data from the current {@link Channel} will be made until
- * {@link ChannelHandlerContext#read()} is called.
- */
- void channelReadComplete(ChannelHandlerContext ctx) throws Exception;
-
- /**
- * Gets called if an user event was triggered.
- */
- void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception;
-
- /**
- * Gets called once the writable state of a {@link Channel} changed. You can check the state with
- * {@link Channel#isWritable()}.
- */
- void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception;
-}
diff --git a/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java b/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java
index 580cc82f3e..6e08e9ad8e 100644
--- a/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java
+++ b/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java
@@ -16,95 +16,7 @@
package io.netty.channel;
/**
- * Abstract base class for {@link ChannelInboundHandler} implementations that provides
- * implementations of all of their methods.
- *
- *
- * This implementation just forward the operation to the next {@link ChannelHandler} in the
- * {@link ChannelPipeline}. Sub-classes may override a method implementation to change this.
- *
- *
- * Be aware that messages are not released after the {@link #channelRead(ChannelHandlerContext, Object)}
- * method returns automatically. If you are looking for a {@link ChannelInboundHandler} implementation that
- * releases the received messages automatically, please see {@link SimpleChannelInboundHandler}.
- *
+ * @deprecated Use {@link ChannelHandlerAdapter} instead.
*/
-public class ChannelInboundHandlerAdapter extends ChannelHandlerAdapter implements ChannelInboundHandler {
-
- /**
- * Calls {@link ChannelHandlerContext#fireChannelRegistered()} to forward
- * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
- ctx.fireChannelRegistered();
- }
-
- /**
- * Calls {@link ChannelHandlerContext#fireChannelActive()} to forward
- * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void channelActive(ChannelHandlerContext ctx) throws Exception {
- ctx.fireChannelActive();
- }
-
- /**
- * Calls {@link ChannelHandlerContext#fireChannelInactive()} to forward
- * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void channelInactive(ChannelHandlerContext ctx) throws Exception {
- ctx.fireChannelInactive();
- }
-
- /**
- * Calls {@link ChannelHandlerContext#fireChannelRead(Object)} to forward
- * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
- ctx.fireChannelRead(msg);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#fireChannelReadComplete()} to forward
- * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
- ctx.fireChannelReadComplete();
- }
-
- /**
- * Calls {@link ChannelHandlerContext#fireUserEventTriggered(Object)} to forward
- * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
- ctx.fireUserEventTriggered(evt);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#fireChannelWritabilityChanged()} to forward
- * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
- ctx.fireChannelWritabilityChanged();
- }
-}
+@Deprecated
+public class ChannelInboundHandlerAdapter extends ChannelHandlerAdapter { }
diff --git a/transport/src/main/java/io/netty/channel/ChannelInboundOps.java b/transport/src/main/java/io/netty/channel/ChannelInboundOps.java
index f6b1aebcd4..e1a199f1f1 100644
--- a/transport/src/main/java/io/netty/channel/ChannelInboundOps.java
+++ b/transport/src/main/java/io/netty/channel/ChannelInboundOps.java
@@ -24,8 +24,8 @@ interface ChannelInboundOps {
/**
* A {@link Channel} was registered to its {@link EventLoop}.
*
- * This will result in having the {@link ChannelInboundHandler#channelRegistered(ChannelHandlerContext)} method
- * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
+ * This will result in having the {@link ChannelHandler#channelRegistered(ChannelHandlerContext)} method
+ * called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelInboundOps fireChannelRegistered();
@@ -33,8 +33,8 @@ interface ChannelInboundOps {
/**
* A {@link Channel} is active now, which means it is connected.
*
- * This will result in having the {@link ChannelInboundHandler#channelActive(ChannelHandlerContext)} method
- * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
+ * This will result in having the {@link ChannelHandler#channelActive(ChannelHandlerContext)} method
+ * called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelInboundOps fireChannelActive();
@@ -42,8 +42,8 @@ interface ChannelInboundOps {
/**
* A {@link Channel} is inactive now, which means it is closed.
*
- * This will result in having the {@link ChannelInboundHandler#channelInactive(ChannelHandlerContext)} method
- * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
+ * This will result in having the {@link ChannelHandler#channelInactive(ChannelHandlerContext)} method
+ * called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelInboundOps fireChannelInactive();
@@ -51,8 +51,8 @@ interface ChannelInboundOps {
/**
* A {@link Channel} received an {@link Throwable} in one of its inbound operations.
*
- * This will result in having the {@link ChannelInboundHandler#exceptionCaught(ChannelHandlerContext, Throwable)}
- * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
+ * This will result in having the {@link ChannelHandler#exceptionCaught(ChannelHandlerContext, Throwable)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelInboundOps fireExceptionCaught(Throwable cause);
@@ -60,8 +60,8 @@ interface ChannelInboundOps {
/**
* A {@link Channel} received an user defined event.
*
- * This will result in having the {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)}
- * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
+ * This will result in having the {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelInboundOps fireUserEventTriggered(Object event);
@@ -69,8 +69,8 @@ interface ChannelInboundOps {
/**
* A {@link Channel} received a message.
*
- * This will result in having the {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object)}
- * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
+ * This will result in having the {@link ChannelHandler#channelRead(ChannelHandlerContext, Object)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelInboundOps fireChannelRead(Object msg);
@@ -78,8 +78,8 @@ interface ChannelInboundOps {
ChannelInboundOps fireChannelReadComplete();
/**
- * Triggers an {@link ChannelInboundHandler#channelWritabilityChanged(ChannelHandlerContext)}
- * event to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
+ * Triggers an {@link ChannelHandler#channelWritabilityChanged(ChannelHandlerContext)}
+ * event to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
*/
ChannelInboundOps fireChannelWritabilityChanged();
}
diff --git a/transport/src/main/java/io/netty/channel/ChannelInitializer.java b/transport/src/main/java/io/netty/channel/ChannelInitializer.java
index 043458b554..2145a10bca 100644
--- a/transport/src/main/java/io/netty/channel/ChannelInitializer.java
+++ b/transport/src/main/java/io/netty/channel/ChannelInitializer.java
@@ -22,7 +22,7 @@ import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
/**
- * A special {@link ChannelInboundHandler} which offers an easy way to initialize a {@link Channel} once it was
+ * A special {@link ChannelHandler} which offers an easy way to initialize a {@link Channel} once it was
* registered to its {@link EventLoop}.
*
* Implementations are most often used in the context of {@link Bootstrap#handler(ChannelHandler)} ,
@@ -47,7 +47,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory;
* @param A sub-type of {@link Channel}
*/
@Sharable
-public abstract class ChannelInitializer extends ChannelInboundHandlerAdapter {
+public abstract class ChannelInitializer extends ChannelHandlerAdapter {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ChannelInitializer.class);
diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java b/transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java
deleted file mode 100644
index a02f780bca..0000000000
--- a/transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2012 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.channel;
-
-import java.net.SocketAddress;
-
-/**
- * {@link ChannelHandler} which will get notified for IO-outbound-operations.
- */
-public interface ChannelOutboundHandler extends ChannelHandler {
- /**
- * Called once a bind operation is made.
- *
- * @param ctx the {@link ChannelHandlerContext} for which the bind operation is made
- * @param localAddress the {@link SocketAddress} to which it should bound
- * @param promise the {@link ChannelPromise} to notify once the operation completes
- * @throws Exception thrown if an error accour
- */
- void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception;
-
- /**
- * Called once a connect operation is made.
- *
- * @param ctx the {@link ChannelHandlerContext} for which the connect operation is made
- * @param remoteAddress the {@link SocketAddress} to which it should connect
- * @param localAddress the {@link SocketAddress} which is used as source on connect
- * @param promise the {@link ChannelPromise} to notify once the operation completes
- * @throws Exception thrown if an error accour
- */
- void connect(
- ChannelHandlerContext ctx, SocketAddress remoteAddress,
- SocketAddress localAddress, ChannelPromise promise) throws Exception;
-
- /**
- * Called once a disconnect operation is made.
- *
- * @param ctx the {@link ChannelHandlerContext} for which the disconnect operation is made
- * @param promise the {@link ChannelPromise} to notify once the operation completes
- * @throws Exception thrown if an error accour
- */
- void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception;
-
- /**
- * Called once a close operation is made.
- *
- * @param ctx the {@link ChannelHandlerContext} for which the close operation is made
- * @param promise the {@link ChannelPromise} to notify once the operation completes
- * @throws Exception thrown if an error accour
- */
- void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception;
-
- /**
- * Intercepts {@link ChannelHandlerContext#read()}.
- */
- void read(ChannelHandlerContext ctx) throws Exception;
-
- /**
- * Called once a write operation is made. The write operation will write the messages through the
- * {@link ChannelPipeline}. Those are then ready to be flushed to the actual {@link Channel} once
- * {@link Channel#flush()} is called
- *
- * @param ctx the {@link ChannelHandlerContext} for which the write operation is made
- * @param msg the message to write
- * @param promise the {@link ChannelPromise} to notify once the operation completes
- * @throws Exception thrown if an error accour
- */
- void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception;
-
- /**
- * Called once a flush operation is made. The flush operation will try to flush out all previous written messages
- * that are pending.
- *
- * @param ctx the {@link ChannelHandlerContext} for which the flush operation is made
- * @throws Exception thrown if an error accour
- */
- void flush(ChannelHandlerContext ctx) throws Exception;
-}
diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java b/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java
index 2ac728ac77..73c2271dba 100644
--- a/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java
+++ b/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java
@@ -15,92 +15,8 @@
*/
package io.netty.channel;
-import java.net.SocketAddress;
-
/**
- * Skelton implementation of a {@link ChannelOutboundHandler}. This implementation just forwards each method call via
- * the {@link ChannelHandlerContext}.
+ * @deprecated Use {@link ChannelHandlerAdapter} instead.
*/
-public class ChannelOutboundHandlerAdapter extends ChannelHandlerAdapter implements ChannelOutboundHandler {
-
- /**
- * Calls {@link ChannelHandlerContext#bind(SocketAddress, ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void bind(ChannelHandlerContext ctx, SocketAddress localAddress,
- ChannelPromise promise) throws Exception {
- ctx.bind(localAddress, promise);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress,
- SocketAddress localAddress, ChannelPromise promise) throws Exception {
- ctx.connect(remoteAddress, localAddress, promise);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#disconnect(ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise)
- throws Exception {
- ctx.disconnect(promise);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#close(ChannelPromise)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void close(ChannelHandlerContext ctx, ChannelPromise promise)
- throws Exception {
- ctx.close(promise);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#read()} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void read(ChannelHandlerContext ctx) throws Exception {
- ctx.read();
- }
-
- /**
- * Calls {@link ChannelHandlerContext#write(Object)} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
- ctx.write(msg, promise);
- }
-
- /**
- * Calls {@link ChannelHandlerContext#flush()} to forward
- * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}.
- *
- * Sub-classes may override this method to change behavior.
- */
- @Override
- public void flush(ChannelHandlerContext ctx) throws Exception {
- ctx.flush();
- }
-}
+@Deprecated
+public class ChannelOutboundHandlerAdapter extends ChannelHandlerAdapter { }
diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundOps.java b/transport/src/main/java/io/netty/channel/ChannelOutboundOps.java
index 56ebd04f13..6189492d98 100644
--- a/transport/src/main/java/io/netty/channel/ChannelOutboundOps.java
+++ b/transport/src/main/java/io/netty/channel/ChannelOutboundOps.java
@@ -28,8 +28,8 @@ interface ChannelOutboundOps {
* completes, either because the operation was successful or because of an error.
*
* This will result in having the
- * {@link ChannelOutboundHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)} method
- * called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)} method
+ * called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture bind(SocketAddress localAddress);
@@ -43,8 +43,8 @@ interface ChannelOutboundOps {
* will be used.
*
* This will result in having the
- * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture connect(SocketAddress remoteAddress);
@@ -55,8 +55,8 @@ interface ChannelOutboundOps {
* an error.
*
* This will result in having the
- * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress);
@@ -66,8 +66,8 @@ interface ChannelOutboundOps {
* either because the operation was successful or because of an error.
*
* This will result in having the
- * {@link ChannelOutboundHandler#disconnect(ChannelHandlerContext, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#disconnect(ChannelHandlerContext, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture disconnect();
@@ -80,8 +80,8 @@ interface ChannelOutboundOps {
* After it is closed it is not possible to reuse it again.
*
* This will result in having the
- * {@link ChannelOutboundHandler#close(ChannelHandlerContext, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#close(ChannelHandlerContext, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture close();
@@ -93,8 +93,8 @@ interface ChannelOutboundOps {
* The given {@link ChannelPromise} will be notified.
*
* This will result in having the
- * {@link ChannelOutboundHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)} method
- * called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)} method
+ * called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise);
@@ -111,8 +111,8 @@ interface ChannelOutboundOps {
* will be used.
*
* This will result in having the
- * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise);
@@ -125,8 +125,8 @@ interface ChannelOutboundOps {
* The given {@link ChannelPromise} will be notified and also returned.
*
* This will result in having the
- * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise);
@@ -138,8 +138,8 @@ interface ChannelOutboundOps {
* The given {@link ChannelPromise} will be notified.
*
* This will result in having the
- * {@link ChannelOutboundHandler#disconnect(ChannelHandlerContext, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#disconnect(ChannelHandlerContext, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture disconnect(ChannelPromise promise);
@@ -153,22 +153,22 @@ interface ChannelOutboundOps {
* The given {@link ChannelPromise} will be notified.
*
* This will result in having the
- * {@link ChannelOutboundHandler#close(ChannelHandlerContext, ChannelPromise)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#close(ChannelHandlerContext, ChannelPromise)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelFuture close(ChannelPromise promise);
/**
* Request to Read data from the {@link Channel} into the first inbound buffer, triggers an
- * {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object)} event if data was
+ * {@link ChannelHandler#channelRead(ChannelHandlerContext, Object)} event if data was
* read, and triggers a
- * {@link ChannelInboundHandler#channelReadComplete(ChannelHandlerContext) channelReadComplete} event so the
+ * {@link ChannelHandler#channelReadComplete(ChannelHandlerContext) channelReadComplete} event so the
* handler can decide to continue reading. If there's a pending read operation already, this method does nothing.
*
* This will result in having the
- * {@link ChannelOutboundHandler#read(ChannelHandlerContext)}
- * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
+ * {@link ChannelHandler#read(ChannelHandlerContext)}
+ * method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
* {@link Channel}.
*/
ChannelOutboundOps read();
diff --git a/transport/src/main/java/io/netty/channel/ChannelPipeline.java b/transport/src/main/java/io/netty/channel/ChannelPipeline.java
index dcdef66016..428ee01c05 100644
--- a/transport/src/main/java/io/netty/channel/ChannelPipeline.java
+++ b/transport/src/main/java/io/netty/channel/ChannelPipeline.java
@@ -42,11 +42,11 @@ import java.util.NoSuchElementException;
*
How an event flows in a pipeline
*
* The following diagram describes how I/O events are processed by {@link ChannelHandler}s in a {@link ChannelPipeline}
- * typically. An I/O event is handled by either a {@link ChannelInboundHandler} or a {@link ChannelOutboundHandler}
- * and be forwarded to its closest handler by calling the event propagation methods defined in
- * {@link ChannelHandlerContext}, such as {@link ChannelHandlerContext#fireChannelRead(Object)} and
- * {@link ChannelHandlerContext#write(Object)}.
- *
+ * typically. An I/O event is handled by a {@link ChannelHandler} and is forwarded by the {@link ChannelHandler} which
+ * handled the event to the {@link ChannelHandler} which is placed right next to it. A {@link ChannelHandler} can also
+ * trigger an arbitrary I/O event if necessary. To forward or trigger an event, a {@link ChannelHandler} calls the
+ * event propagation methods defined in {@link ChannelHandlerContext}, such as
+ * {@link ChannelHandlerContext#fireChannelRead(Object)} and {@link ChannelHandlerContext#write(Object)}.
*
- * An inbound event is handled by the inbound handlers in the bottom-up direction as shown on the left side of the
- * diagram. An inbound handler usually handles the inbound data generated by the I/O thread on the bottom of the
- * diagram. The inbound data is often read from a remote peer via the actual input operation such as
- * {@link SocketChannel#read(ByteBuffer)}. If an inbound event goes beyond the top inbound handler, it is discarded
- * silently, or logged if it needs your attention.
+ * An inbound event is handled by the {@link ChannelHandler}s in the bottom-up direction as shown on the left side of
+ * the diagram. An inbound event is usually triggered by the I/O thread on the bottom of the diagram so that the
+ * {@link ChannelHandler}s are notified when the state of a {@link Channel} changes (e.g. newly established connections
+ * and closed connections) or the inbound data was read from a remote peer. If an inbound event goes beyond the
+ * {@link ChannelHandler} at the top of the diagram, it is discarded and logged, depending on your loglevel.
+ *
*
- * An outbound event is handled by the outbound handler in the top-down direction as shown on the right side of the
- * diagram. An outbound handler usually generates or transforms the outbound traffic such as write requests.
- * If an outbound event goes beyond the bottom outbound handler, it is handled by an I/O thread associated with the
- * {@link Channel}. The I/O thread often performs the actual output operation such as
- * {@link SocketChannel#write(ByteBuffer)}.
+ * An outbound event is handled by the {@link ChannelHandler}s in the top-down direction as shown on the right side of
+ * the diagram. An outbound event is usually triggered by your code that requests an outbound I/O operation, such as
+ * a write request and a connection attempt. If an outbound event goes beyond the {@link ChannelHandler} at the
+ * bottom of the diagram, it is handled by an I/O thread associated with the {@link Channel}. The I/O thread often
+ * performs the actual output operation such as {@link SocketChannel#write(ByteBuffer)}.
*
- * For example, let us assume that we created the following pipeline:
- *
- * {@link ChannelPipeline} p = ...;
- * p.addLast("1", new InboundHandlerA());
- * p.addLast("2", new InboundHandlerB());
- * p.addLast("3", new OutboundHandlerA());
- * p.addLast("4", new OutboundHandlerB());
- * p.addLast("5", new InboundOutboundHandlerX());
- *
- * In the example above, the class whose name starts with {@code Inbound} means it is an inbound handler.
- * The class whose name starts with {@code Outbound} means it is a outbound handler.
- *
- * In the given example configuration, the handler evaluation order is 1, 2, 3, 4, 5 when an event goes inbound.
- * When an event goes outbound, the order is 5, 4, 3, 2, 1. On top of this principle, {@link ChannelPipeline} skips
- * the evaluation of certain handlers to shorten the stack depth:
- *
- *
3 and 4 don't implement {@link ChannelInboundHandler}, and therefore the actual evaluation order of an inbound
- * event will be: 1, 2, and 5.
- *
1 and 2 don't implement {@link ChannelOutboundHandler}, and therefore the actual evaluation order of a
- * outbound event will be: 5, 4, and 3.
- *
If 5 implements both {@link ChannelInboundHandler} and {@link ChannelOutboundHandler}, the evaluation order of
- * an inbound and a outbound event could be 125 and 543 respectively.
- *
*
*
Forwarding an event to the next handler
*
- * As you might noticed in the diagram shows, a handler has to invoke the event propagation methods in
+ * As explained briefly above, a {@link ChannelHandler} has to invoke the event propagation methods in
* {@link ChannelHandlerContext} to forward an event to its next handler. Those methods include:
*
*
Inbound event propagation methods:
@@ -156,7 +134,7 @@ import java.util.NoSuchElementException;
* and the following example shows how the event propagation is usually done:
*
*
- * public class MyInboundHandler extends {@link ChannelInboundHandlerAdapter} {
+ * public class MyInboundHandler extends {@link ChannelHandlerAdapter} {
* {@code @Override}
* public void channelActive({@link ChannelHandlerContext} ctx) {
* System.out.println("Connected!");
@@ -164,7 +142,7 @@ import java.util.NoSuchElementException;
* }
* }
*
- * public clas MyOutboundHandler extends {@link ChannelOutboundHandlerAdapter} {
+ * public clas MyOutboundHandler extends {@link ChannelHandlerAdapter} {
* {@code @Override}
* public void close({@link ChannelHandlerContext} ctx, {@link ChannelPromise} promise) {
* System.out.println("Closing ..");
diff --git a/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java b/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java
deleted file mode 100644
index 4e9e925c68..0000000000
--- a/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2012 The Netty Project
- *
- * The Netty Project licenses this file to you under the Apache License,
- * version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package io.netty.channel;
-
-import java.net.SocketAddress;
-
-/**
- * Combines a {@link ChannelInboundHandler} and a {@link ChannelOutboundHandler} into one {@link ChannelHandler}.
- *
- */
-public class CombinedChannelDuplexHandler
- extends ChannelDuplexHandler {
-
- private I inboundHandler;
- private O outboundHandler;
-
- /**
- * Creates a new uninitialized instance. A class that extends this handler must invoke
- * {@link #init(ChannelInboundHandler, ChannelOutboundHandler)} before adding this handler into a
- * {@link ChannelPipeline}.
- */
- protected CombinedChannelDuplexHandler() { }
-
- /**
- * Creates a new instance that combines the specified two handlers into one.
- */
- public CombinedChannelDuplexHandler(I inboundHandler, O outboundHandler) {
- init(inboundHandler, outboundHandler);
- }
-
- /**
- * Initialized this handler with the specified handlers.
- *
- * @throws IllegalStateException if this handler was not constructed via the default constructor or
- * if this handler does not implement all required handler interfaces
- * @throws IllegalArgumentException if the specified handlers cannot be combined into one due to a conflict
- * in the type hierarchy
- */
- protected final void init(I inboundHandler, O outboundHandler) {
- validate(inboundHandler, outboundHandler);
- this.inboundHandler = inboundHandler;
- this.outboundHandler = outboundHandler;
- }
-
- @SuppressWarnings("InstanceofIncompatibleInterface")
- private void validate(I inboundHandler, O outboundHandler) {
- if (this.inboundHandler != null) {
- throw new IllegalStateException(
- "init() can not be invoked if " + CombinedChannelDuplexHandler.class.getSimpleName() +
- " was constructed with non-default constructor.");
- }
-
- if (inboundHandler == null) {
- throw new NullPointerException("inboundHandler");
- }
- if (outboundHandler == null) {
- throw new NullPointerException("outboundHandler");
- }
- if (inboundHandler instanceof ChannelOutboundHandler) {
- throw new IllegalArgumentException(
- "inboundHandler must not implement " +
- ChannelOutboundHandler.class.getSimpleName() + " to get combined.");
- }
- if (outboundHandler instanceof ChannelInboundHandler) {
- throw new IllegalArgumentException(
- "outboundHandler must not implement " +
- ChannelInboundHandler.class.getSimpleName() + " to get combined.");
- }
- }
-
- protected final I inboundHandler() {
- return inboundHandler;
- }
-
- protected final O outboundHandler() {
- return outboundHandler;
- }
-
- @Override
- public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
- if (inboundHandler == null) {
- throw new IllegalStateException(
- "init() must be invoked before being added to a " + ChannelPipeline.class.getSimpleName() +
- " if " + CombinedChannelDuplexHandler.class.getSimpleName() +
- " was constructed with the default constructor.");
- }
- try {
- inboundHandler.handlerAdded(ctx);
- } finally {
- outboundHandler.handlerAdded(ctx);
- }
- }
-
- @Override
- public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
- try {
- inboundHandler.handlerRemoved(ctx);
- } finally {
- outboundHandler.handlerRemoved(ctx);
- }
- }
-
- @Override
- public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
- inboundHandler.channelRegistered(ctx);
- }
-
- @Override
- public void channelActive(ChannelHandlerContext ctx) throws Exception {
- inboundHandler.channelActive(ctx);
- }
-
- @Override
- public void channelInactive(ChannelHandlerContext ctx) throws Exception {
- inboundHandler.channelInactive(ctx);
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- inboundHandler.exceptionCaught(ctx, cause);
- }
-
- @Override
- public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
- inboundHandler.userEventTriggered(ctx, evt);
- }
-
- @Override
- public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
- inboundHandler.channelRead(ctx, msg);
- }
-
- @Override
- public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
- inboundHandler.channelReadComplete(ctx);
- }
-
- @Override
- public void bind(
- ChannelHandlerContext ctx,
- SocketAddress localAddress, ChannelPromise promise) throws Exception {
- outboundHandler.bind(ctx, localAddress, promise);
- }
-
- @Override
- public void connect(
- ChannelHandlerContext ctx,
- SocketAddress remoteAddress, SocketAddress localAddress,
- ChannelPromise promise) throws Exception {
- outboundHandler.connect(ctx, remoteAddress, localAddress, promise);
- }
-
- @Override
- public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
- outboundHandler.disconnect(ctx, promise);
- }
-
- @Override
- public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
- outboundHandler.close(ctx, promise);
- }
-
- @Override
- public void read(ChannelHandlerContext ctx) throws Exception {
- outboundHandler.read(ctx);
- }
-
- @Override
- public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
- outboundHandler.write(ctx, msg, promise);
- }
-
- @Override
- public void flush(ChannelHandlerContext ctx) throws Exception {
- outboundHandler.flush(ctx);
- }
-
- @Override
- public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
- inboundHandler.channelWritabilityChanged(ctx);
- }
-}
diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java
index ed75cc37cd..738d5cea6b 100644
--- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java
+++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java
@@ -16,13 +16,160 @@
package io.netty.channel;
import io.netty.buffer.ByteBufAllocator;
+import io.netty.channel.ChannelHandler.Skip;
import io.netty.util.DefaultAttributeMap;
import io.netty.util.concurrent.EventExecutor;
+import io.netty.util.internal.PlatformDependent;
import java.net.SocketAddress;
+import java.util.WeakHashMap;
final class DefaultChannelHandlerContext extends DefaultAttributeMap implements ChannelHandlerContext {
+ // This class keeps an integer member field 'skipFlags' whose each bit tells if the corresponding handler method
+ // is annotated with @Skip. 'skipFlags' is retrieved in runtime via the reflection API and is cached.
+ // The following constants signify which bit of 'skipFlags' corresponds to which handler method:
+
+ static final int MASK_HANDLER_ADDED = 1;
+ static final int MASK_HANDLER_REMOVED = 1 << 1;
+ private static final int MASK_EXCEPTION_CAUGHT = 1 << 2;
+ private static final int MASK_CHANNEL_REGISTERED = 1 << 3;
+ private static final int MASK_CHANNEL_ACTIVE = 1 << 4;
+ private static final int MASK_CHANNEL_INACTIVE = 1 << 5;
+ private static final int MASK_CHANNEL_READ = 1 << 6;
+ private static final int MASK_CHANNEL_READ_COMPLETE = 1 << 7;
+ private static final int MASK_CHANNEL_WRITABILITY_CHANGED = 1 << 8;
+ private static final int MASK_USER_EVENT_TRIGGERED = 1 << 9;
+ private static final int MASK_BIND = 1 << 10;
+ private static final int MASK_CONNECT = 1 << 11;
+ private static final int MASK_DISCONNECT = 1 << 12;
+ private static final int MASK_CLOSE = 1 << 13;
+ private static final int MASK_READ = 1 << 14;
+ private static final int MASK_WRITE = 1 << 15;
+ private static final int MASK_FLUSH = 1 << 16;
+
+ /**
+ * Cache the result of the costly generation of {@link #skipFlags} in the partitioned synchronized
+ * {@link WeakHashMap}.
+ */
+ @SuppressWarnings("unchecked")
+ private static final WeakHashMap, Integer>[] skipFlagsCache =
+ new WeakHashMap[Runtime.getRuntime().availableProcessors()];
+
+ static {
+ for (int i = 0; i < skipFlagsCache.length; i ++) {
+ skipFlagsCache[i] = new WeakHashMap, Integer>();
+ }
+ }
+
+ /**
+ * Returns an integer bitset that tells which handler methods were annotated with {@link Skip}.
+ * It gets the value from {@link #skipFlagsCache} if an handler of the same type were queried before.
+ * Otherwise, it delegates to {@link #skipFlags0(Class)} to get it.
+ */
+ private static int skipFlags(ChannelHandler handler) {
+ WeakHashMap, Integer> cache =
+ skipFlagsCache[(int) (Thread.currentThread().getId() % skipFlagsCache.length)];
+ Class extends ChannelHandler> handlerType = handler.getClass();
+ int flagsVal;
+ synchronized (cache) {
+ Integer flags = cache.get(handlerType);
+ if (flags != null) {
+ flagsVal = flags;
+ } else {
+ flagsVal = skipFlags0(handlerType);
+ cache.put(handlerType, Integer.valueOf(flagsVal));
+ }
+ }
+
+ return flagsVal;
+ }
+
+ /**
+ * Determines the {@link #skipFlags} of the specified {@code handlerType} using the reflection API.
+ */
+ private static int skipFlags0(Class extends ChannelHandler> handlerType) {
+ int flags = 0;
+ try {
+ if (handlerType.getMethod(
+ "handlerAdded", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_HANDLER_ADDED;
+ }
+ if (handlerType.getMethod(
+ "handlerRemoved", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_HANDLER_REMOVED;
+ }
+ if (handlerType.getMethod(
+ "exceptionCaught", ChannelHandlerContext.class, Throwable.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_EXCEPTION_CAUGHT;
+ }
+ if (handlerType.getMethod(
+ "channelRegistered", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CHANNEL_REGISTERED;
+ }
+ if (handlerType.getMethod(
+ "channelActive", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CHANNEL_ACTIVE;
+ }
+ if (handlerType.getMethod(
+ "channelInactive", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CHANNEL_INACTIVE;
+ }
+ if (handlerType.getMethod(
+ "channelRead", ChannelHandlerContext.class, Object.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CHANNEL_READ;
+ }
+ if (handlerType.getMethod(
+ "channelReadComplete", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CHANNEL_READ_COMPLETE;
+ }
+ if (handlerType.getMethod(
+ "channelWritabilityChanged", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CHANNEL_WRITABILITY_CHANGED;
+ }
+ if (handlerType.getMethod(
+ "userEventTriggered", ChannelHandlerContext.class, Object.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_USER_EVENT_TRIGGERED;
+ }
+ if (handlerType.getMethod(
+ "bind", ChannelHandlerContext.class,
+ SocketAddress.class, ChannelPromise.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_BIND;
+ }
+ if (handlerType.getMethod(
+ "connect", ChannelHandlerContext.class, SocketAddress.class, SocketAddress.class,
+ ChannelPromise.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CONNECT;
+ }
+ if (handlerType.getMethod(
+ "disconnect", ChannelHandlerContext.class, ChannelPromise.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_DISCONNECT;
+ }
+ if (handlerType.getMethod(
+ "close", ChannelHandlerContext.class, ChannelPromise.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_CLOSE;
+ }
+ if (handlerType.getMethod(
+ "read", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_READ;
+ }
+ if (handlerType.getMethod(
+ "write", ChannelHandlerContext.class,
+ Object.class, ChannelPromise.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_WRITE;
+ }
+ if (handlerType.getMethod(
+ "flush", ChannelHandlerContext.class).isAnnotationPresent(Skip.class)) {
+ flags |= MASK_FLUSH;
+ }
+ } catch (Exception e) {
+ // Should never reach here.
+ PlatformDependent.throwException(e);
+ }
+
+ return flags;
+ }
+
volatile DefaultChannelHandlerContext next;
volatile DefaultChannelHandlerContext prev;
@@ -32,6 +179,8 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
private final ChannelHandler handler;
private boolean removed;
+ final int skipFlags;
+
// Will be set to null if no child executor should be used, otherwise it will be set to the
// child executor.
final ChannelHandlerInvoker invoker;
@@ -58,6 +207,8 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
this.name = name;
this.handler = handler;
+ skipFlags = skipFlags(handler);
+
if (invoker == null) {
this.invoker = channel.unsafe().invoker();
} else {
@@ -110,6 +261,11 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
return invoker.executor();
}
+ @Override
+ public ChannelHandlerInvoker invoker() {
+ return invoker;
+ }
+
@Override
public ChannelHandler handler() {
return handler;
@@ -122,56 +278,56 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
@Override
public ChannelHandlerContext fireChannelRegistered() {
- DefaultChannelHandlerContext next = findContextInbound();
+ DefaultChannelHandlerContext next = findContextInbound(MASK_CHANNEL_REGISTERED);
next.invoker.invokeChannelRegistered(next);
return this;
}
@Override
public ChannelHandlerContext fireChannelActive() {
- DefaultChannelHandlerContext next = findContextInbound();
+ DefaultChannelHandlerContext next = findContextInbound(MASK_CHANNEL_ACTIVE);
next.invoker.invokeChannelActive(next);
return this;
}
@Override
public ChannelHandlerContext fireChannelInactive() {
- DefaultChannelHandlerContext next = findContextInbound();
+ DefaultChannelHandlerContext next = findContextInbound(MASK_CHANNEL_INACTIVE);
next.invoker.invokeChannelInactive(next);
return this;
}
@Override
public ChannelHandlerContext fireExceptionCaught(Throwable cause) {
- DefaultChannelHandlerContext next = this.next;
+ DefaultChannelHandlerContext next = findContextInbound(MASK_EXCEPTION_CAUGHT);
next.invoker.invokeExceptionCaught(next, cause);
return this;
}
@Override
public ChannelHandlerContext fireUserEventTriggered(Object event) {
- DefaultChannelHandlerContext next = findContextInbound();
+ DefaultChannelHandlerContext next = findContextInbound(MASK_USER_EVENT_TRIGGERED);
next.invoker.invokeUserEventTriggered(next, event);
return this;
}
@Override
public ChannelHandlerContext fireChannelRead(Object msg) {
- DefaultChannelHandlerContext next = findContextInbound();
+ DefaultChannelHandlerContext next = findContextInbound(MASK_CHANNEL_READ);
next.invoker.invokeChannelRead(next, msg);
return this;
}
@Override
public ChannelHandlerContext fireChannelReadComplete() {
- DefaultChannelHandlerContext next = findContextInbound();
+ DefaultChannelHandlerContext next = findContextInbound(MASK_CHANNEL_READ_COMPLETE);
next.invoker.invokeChannelReadComplete(next);
return this;
}
@Override
public ChannelHandlerContext fireChannelWritabilityChanged() {
- DefaultChannelHandlerContext next = findContextInbound();
+ DefaultChannelHandlerContext next = findContextInbound(MASK_CHANNEL_WRITABILITY_CHANGED);
next.invoker.invokeChannelWritabilityChanged(next);
return this;
}
@@ -203,7 +359,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
@Override
public ChannelFuture bind(final SocketAddress localAddress, final ChannelPromise promise) {
- DefaultChannelHandlerContext next = findContextOutbound();
+ DefaultChannelHandlerContext next = findContextOutbound(MASK_BIND);
next.invoker.invokeBind(next, localAddress, promise);
return promise;
}
@@ -215,7 +371,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
@Override
public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) {
- DefaultChannelHandlerContext next = findContextOutbound();
+ DefaultChannelHandlerContext next = findContextOutbound(MASK_CONNECT);
next.invoker.invokeConnect(next, remoteAddress, localAddress, promise);
return promise;
}
@@ -226,21 +382,21 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
return close(promise);
}
- DefaultChannelHandlerContext next = findContextOutbound();
+ DefaultChannelHandlerContext next = findContextOutbound(MASK_DISCONNECT);
next.invoker.invokeDisconnect(next, promise);
return promise;
}
@Override
public ChannelFuture close(ChannelPromise promise) {
- DefaultChannelHandlerContext next = findContextOutbound();
+ DefaultChannelHandlerContext next = findContextOutbound(MASK_CLOSE);
next.invoker.invokeClose(next, promise);
return promise;
}
@Override
public ChannelHandlerContext read() {
- DefaultChannelHandlerContext next = findContextOutbound();
+ DefaultChannelHandlerContext next = findContextOutbound(MASK_READ);
next.invoker.invokeRead(next);
return this;
}
@@ -252,22 +408,25 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
@Override
public ChannelFuture write(Object msg, ChannelPromise promise) {
- DefaultChannelHandlerContext next = findContextOutbound();
+ DefaultChannelHandlerContext next = findContextOutbound(MASK_WRITE);
next.invoker.invokeWrite(next, msg, promise);
return promise;
}
@Override
public ChannelHandlerContext flush() {
- DefaultChannelHandlerContext next = findContextOutbound();
+ DefaultChannelHandlerContext next = findContextOutbound(MASK_FLUSH);
next.invoker.invokeFlush(next);
return this;
}
@Override
public ChannelFuture writeAndFlush(Object msg, ChannelPromise promise) {
- DefaultChannelHandlerContext next = findContextOutbound();
- next.invoker.invokeWriteAndFlush(next, msg, promise);
+ DefaultChannelHandlerContext next;
+ next = findContextOutbound(MASK_WRITE);
+ next.invoker.invokeWrite(next, msg, promise);
+ next = findContextOutbound(MASK_FLUSH);
+ next.invoker.invokeFlush(next);
return promise;
}
@@ -300,19 +459,19 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
return new FailedChannelFuture(channel(), executor(), cause);
}
- private DefaultChannelHandlerContext findContextInbound() {
+ private DefaultChannelHandlerContext findContextInbound(int mask) {
DefaultChannelHandlerContext ctx = this;
do {
ctx = ctx.next;
- } while (!(ctx.handler instanceof ChannelInboundHandler));
+ } while ((ctx.skipFlags & mask) != 0);
return ctx;
}
- private DefaultChannelHandlerContext findContextOutbound() {
+ private DefaultChannelHandlerContext findContextOutbound(int mask) {
DefaultChannelHandlerContext ctx = this;
do {
ctx = ctx.prev;
- } while (!(ctx.handler instanceof ChannelOutboundHandler));
+ } while ((ctx.skipFlags & mask) != 0);
return ctx;
}
diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerInvoker.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerInvoker.java
index 5c729bf74b..1dd54b1933 100644
--- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerInvoker.java
+++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerInvoker.java
@@ -283,16 +283,9 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
}
validatePromise(ctx, promise, true);
- invokeWrite(ctx, msg, false, promise);
- }
-
- private void invokeWrite(ChannelHandlerContext ctx, Object msg, boolean flush, ChannelPromise promise) {
if (executor.inEventLoop()) {
invokeWriteNow(ctx, msg, promise);
- if (flush) {
- invokeFlushNow(ctx);
- }
} else {
AbstractChannel channel = (AbstractChannel) ctx.channel();
int size = channel.estimatorHandle().size(msg);
@@ -303,7 +296,7 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
buffer.incrementPendingOutboundBytes(size);
}
}
- safeExecuteOutbound(WriteTask.newInstance(ctx, msg, size, flush, promise), promise, msg);
+ safeExecuteOutbound(WriteTask.newInstance(ctx, msg, size, promise), promise, msg);
}
}
@@ -326,17 +319,6 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
}
}
- @Override
- public void invokeWriteAndFlush(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
- if (msg == null) {
- throw new NullPointerException("msg");
- }
-
- validatePromise(ctx, promise, true);
-
- invokeWrite(ctx, msg, true, promise);
- }
-
private static void validatePromise(ChannelHandlerContext ctx, ChannelPromise promise, boolean allowVoidPromise) {
if (ctx == null) {
throw new NullPointerException("ctx");
@@ -406,7 +388,6 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
private Object msg;
private ChannelPromise promise;
private int size;
- private boolean flush;
private static final Recycler RECYCLER = new Recycler() {
@Override
@@ -416,13 +397,12 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
};
private static WriteTask newInstance(
- ChannelHandlerContext ctx, Object msg, int size, boolean flush, ChannelPromise promise) {
+ ChannelHandlerContext ctx, Object msg, int size, ChannelPromise promise) {
WriteTask task = RECYCLER.get();
task.ctx = ctx;
task.msg = msg;
task.promise = promise;
task.size = size;
- task.flush = flush;
return task;
}
@@ -443,9 +423,6 @@ public class DefaultChannelHandlerInvoker implements ChannelHandlerInvoker {
}
}
invokeWriteNow(ctx, msg, promise);
- if (flush) {
- invokeFlushNow(ctx);
- }
} finally {
// Set to null so the GC can collect them directly
ctx = null;
diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java
index ec8256a971..5dc6e4a797 100644
--- a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java
+++ b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java
@@ -324,7 +324,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
return invoker;
}
- private String generateName(ChannelHandler handler) {
+ String generateName(ChannelHandler handler) {
WeakHashMap, String> cache = nameCaches[(int) (Thread.currentThread().getId() % nameCaches.length)];
Class> handlerType = handler.getClass();
String name;
@@ -529,7 +529,11 @@ final class DefaultChannelPipeline implements ChannelPipeline {
}
}
- private void callHandlerAdded(final ChannelHandlerContext ctx) {
+ private void callHandlerAdded(final DefaultChannelHandlerContext ctx) {
+ if ((ctx.skipFlags & DefaultChannelHandlerContext.MASK_HANDLER_ADDED) != 0) {
+ return;
+ }
+
if (ctx.channel().isRegistered() && !ctx.executor().inEventLoop()) {
ctx.executor().execute(new Runnable() {
@Override
@@ -542,13 +546,13 @@ final class DefaultChannelPipeline implements ChannelPipeline {
callHandlerAdded0(ctx);
}
- private void callHandlerAdded0(final ChannelHandlerContext ctx) {
+ private void callHandlerAdded0(final DefaultChannelHandlerContext ctx) {
try {
ctx.handler().handlerAdded(ctx);
} catch (Throwable t) {
boolean removed = false;
try {
- remove((DefaultChannelHandlerContext) ctx);
+ remove(ctx);
removed = true;
} catch (Throwable t2) {
if (logger.isWarnEnabled()) {
@@ -569,6 +573,10 @@ final class DefaultChannelPipeline implements ChannelPipeline {
}
private void callHandlerRemoved(final DefaultChannelHandlerContext ctx) {
+ if ((ctx.skipFlags & DefaultChannelHandlerContext.MASK_HANDLER_REMOVED) != 0) {
+ return;
+ }
+
if (ctx.channel().isRegistered() && !ctx.executor().inEventLoop()) {
ctx.executor().execute(new Runnable() {
@Override
@@ -970,7 +978,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
}
// A special catch-all handler that handles both bytes and messages.
- static final class TailHandler implements ChannelInboundHandler {
+ static final class TailHandler extends ChannelHandlerAdapter {
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception { }
@@ -984,12 +992,6 @@ final class DefaultChannelPipeline implements ChannelPipeline {
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { }
- @Override
- public void handlerAdded(ChannelHandlerContext ctx) throws Exception { }
-
- @Override
- public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { }
-
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { }
@@ -1015,7 +1017,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { }
}
- static final class HeadHandler implements ChannelOutboundHandler {
+ static final class HeadHandler extends ChannelHandlerAdapter {
protected final Unsafe unsafe;
@@ -1023,16 +1025,6 @@ final class DefaultChannelPipeline implements ChannelPipeline {
this.unsafe = unsafe;
}
- @Override
- public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
- // NOOP
- }
-
- @Override
- public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
- // NOOP
- }
-
@Override
public void bind(
ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
@@ -1072,10 +1064,5 @@ final class DefaultChannelPipeline implements ChannelPipeline {
public void flush(ChannelHandlerContext ctx) throws Exception {
unsafe.flush();
}
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- ctx.fireExceptionCaught(cause);
- }
}
}
diff --git a/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java b/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java
index 5ecafc7c11..af41525bf0 100644
--- a/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java
+++ b/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java
@@ -19,7 +19,7 @@ import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.TypeParameterMatcher;
/**
- * {@link ChannelInboundHandlerAdapter} which allows to explicit only handle a specific type of messages.
+ * {@link ChannelHandler} which allows to explicit only handle a specific type of messages.
*
* For example here is an implementation which only handle {@link String} messages.
*
@@ -43,7 +43,7 @@ import io.netty.util.internal.TypeParameterMatcher;
* {@link #messageReceived(ChannelHandlerContext, Object)}.
*
*/
-public abstract class SimpleChannelInboundHandler extends ChannelInboundHandlerAdapter {
+public abstract class SimpleChannelInboundHandler extends ChannelHandlerAdapter {
private final TypeParameterMatcher matcher;
private final boolean autoRelease;
@@ -87,7 +87,7 @@ public abstract class SimpleChannelInboundHandler extends ChannelInboundHandl
/**
* Returns {@code true} if the given message should be handled. If {@code false} it will be passed to the next
- * {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
+ * {@link ChannelHandler} in the {@link ChannelPipeline}.
*/
public boolean acceptInboundMessage(Object msg) throws Exception {
return matcher.match(msg);
diff --git a/transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java b/transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java
index 4c3b955441..e4ead9fea3 100644
--- a/transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java
+++ b/transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java
@@ -20,8 +20,8 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.ChannelPipeline;
@@ -345,7 +345,7 @@ public class EmbeddedChannel extends AbstractChannel {
}
}
- private final class LastInboundHandler extends ChannelInboundHandlerAdapter {
+ private final class LastInboundHandler extends ChannelHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
inboundMessages.add(msg);
diff --git a/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java b/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java
index f23adf3c3a..7c5211dc53 100644
--- a/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java
+++ b/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java
@@ -184,11 +184,6 @@ final class EmbeddedEventLoop extends AbstractEventLoop implements ChannelHandle
invokeWriteNow(ctx, msg, promise);
}
- @Override
- public void invokeWriteAndFlush(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
- invokeWriteAndFlushNow(ctx, msg, promise);
- }
-
@Override
public void invokeFlush(ChannelHandlerContext ctx) {
invokeFlushNow(ctx);
diff --git a/transport/src/main/java/io/netty/channel/embedded/package-info.java b/transport/src/main/java/io/netty/channel/embedded/package-info.java
index 57321517e2..b69473f70f 100644
--- a/transport/src/main/java/io/netty/channel/embedded/package-info.java
+++ b/transport/src/main/java/io/netty/channel/embedded/package-info.java
@@ -15,7 +15,7 @@
*/
/**
- * A virtual {@link Channel} that helps wrapping a series of handlers to
+ * A virtual {@link io.netty.channel.Channel} that helps wrapping a series of handlers to
* unit test the handlers or use them in non-I/O context.
*/
package io.netty.channel.embedded;
diff --git a/transport/src/main/java/io/netty/channel/group/ChannelGroup.java b/transport/src/main/java/io/netty/channel/group/ChannelGroup.java
index 0ec17b03f7..b4bb12f071 100644
--- a/transport/src/main/java/io/netty/channel/group/ChannelGroup.java
+++ b/transport/src/main/java/io/netty/channel/group/ChannelGroup.java
@@ -20,9 +20,9 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufHolder;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelId;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ServerChannel;
import io.netty.util.CharsetUtil;
import io.netty.util.concurrent.GlobalEventExecutor;
@@ -82,7 +82,7 @@ import java.util.Set;
* b.releaseExternalResources();
* }
*
- * public class MyHandler extends {@link ChannelInboundHandlerAdapter} {
+ * public class MyHandler extends {@link ChannelHandlerAdapter} {
* {@code @Override}
* public void channelActive({@link ChannelHandlerContext} ctx) {
* // closed on shutdown.
diff --git a/transport/src/main/java/io/netty/channel/socket/ChannelInputShutdownEvent.java b/transport/src/main/java/io/netty/channel/socket/ChannelInputShutdownEvent.java
index 40ed4140b5..8f588aa88c 100644
--- a/transport/src/main/java/io/netty/channel/socket/ChannelInputShutdownEvent.java
+++ b/transport/src/main/java/io/netty/channel/socket/ChannelInputShutdownEvent.java
@@ -15,12 +15,12 @@
*/
package io.netty.channel.socket;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
/**
* Special event which will be fired and passed to the
- * {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)} methods once the input of
+ * {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)} methods once the input of
* a {@link SocketChannel} was shutdown and the {@link SocketChannelConfig#isAllowHalfClosure()} method returns
* {@code true}.
*/
diff --git a/transport/src/main/java/io/netty/channel/socket/SocketChannelConfig.java b/transport/src/main/java/io/netty/channel/socket/SocketChannelConfig.java
index 071832f170..5eb69d91fc 100644
--- a/transport/src/main/java/io/netty/channel/socket/SocketChannelConfig.java
+++ b/transport/src/main/java/io/netty/channel/socket/SocketChannelConfig.java
@@ -17,8 +17,8 @@ package io.netty.channel.socket;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelConfig;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelOption;
import io.netty.channel.MessageSizeEstimator;
import io.netty.channel.RecvByteBufAllocator;
@@ -151,7 +151,7 @@ public interface SocketChannelConfig extends ChannelConfig {
* Sets whether the channel should not close itself when its remote peer shuts down output to
* make the connection half-closed. If {@code true} the connection is not closed when the
* remote peer shuts down output. Instead,
- * {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)}
+ * {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)}
* is invoked with a {@link ChannelInputShutdownEvent} object. If {@code false}, the connection
* is closed automatically.
*/
diff --git a/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java b/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java
index 78ce3bbb20..283c1d4998 100644
--- a/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java
+++ b/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java
@@ -16,9 +16,9 @@
package io.netty.bootstrap;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandler.Sharable;
-import io.netty.channel.ChannelInboundHandler;
-import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.local.LocalAddress;
@@ -37,7 +37,7 @@ public class BootstrapTest {
EventLoopGroup groupB = new DefaultEventLoopGroup(1);
try {
- ChannelInboundHandler dummyHandler = new DummyHandler();
+ ChannelHandler dummyHandler = new DummyHandler();
final Bootstrap bootstrapA = new Bootstrap();
bootstrapA.group(groupA);
@@ -85,7 +85,7 @@ public class BootstrapTest {
EventLoopGroup groupB = new DefaultEventLoopGroup(1);
try {
- ChannelInboundHandler dummyHandler = new DummyHandler();
+ ChannelHandler dummyHandler = new DummyHandler();
final Bootstrap bootstrapA = new Bootstrap();
bootstrapA.group(groupA);
@@ -128,5 +128,5 @@ public class BootstrapTest {
}
@Sharable
- private static final class DummyHandler extends ChannelInboundHandlerAdapter { }
+ private static final class DummyHandler extends ChannelHandlerAdapter { }
}
diff --git a/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java b/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java
index 6efee19e35..804e5650b0 100644
--- a/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java
+++ b/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java
@@ -56,7 +56,7 @@ public class DefaultChannelPipelineTest {
final AtomicReference peerRef = new AtomicReference();
ServerBootstrap sb = new ServerBootstrap();
sb.group(group).channel(LocalServerChannel.class);
- sb.childHandler(new ChannelInboundHandlerAdapter() {
+ sb.childHandler(new ChannelHandlerAdapter() {
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
peerRef.set(ctx.channel());
@@ -116,7 +116,7 @@ public class DefaultChannelPipelineTest {
assertTrue(handler.called);
}
- private static final class StringInboundHandler extends ChannelInboundHandlerAdapter {
+ private static final class StringInboundHandler extends ChannelHandlerAdapter {
boolean called;
@Override
@@ -194,7 +194,7 @@ public class DefaultChannelPipelineTest {
pipeline.addLast(new ChannelInitializer() {
@Override
protected void initChannel(Channel ch) throws Exception {
- ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
+ ch.pipeline().addLast(new ChannelHandlerAdapter() {
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
latch.countDown();
@@ -473,9 +473,9 @@ public class DefaultChannelPipelineTest {
}
@Sharable
- private static class TestHandler extends ChannelDuplexHandler { }
+ private static class TestHandler extends ChannelHandlerAdapter { }
- private static class BufferedTestHandler extends ChannelDuplexHandler {
+ private static class BufferedTestHandler extends ChannelHandlerAdapter {
final Queue inboundBuffer = new ArrayDeque();
final Queue outboundBuffer = new ArrayDeque();
diff --git a/transport/src/test/java/io/netty/channel/LoggingHandler.java b/transport/src/test/java/io/netty/channel/LoggingHandler.java
index c58050439a..5ebc042cca 100644
--- a/transport/src/test/java/io/netty/channel/LoggingHandler.java
+++ b/transport/src/test/java/io/netty/channel/LoggingHandler.java
@@ -19,10 +19,12 @@ import java.net.SocketAddress;
import java.util.Collections;
import java.util.EnumSet;
-final class LoggingHandler implements ChannelInboundHandler, ChannelOutboundHandler {
+final class LoggingHandler implements ChannelHandler {
- static enum Event { WRITE, FLUSH, BIND, CONNECT, DISCONNECT, CLOSE, READ, WRITABILITY, HANDLER_ADDED,
- HANDLER_REMOVED, EXCEPTION, READ_COMPLETE, REGISTERED, ACTIVE, INACTIVE, USER };
+ enum Event {
+ WRITE, FLUSH, BIND, CONNECT, DISCONNECT, CLOSE, READ, WRITABILITY, HANDLER_ADDED,
+ HANDLER_REMOVED, EXCEPTION, READ_COMPLETE, REGISTERED, ACTIVE, INACTIVE, USER
+ }
private StringBuilder log = new StringBuilder();
diff --git a/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java b/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java
index f0bf9bb308..78c1e74fa2 100644
--- a/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java
+++ b/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java
@@ -15,19 +15,17 @@
*/
package io.netty.channel;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.LoggingHandler.Event;
import io.netty.channel.local.LocalAddress;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
+import org.junit.Test;
import java.nio.channels.ClosedChannelException;
-import org.junit.Test;
+import static org.junit.Assert.*;
public class ReentrantChannelTest extends BaseChannelTest {
@@ -78,7 +76,7 @@ public class ReentrantChannelTest extends BaseChannelTest {
clientChannel.config().setWriteBufferLowWaterMark(512);
clientChannel.config().setWriteBufferHighWaterMark(1024);
- clientChannel.pipeline().addLast(new ChannelInboundHandlerAdapter() {
+ clientChannel.pipeline().addLast(new ChannelHandlerAdapter() {
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
if (!ctx.channel().isWritable()) {
@@ -116,7 +114,7 @@ public class ReentrantChannelTest extends BaseChannelTest {
Channel clientChannel = cb.connect(addr).sync().channel();
- clientChannel.pipeline().addLast(new ChannelOutboundHandlerAdapter() {
+ clientChannel.pipeline().addLast(new ChannelHandlerAdapter() {
int writeCount;
int flushCount;
@@ -173,7 +171,7 @@ public class ReentrantChannelTest extends BaseChannelTest {
Channel clientChannel = cb.connect(addr).sync().channel();
- clientChannel.pipeline().addLast(new ChannelOutboundHandlerAdapter() {
+ clientChannel.pipeline().addLast(new ChannelHandlerAdapter() {
@Override
public void write(final ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
@@ -211,7 +209,7 @@ public class ReentrantChannelTest extends BaseChannelTest {
Channel clientChannel = cb.connect(addr).sync().channel();
- clientChannel.pipeline().addLast(new ChannelOutboundHandlerAdapter() {
+ clientChannel.pipeline().addLast(new ChannelHandlerAdapter() {
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
diff --git a/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java b/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java
index 2681e6bc81..1d04d652a0 100644
--- a/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java
+++ b/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java
@@ -17,8 +17,8 @@ package io.netty.channel.group;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
@@ -37,7 +37,7 @@ public class DefaultChannnelGroupTest {
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup);
- b.childHandler(new ChannelInboundHandlerAdapter() {
+ b.childHandler(new ChannelHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
allChannels.add(ctx.channel());
diff --git a/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java b/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java
index e2988322d1..889d390920 100644
--- a/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java
+++ b/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java
@@ -19,8 +19,8 @@ import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
@@ -144,7 +144,7 @@ public class LocalChannelTest {
clientGroup.terminationFuture().sync();
}
- static class TestHandler extends ChannelInboundHandlerAdapter {
+ static class TestHandler extends ChannelHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
logger.info(String.format("Received mesage: %s", msg));
diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java
index 8222832423..7ebc149204 100644
--- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java
+++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java
@@ -19,9 +19,8 @@ import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultEventLoopGroup;
@@ -55,7 +54,7 @@ public class LocalTransportThreadModelTest {
.childHandler(new ChannelInitializer() {
@Override
public void initChannel(LocalChannel ch) throws Exception {
- ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
+ ch.pipeline().addLast(new ChannelHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
// Discard
@@ -356,7 +355,7 @@ public class LocalTransportThreadModelTest {
}
}
- private static class ThreadNameAuditor extends ChannelDuplexHandler {
+ private static class ThreadNameAuditor extends ChannelHandlerAdapter {
private final AtomicReference exception = new AtomicReference();
@@ -393,7 +392,7 @@ public class LocalTransportThreadModelTest {
/**
* Converts integers into a binary stream.
*/
- private static class MessageForwarder1 extends ChannelDuplexHandler {
+ private static class MessageForwarder1 extends ChannelHandlerAdapter {
private final AtomicReference exception = new AtomicReference();
private volatile int inCnt;
@@ -451,7 +450,7 @@ public class LocalTransportThreadModelTest {
/**
* Converts a binary stream into integers.
*/
- private static class MessageForwarder2 extends ChannelDuplexHandler {
+ private static class MessageForwarder2 extends ChannelHandlerAdapter {
private final AtomicReference exception = new AtomicReference();
private volatile int inCnt;
@@ -503,7 +502,7 @@ public class LocalTransportThreadModelTest {
/**
* Simply forwards the received object to the next handler.
*/
- private static class MessageForwarder3 extends ChannelDuplexHandler {
+ private static class MessageForwarder3 extends ChannelHandlerAdapter {
private final AtomicReference exception = new AtomicReference();
private volatile int inCnt;
@@ -549,7 +548,7 @@ public class LocalTransportThreadModelTest {
/**
* Discards all received messages.
*/
- private static class MessageDiscarder extends ChannelDuplexHandler {
+ private static class MessageDiscarder extends ChannelHandlerAdapter {
private final AtomicReference exception = new AtomicReference();
private volatile int inCnt;
diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java
index 277ebb98ac..1a536cf379 100644
--- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java
+++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java
@@ -20,8 +20,8 @@ import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler.Sharable;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.util.ReferenceCountUtil;
import org.junit.Test;
@@ -94,7 +94,7 @@ public class LocalTransportThreadModelTest2 {
}
@Sharable
- static class LocalHander extends ChannelInboundHandlerAdapter {
+ static class LocalHander extends ChannelHandlerAdapter {
private final String name;
public volatile ChannelFuture lastWriteFuture;
diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest3.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest3.java
index f914d9197c..6fb6b36903 100644
--- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest3.java
+++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest3.java
@@ -17,10 +17,9 @@ package io.netty.channel.local;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultEventLoopGroup;
@@ -67,7 +66,7 @@ public class LocalTransportThreadModelTest3 {
.childHandler(new ChannelInitializer() {
@Override
public void initChannel(LocalChannel ch) throws Exception {
- ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
+ ch.pipeline().addLast(new ChannelHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
// Discard
@@ -247,9 +246,9 @@ public class LocalTransportThreadModelTest3 {
}
@ChannelHandler.Sharable
- private static final class EventForwarder extends ChannelDuplexHandler { }
+ private static final class EventForwarder extends ChannelHandlerAdapter { }
- private static final class EventRecorder extends ChannelDuplexHandler {
+ private static final class EventRecorder extends ChannelHandlerAdapter {
private final Queue events;
private final boolean inbound;
diff --git a/transport/src/test/java/io/netty/channel/nio/NioDatagramChannelTest.java b/transport/src/test/java/io/netty/channel/nio/NioDatagramChannelTest.java
index 343bd1920e..53a8801405 100644
--- a/transport/src/test/java/io/netty/channel/nio/NioDatagramChannelTest.java
+++ b/transport/src/test/java/io/netty/channel/nio/NioDatagramChannelTest.java
@@ -16,8 +16,8 @@
package io.netty.channel.nio;
import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelOption;
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.channel.socket.DatagramChannel;
@@ -44,7 +44,7 @@ public class NioDatagramChannelTest {
Bootstrap udpBootstrap = new Bootstrap();
udpBootstrap.group(group).channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
- .handler(new ChannelInboundHandlerAdapter() {
+ .handler(new ChannelHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
// Discard
diff --git a/transport/src/test/java/io/netty/channel/nio/NioSocketChannelTest.java b/transport/src/test/java/io/netty/channel/nio/NioSocketChannelTest.java
index 0844167b8c..be50b7eba8 100644
--- a/transport/src/test/java/io/netty/channel/nio/NioSocketChannelTest.java
+++ b/transport/src/test/java/io/netty/channel/nio/NioSocketChannelTest.java
@@ -19,8 +19,8 @@ import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.util.CharsetUtil;
import org.junit.Test;
@@ -51,7 +51,7 @@ public class NioSocketChannelTest {
ServerBootstrap sb = new ServerBootstrap();
sb.group(group).channel(NioServerSocketChannel.class);
- sb.childHandler(new ChannelInboundHandlerAdapter() {
+ sb.childHandler(new ChannelHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// Write a large enough data so that it is split into two loops.
@@ -106,7 +106,7 @@ public class NioSocketChannelTest {
try {
ServerBootstrap sb = new ServerBootstrap();
sb.group(group).channel(NioServerSocketChannel.class);
- sb.childHandler(new ChannelInboundHandlerAdapter() {
+ sb.childHandler(new ChannelHandlerAdapter() {
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
// Trigger a gathering write by writing two buffers.