Merge ChannelInboundHandler and ChannelOutboundHandler into ChannelHa… (#8957)
Motivation:
In 42742e233f
we already added default methods to Channel*Handler and deprecated the Adapter classes to simplify the class hierarchy. With this change we go even further and merge everything into just ChannelHandler. This simplifies things even more in terms of class-hierarchy.
Modifications:
- Merge ChannelInboundHandler | ChannelOutboundHandler into ChannelHandler
- Adjust code to just use ChannelHandler
- Deprecate old interfaces.
Result:
Cleaner and simpler code in terms of class-hierarchy.
This commit is contained in:
parent
6297f183a3
commit
0f34345347
@ -15,7 +15,6 @@
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.AsciiString;
|
||||
|
||||
@ -36,7 +35,7 @@ import static java.util.Objects.requireNonNull;
|
||||
* simply removes itself from the pipeline. If the upgrade is successful, upgrades the pipeline to
|
||||
* the new protocol.
|
||||
*/
|
||||
public class HttpClientUpgradeHandler extends HttpObjectAggregator implements ChannelOutboundHandler {
|
||||
public class HttpClientUpgradeHandler extends HttpObjectAggregator {
|
||||
|
||||
/**
|
||||
* User events that are fired to notify about upgrade status.
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -44,7 +44,7 @@ import static io.netty.handler.codec.http.HttpUtil.*;
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*/
|
||||
public class HttpServerKeepAliveHandler extends ChannelDuplexHandler {
|
||||
public class HttpServerKeepAliveHandler implements ChannelHandler {
|
||||
private static final String MULTIPART_PREFIX = "multipart";
|
||||
|
||||
private boolean persistentConnection = true;
|
||||
@ -61,7 +61,7 @@ public class HttpServerKeepAliveHandler extends ChannelDuplexHandler {
|
||||
persistentConnection = isKeepAlive(request);
|
||||
}
|
||||
}
|
||||
super.channelRead(ctx, msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,7 +84,7 @@ public class HttpServerKeepAliveHandler extends ChannelDuplexHandler {
|
||||
if (msg instanceof LastHttpContent && !shouldKeepAlive()) {
|
||||
promise = promise.unvoid().addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
super.write(ctx, msg, promise);
|
||||
ctx.write(msg, promise);
|
||||
}
|
||||
|
||||
private void trackResponse(HttpResponse response) {
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.cors;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpResponse;
|
||||
@ -46,7 +46,7 @@ import static java.util.Objects.requireNonNull;
|
||||
* This handler can be configured using one or more {@link CorsConfig}, please
|
||||
* refer to this class for details about the configuration options available.
|
||||
*/
|
||||
public class CorsHandler extends ChannelDuplexHandler {
|
||||
public class CorsHandler implements ChannelHandler {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(CorsHandler.class);
|
||||
private static final String ANY_ORIGIN = "*";
|
||||
|
@ -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 {
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {
|
||||
}
|
||||
|
||||
static ChannelHandler forbiddenHttpRequestResponder() {
|
||||
return new ChannelInboundHandler() {
|
||||
return new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof FullHttpRequest) {
|
||||
|
@ -17,7 +17,7 @@ package io.netty.handler.codec.http.websocketx.extensions;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.CodecException;
|
||||
@ -40,7 +40,7 @@ import java.util.List;
|
||||
* Find a basic implementation for compression extensions at
|
||||
* <tt>io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketClientCompressionHandler</tt>.
|
||||
*/
|
||||
public class WebSocketClientExtensionHandler extends ChannelDuplexHandler {
|
||||
public class WebSocketClientExtensionHandler implements ChannelHandler {
|
||||
|
||||
private final List<WebSocketClientExtensionHandshaker> extensionHandshakers;
|
||||
|
||||
@ -74,7 +74,7 @@ public class WebSocketClientExtensionHandler extends ChannelDuplexHandler {
|
||||
request.headers().set(HttpHeaderNames.SEC_WEBSOCKET_EXTENSIONS, headerValue);
|
||||
}
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
ctx.write(msg, promise);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,7 +125,7 @@ public class WebSocketClientExtensionHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
}
|
||||
|
||||
super.channelRead(ctx, msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ package io.netty.handler.codec.http.websocketx.extensions;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
@ -40,7 +40,7 @@ import java.util.List;
|
||||
* Find a basic implementation for compression extensions at
|
||||
* <tt>io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketServerCompressionHandler</tt>.
|
||||
*/
|
||||
public class WebSocketServerExtensionHandler extends ChannelDuplexHandler {
|
||||
public class WebSocketServerExtensionHandler implements ChannelHandler {
|
||||
|
||||
private final List<WebSocketServerExtensionHandshaker> extensionHandshakers;
|
||||
|
||||
@ -98,7 +98,7 @@ public class WebSocketServerExtensionHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
}
|
||||
|
||||
super.channelRead(ctx, msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,6 +132,6 @@ public class WebSocketServerExtensionHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
}
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
ctx.write(msg, promise);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ package io.netty.handler.codec.http;
|
||||
|
||||
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.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.CodecException;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
@ -274,7 +274,7 @@ public class HttpContentDecoderTest {
|
||||
final int maxBytes = 10;
|
||||
HttpObjectAggregator aggregator = new HttpObjectAggregator(maxBytes);
|
||||
final AtomicReference<FullHttpRequest> secondRequestRef = new AtomicReference<>();
|
||||
EmbeddedChannel channel = new EmbeddedChannel(decoder, aggregator, new ChannelInboundHandler() {
|
||||
EmbeddedChannel channel = new EmbeddedChannel(decoder, aggregator, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof FullHttpRequest) {
|
||||
@ -531,7 +531,7 @@ public class HttpContentDecoderTest {
|
||||
HttpContentDecoder decoder = new HttpContentDecoder() {
|
||||
@Override
|
||||
protected EmbeddedChannel newContentDecoder(String contentEncoding) throws Exception {
|
||||
return new EmbeddedChannel(new ChannelInboundHandler() {
|
||||
return new EmbeddedChannel(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireExceptionCaught(new DecoderException());
|
||||
@ -542,7 +542,7 @@ public class HttpContentDecoderTest {
|
||||
};
|
||||
|
||||
final AtomicBoolean channelInactiveCalled = new AtomicBoolean();
|
||||
EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelInboundHandler() {
|
||||
EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
assertTrue(channelInactiveCalled.compareAndSet(false, true));
|
||||
|
@ -16,10 +16,9 @@
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@ -32,13 +31,13 @@ public class HttpContentDecompressorTest {
|
||||
@Test
|
||||
public void testInvokeReadWhenNotProduceMessage() {
|
||||
final AtomicInteger readCalled = new AtomicInteger();
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() {
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new ChannelHandler() {
|
||||
@Override
|
||||
public void read(ChannelHandlerContext ctx) {
|
||||
readCalled.incrementAndGet();
|
||||
ctx.read();
|
||||
}
|
||||
}, new HttpContentDecompressor(), new ChannelInboundHandler() {
|
||||
}, new HttpContentDecompressor(), new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
ctx.fireChannelRead(msg);
|
||||
|
@ -18,8 +18,8 @@ package io.netty.handler.codec.http;
|
||||
|
||||
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.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.CodecException;
|
||||
import io.netty.handler.codec.DecoderResult;
|
||||
@ -397,7 +397,7 @@ public class HttpContentEncoderTest {
|
||||
@Override
|
||||
protected Result beginEncode(HttpResponse headers, String acceptEncoding) throws Exception {
|
||||
return new Result("myencoding", new EmbeddedChannel(
|
||||
new ChannelInboundHandler() {
|
||||
new ChannelHandler() {
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireExceptionCaught(new EncoderException());
|
||||
@ -408,7 +408,7 @@ public class HttpContentEncoderTest {
|
||||
};
|
||||
|
||||
final AtomicBoolean channelInactiveCalled = new AtomicBoolean();
|
||||
EmbeddedChannel channel = new EmbeddedChannel(encoder, new ChannelInboundHandler() {
|
||||
EmbeddedChannel channel = new EmbeddedChannel(encoder, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
assertTrue(channelInactiveCalled.compareAndSet(false, true));
|
||||
|
@ -18,12 +18,10 @@ package io.netty.handler.codec.http;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -56,7 +54,7 @@ public class HttpServerUpgradeHandlerTest {
|
||||
assertNotNull(ctx.pipeline().get(HttpServerUpgradeHandler.class));
|
||||
|
||||
// Add a marker handler to signal that the upgrade has happened
|
||||
ctx.pipeline().addAfter(ctx.name(), "marker", new ChannelInboundHandler() { });
|
||||
ctx.pipeline().addAfter(ctx.name(), "marker", new ChannelHandler() { });
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +63,7 @@ public class HttpServerUpgradeHandlerTest {
|
||||
final HttpServerCodec httpServerCodec = new HttpServerCodec();
|
||||
final UpgradeCodecFactory factory = protocol -> new TestUpgradeCodec();
|
||||
|
||||
ChannelHandler testInStackFrame = new ChannelDuplexHandler() {
|
||||
ChannelHandler testInStackFrame = new ChannelHandler() {
|
||||
// marker boolean to signal that we're in the `channelRead` method
|
||||
private boolean inReadCall;
|
||||
private boolean writeUpgradeMessage;
|
||||
@ -78,7 +76,7 @@ public class HttpServerUpgradeHandlerTest {
|
||||
|
||||
inReadCall = true;
|
||||
try {
|
||||
super.channelRead(ctx, msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
// All in the same call stack, the upgrade codec should receive the message,
|
||||
// written the upgrade response, and upgraded the pipeline.
|
||||
assertTrue(writeUpgradeMessage);
|
||||
|
@ -18,7 +18,6 @@ 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.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpRequest;
|
||||
@ -154,7 +153,7 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
return new String(response.content().array());
|
||||
}
|
||||
|
||||
private class MockOutboundHandler implements ChannelOutboundHandler {
|
||||
private class MockOutboundHandler implements ChannelHandler {
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
package io.netty.handler.codec.http2;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
/**
|
||||
* A {@link ChannelDuplexHandler} providing additional functionality for HTTP/2. Specifically it allows to:
|
||||
* A {@link ChannelHandler} providing additional functionality for HTTP/2. Specifically it allows to:
|
||||
* <ul>
|
||||
* <li>Create new outbound streams using {@link #newStream()}.</li>
|
||||
* <li>Iterate over all active streams using {@link #forEachActiveStream(Http2FrameStreamVisitor)}.</li>
|
||||
@ -33,7 +33,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
* or else an {@link IllegalStateException} will be thrown.
|
||||
*/
|
||||
@UnstableApi
|
||||
public abstract class Http2ChannelDuplexHandler extends ChannelDuplexHandler {
|
||||
public abstract class Http2ChannelDuplexHandler implements ChannelHandler {
|
||||
|
||||
private volatile Http2FrameCodec frameCodec;
|
||||
|
||||
|
@ -20,7 +20,6 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
@ -63,8 +62,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
* {@link Http2LocalFlowController}
|
||||
*/
|
||||
@UnstableApi
|
||||
public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http2LifecycleManager,
|
||||
ChannelOutboundHandler {
|
||||
public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http2LifecycleManager {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(Http2ConnectionHandler.class);
|
||||
|
||||
|
@ -18,8 +18,8 @@ package io.netty.handler.codec.http2;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
@ -78,7 +78,7 @@ public class CleartextHttp2ServerUpgradeHandlerTest {
|
||||
|
||||
CleartextHttp2ServerUpgradeHandler handler = new CleartextHttp2ServerUpgradeHandler(
|
||||
httpServerCodec, upgradeHandler, http2ConnectionHandler);
|
||||
channel = new EmbeddedChannel(handler, new ChannelInboundHandler() {
|
||||
channel = new EmbeddedChannel(handler, new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
userEvents.add(evt);
|
||||
@ -204,7 +204,7 @@ public class CleartextHttp2ServerUpgradeHandlerTest {
|
||||
|
||||
CleartextHttp2ServerUpgradeHandler handler = new CleartextHttp2ServerUpgradeHandler(
|
||||
httpServerCodec, upgradeHandler, http2Codec);
|
||||
channel = new EmbeddedChannel(handler, new ChannelInboundHandler() {
|
||||
channel = new EmbeddedChannel(handler, new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
userEvents.add(evt);
|
||||
|
@ -20,8 +20,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -320,7 +320,7 @@ public class DataCompressionHttp2Test {
|
||||
.gracefulShutdownTimeoutMillis(0)
|
||||
.codec(decoder, clientEncoder).build();
|
||||
p.addLast(clientHandler);
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) {
|
||||
prefaceWrittenLatch.countDown();
|
||||
|
@ -16,7 +16,6 @@ package io.netty.handler.codec.http2;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
@ -44,13 +43,13 @@ public class Http2ClientUpgradeCodecTest {
|
||||
@Test
|
||||
public void testUpgradeToHttp2MultiplexCodec() throws Exception {
|
||||
testUpgrade(Http2MultiplexCodecBuilder.forClient(new HttpInboundHandler())
|
||||
.withUpgradeStreamHandler(new ChannelInboundHandler() { }).build());
|
||||
.withUpgradeStreamHandler(new ChannelHandler() { }).build());
|
||||
}
|
||||
|
||||
private static void testUpgrade(Http2ConnectionHandler handler) throws Exception {
|
||||
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "*");
|
||||
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { });
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new ChannelHandler() { });
|
||||
ChannelHandlerContext ctx = channel.pipeline().firstContext();
|
||||
Http2ClientUpgradeCodec codec = new Http2ClientUpgradeCodec("connectionHandler", handler);
|
||||
codec.setUpgradeHeaders(ctx, request);
|
||||
@ -64,5 +63,5 @@ public class Http2ClientUpgradeCodecTest {
|
||||
}
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
private static final class HttpInboundHandler implements ChannelInboundHandler { }
|
||||
private static final class HttpInboundHandler implements ChannelHandler { }
|
||||
}
|
||||
|
@ -23,11 +23,10 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
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.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -642,7 +641,7 @@ public class Http2ConnectionRoundtripTest {
|
||||
runInChannel(clientChannel, () -> {
|
||||
http2Client.encoder().writeHeaders(ctx(), 3, EmptyHttp2Headers.INSTANCE, 0, (short) 16, false, 0, false,
|
||||
newPromise());
|
||||
clientChannel.pipeline().addFirst(new ChannelOutboundHandler() {
|
||||
clientChannel.pipeline().addFirst(new ChannelHandler() {
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
ReferenceCountUtil.release(msg);
|
||||
@ -1061,7 +1060,7 @@ public class Http2ConnectionRoundtripTest {
|
||||
.validateHeaders(false)
|
||||
.gracefulShutdownTimeoutMillis(0)
|
||||
.build());
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) {
|
||||
|
@ -18,8 +18,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.UnsupportedMessageTypeException;
|
||||
@ -779,7 +779,7 @@ public class Http2FrameCodecTest {
|
||||
|
||||
@Test
|
||||
public void upgradeWithoutFlowControlling() throws Exception {
|
||||
channel.pipeline().addAfter(frameCodec.ctx.name(), null, new ChannelInboundHandler() {
|
||||
channel.pipeline().addAfter(frameCodec.ctx.name(), null, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof Http2DataFrame) {
|
||||
|
@ -22,7 +22,6 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelProgressivePromise;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -107,7 +106,7 @@ final class Http2FrameInboundWriter {
|
||||
}
|
||||
|
||||
private static final class WriteInboundChannelHandlerContext
|
||||
implements ChannelHandlerContext, ChannelOutboundHandler {
|
||||
implements ChannelHandlerContext, ChannelHandler {
|
||||
private final EmbeddedChannel channel;
|
||||
|
||||
WriteInboundChannelHandlerContext(EmbeddedChannel channel) {
|
||||
|
@ -25,7 +25,6 @@ import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerAdapter;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -81,7 +80,7 @@ public class Http2MultiplexCodecBuilderTest {
|
||||
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private boolean writable;
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,6 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
@ -132,7 +131,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
@Test
|
||||
public void writeUnknownFrame() {
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() {
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
ctx.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers()));
|
||||
@ -156,7 +155,7 @@ public class Http2MultiplexCodecTest {
|
||||
AtomicInteger maxReads, final ChannelHandler childHandler) {
|
||||
final AtomicReference<Http2StreamChannel> streamChannelRef = new AtomicReference<>();
|
||||
childChannelInitializer.maxReads = maxReads;
|
||||
childChannelInitializer.handler = new ChannelInboundHandler() {
|
||||
childChannelInitializer.handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) {
|
||||
assertNull(streamChannelRef.get());
|
||||
@ -183,7 +182,7 @@ public class Http2MultiplexCodecTest {
|
||||
// header frame and unknown frame
|
||||
verifyFramesMultiplexedToCorrectChannel(channel, handler, 2);
|
||||
|
||||
Channel childChannel = newOutboundStream(new ChannelInboundHandler() { });
|
||||
Channel childChannel = newOutboundStream(new ChannelHandler() { });
|
||||
assertTrue(childChannel.isActive());
|
||||
}
|
||||
|
||||
@ -309,7 +308,7 @@ public class Http2MultiplexCodecTest {
|
||||
assertNotNull(headersFrame);
|
||||
|
||||
// Add a handler which will request reads.
|
||||
childChannel.pipeline().addFirst(new ChannelInboundHandler() {
|
||||
childChannel.pipeline().addFirst(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
ctx.fireChannelRead(msg);
|
||||
@ -363,7 +362,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
@Test
|
||||
public void outboundStreamShouldWriteResetFrameOnClose_headersSent() {
|
||||
ChannelHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
ctx.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers()));
|
||||
@ -398,7 +397,7 @@ public class Http2MultiplexCodecTest {
|
||||
}
|
||||
});
|
||||
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() {
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
ctx.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers()));
|
||||
@ -629,7 +628,7 @@ public class Http2MultiplexCodecTest {
|
||||
public void settingChannelOptsAndAttrs() {
|
||||
AttributeKey<String> key = AttributeKey.newInstance("foo");
|
||||
|
||||
Channel childChannel = newOutboundStream(new ChannelInboundHandler() { });
|
||||
Channel childChannel = newOutboundStream(new ChannelHandler() { });
|
||||
childChannel.config().setAutoRead(false).setWriteSpinCount(1000);
|
||||
childChannel.attr(key).set("bar");
|
||||
assertFalse(childChannel.config().isAutoRead());
|
||||
@ -639,7 +638,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
@Test
|
||||
public void outboundFlowControlWritability() {
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() { });
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelHandler() { });
|
||||
assertTrue(childChannel.isActive());
|
||||
|
||||
assertTrue(childChannel.isWritable());
|
||||
@ -691,7 +690,7 @@ public class Http2MultiplexCodecTest {
|
||||
assertTrue(childChannel.isOpen());
|
||||
assertTrue(childChannel.isActive());
|
||||
|
||||
childChannel.pipeline().addLast(new ChannelInboundHandler() {
|
||||
childChannel.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
channelOpen.set(ctx.channel().isOpen());
|
||||
@ -712,7 +711,7 @@ public class Http2MultiplexCodecTest {
|
||||
final AtomicInteger exceptionCaught = new AtomicInteger(-1);
|
||||
final AtomicInteger channelInactive = new AtomicInteger(-1);
|
||||
final AtomicInteger channelUnregistered = new AtomicInteger(-1);
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() {
|
||||
Http2StreamChannel childChannel = newOutboundStream(new ChannelHandler() {
|
||||
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
@ -721,7 +720,7 @@ public class Http2MultiplexCodecTest {
|
||||
}
|
||||
});
|
||||
|
||||
childChannel.pipeline().addLast(new ChannelInboundHandler() {
|
||||
childChannel.pipeline().addLast(new ChannelHandler() {
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
@ -784,7 +783,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
assertEquals(new DefaultHttp2HeadersFrame(request).stream(childChannel.stream()), inboundHandler.readInbound());
|
||||
|
||||
ChannelHandler readCompleteSupressHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler readCompleteSupressHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) {
|
||||
// We want to simulate the parent channel calling channelRead and delay calling channelReadComplete.
|
||||
@ -847,7 +846,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
assertEquals(new DefaultHttp2HeadersFrame(request).stream(childChannel.stream()), inboundHandler.readInbound());
|
||||
|
||||
ChannelHandler readCompleteSupressHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler readCompleteSupressHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) {
|
||||
// We want to simulate the parent channel calling channelRead and delay calling channelReadComplete.
|
||||
@ -907,7 +906,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
assertEquals(new DefaultHttp2HeadersFrame(request).stream(childChannel.stream()), inboundHandler.readInbound());
|
||||
|
||||
ChannelHandler readCompleteSupressHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler readCompleteSupressHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
// We want to simulate the parent channel calling channelRead and delay calling channelReadComplete.
|
||||
|
@ -17,7 +17,6 @@ package io.netty.handler.codec.http2;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpRequest;
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
@ -57,7 +56,7 @@ public class Http2ServerUpgradeCodecTest {
|
||||
request.headers().set(HttpHeaderNames.UPGRADE, "h2c");
|
||||
request.headers().set("HTTP2-Settings", "AAMAAABkAAQAAP__");
|
||||
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { });
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new ChannelHandler() { });
|
||||
ChannelHandlerContext ctx = channel.pipeline().firstContext();
|
||||
Http2ServerUpgradeCodec codec = new Http2ServerUpgradeCodec("connectionHandler", handler);
|
||||
assertTrue(codec.prepareUpgradeResponse(ctx, request, new DefaultHttpHeaders()));
|
||||
@ -78,5 +77,5 @@ public class Http2ServerUpgradeCodecTest {
|
||||
}
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
private static final class HttpInboundHandler implements ChannelInboundHandler { }
|
||||
private static final class HttpInboundHandler implements ChannelHandler { }
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.EncoderException;
|
||||
@ -450,7 +449,7 @@ public class Http2StreamFrameToHttpObjectCodecTest {
|
||||
|
||||
final SslContext ctx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).build();
|
||||
EmbeddedChannel ch = new EmbeddedChannel(ctx.newHandler(ByteBufAllocator.DEFAULT),
|
||||
new ChannelOutboundHandler() {
|
||||
new ChannelHandler() {
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
if (msg instanceof Http2StreamFrame) {
|
||||
@ -880,7 +879,7 @@ public class Http2StreamFrameToHttpObjectCodecTest {
|
||||
|
||||
final SslContext ctx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).build();
|
||||
EmbeddedChannel tlsCh = new EmbeddedChannel(ctx.newHandler(ByteBufAllocator.DEFAULT),
|
||||
new ChannelOutboundHandler() {
|
||||
new ChannelHandler() {
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
|
||||
if (msg instanceof Http2StreamFrame) {
|
||||
@ -893,7 +892,7 @@ public class Http2StreamFrameToHttpObjectCodecTest {
|
||||
}, sharedHandler);
|
||||
|
||||
EmbeddedChannel plaintextCh = new EmbeddedChannel(
|
||||
new ChannelOutboundHandler() {
|
||||
new ChannelHandler() {
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
|
||||
if (msg instanceof Http2StreamFrame) {
|
||||
|
@ -20,6 +20,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
@ -529,7 +530,7 @@ public class HttpToHttp2ConnectionHandlerTest {
|
||||
.gracefulShutdownTimeoutMillis(0)
|
||||
.build();
|
||||
p.addLast(handler);
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) {
|
||||
|
@ -20,8 +20,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -665,7 +665,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
||||
|
||||
clientDelegator = new HttpResponseDelegator(clientListener, clientLatch, clientLatch2);
|
||||
p.addLast(clientDelegator);
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
Http2Exception e = getEmbeddedHttp2Exception(cause);
|
||||
@ -677,7 +677,7 @@ public class InboundHttp2ToHttpAdapterTest {
|
||||
}
|
||||
}
|
||||
});
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) {
|
||||
prefaceWrittenLatch.countDown();
|
||||
|
@ -17,7 +17,7 @@
|
||||
package io.netty.handler.codec.http2;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
@ -33,7 +33,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
/**
|
||||
* Channel handler that allows to easily access inbound messages.
|
||||
*/
|
||||
public class LastInboundHandler extends ChannelDuplexHandler {
|
||||
public class LastInboundHandler implements ChannelHandler {
|
||||
private final List<Object> queue = new ArrayList<>();
|
||||
private final Consumer<ChannelHandlerContext> channelReadCompleteConsumer;
|
||||
private Throwable lastException;
|
||||
@ -64,7 +64,6 @@ public class LastInboundHandler extends ChannelDuplexHandler {
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
|
||||
super.handlerAdded(ctx);
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
@ -74,7 +73,6 @@ public class LastInboundHandler extends ChannelDuplexHandler {
|
||||
throw new IllegalStateException("channelActive may only be fired once.");
|
||||
}
|
||||
channelActive = true;
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
public boolean isChannelActive() {
|
||||
@ -91,7 +89,7 @@ public class LastInboundHandler extends ChannelDuplexHandler {
|
||||
throw new IllegalStateException("channelInactive may only be fired once after channelActive.");
|
||||
}
|
||||
channelActive = false;
|
||||
super.channelInactive(ctx);
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -101,7 +99,7 @@ public class LastInboundHandler extends ChannelDuplexHandler {
|
||||
} else {
|
||||
writabilityStates += "," + ctx.channel().isWritable();
|
||||
}
|
||||
super.channelWritabilityChanged(ctx);
|
||||
ctx.fireChannelWritabilityChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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} <strong>MUST NOT</strong>
|
||||
* annotated with {@link @Sharable}.
|
||||
*/
|
||||
public abstract class ByteToMessageCodec<I> extends ChannelDuplexHandler {
|
||||
public abstract class ByteToMessageCodec<I> extends ChannelHandlerAdapter {
|
||||
|
||||
private final TypeParameterMatcher outboundMsgMatcher;
|
||||
private final MessageToByteEncoder<I> encoder;
|
||||
|
@ -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.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
@ -27,7 +27,7 @@ import io.netty.util.internal.TypeParameterMatcher;
|
||||
|
||||
|
||||
/**
|
||||
* {@link ChannelOutboundHandler} which encodes message in a stream-like fashion from one message to an
|
||||
* {@link ChannelHandler} 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;
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public abstract class MessageToByteEncoder<I> extends ChannelHandlerAdapter implements ChannelOutboundHandler {
|
||||
public abstract class MessageToByteEncoder<I> extends ChannelHandlerAdapter {
|
||||
|
||||
private final TypeParameterMatcher matcher;
|
||||
private final boolean preferDirect;
|
||||
@ -89,7 +89,7 @@ public abstract class MessageToByteEncoder<I> extends ChannelHandlerAdapter impl
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
@ -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<INBOUND_IN, OUTBOUND_IN> extends ChannelDuplexHandler {
|
||||
public abstract class MessageToMessageCodec<INBOUND_IN, OUTBOUND_IN> extends ChannelHandlerAdapter {
|
||||
|
||||
private final MessageToMessageEncoder<Object> encoder = new MessageToMessageEncoder<Object>() {
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package io.netty.handler.codec;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerAdapter;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
@ -29,7 +29,7 @@ import io.netty.util.internal.TypeParameterMatcher;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link ChannelOutboundHandler} which encodes from one message to an other message
|
||||
* {@link ChannelHandler} which encodes from one message to an other message
|
||||
*
|
||||
* For example here is an implementation which decodes an {@link Integer} to an {@link String}.
|
||||
*
|
||||
@ -49,7 +49,7 @@ import java.util.List;
|
||||
* are of type {@link ReferenceCounted}. This is needed as the {@link MessageToMessageEncoder} will call
|
||||
* {@link ReferenceCounted#release()} on encoded messages.
|
||||
*/
|
||||
public abstract class MessageToMessageEncoder<I> extends ChannelHandlerAdapter implements ChannelOutboundHandler {
|
||||
public abstract class MessageToMessageEncoder<I> extends ChannelHandlerAdapter {
|
||||
|
||||
private final TypeParameterMatcher matcher;
|
||||
|
||||
@ -71,7 +71,7 @@ public abstract class MessageToMessageEncoder<I> extends ChannelHandlerAdapter i
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
@ -20,6 +20,7 @@ import io.netty.buffer.CompositeByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import io.netty.buffer.UnpooledHeapByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
@ -174,7 +175,7 @@ public class ByteToMessageDecoderTest {
|
||||
assertFalse(in.isReadable());
|
||||
out.add("data");
|
||||
}
|
||||
}, new ChannelInboundHandler() {
|
||||
}, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) {
|
||||
queue.add(3);
|
||||
@ -212,7 +213,7 @@ public class ByteToMessageDecoderTest {
|
||||
}
|
||||
};
|
||||
|
||||
EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelInboundHandler() {
|
||||
EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
if (msg == upgradeMessage) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package io.netty.handler.codec;
|
||||
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@ -31,7 +31,7 @@ import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
public class MessageAggregatorTest {
|
||||
private static final class ReadCounter implements ChannelOutboundHandler {
|
||||
private static final class ReadCounter implements ChannelHandler {
|
||||
int value;
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,6 @@ package io.netty.handler.codec;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import org.junit.Test;
|
||||
@ -55,7 +54,7 @@ public class MessageToMessageEncoderTest {
|
||||
|
||||
final Exception firstWriteException = new Exception();
|
||||
|
||||
ChannelHandler writeThrower = new ChannelOutboundHandler() {
|
||||
ChannelHandler writeThrower = new ChannelHandler() {
|
||||
private boolean firstWritten;
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
|
||||
|
@ -17,8 +17,8 @@ package io.netty.handler.codec;
|
||||
|
||||
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.embedded.EmbeddedChannel;
|
||||
import io.netty.channel.socket.ChannelInputShutdownEvent;
|
||||
import org.junit.Test;
|
||||
@ -96,7 +96,7 @@ public class ReplayingDecoderTest {
|
||||
assertNull(ch.readInbound());
|
||||
}
|
||||
|
||||
private static final class BloatedLineDecoder implements ChannelInboundHandler {
|
||||
private static final class BloatedLineDecoder implements ChannelHandler {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.pipeline().replace(this, "less-bloated", new LineDecoder());
|
||||
@ -226,7 +226,7 @@ public class ReplayingDecoderTest {
|
||||
assertFalse(in.isReadable());
|
||||
out.add("data");
|
||||
}
|
||||
}, new ChannelInboundHandler() {
|
||||
}, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
queue.add(3);
|
||||
|
@ -17,7 +17,7 @@ package io.netty.example.http2.helloworld.frame.server;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
|
||||
@ -40,13 +40,13 @@ import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
||||
* <p>This example is making use of the "frame codec" http2 API. This API is very experimental and incomplete.
|
||||
*/
|
||||
@Sharable
|
||||
public class HelloWorldHttp2Handler extends ChannelDuplexHandler {
|
||||
public class HelloWorldHttp2Handler implements ChannelHandler {
|
||||
|
||||
static final ByteBuf RESPONSE_BYTES = unreleasableBuffer(copiedBuffer("Hello World", CharsetUtil.UTF_8));
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
super.exceptionCaught(ctx, cause);
|
||||
ctx.fireExceptionCaught(cause);
|
||||
cause.printStackTrace();
|
||||
ctx.close();
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler {
|
||||
} else if (msg instanceof Http2DataFrame) {
|
||||
onDataRead(ctx, (Http2DataFrame) msg);
|
||||
} else {
|
||||
super.channelRead(ctx, msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import static io.netty.buffer.Unpooled.unreleasableBuffer;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
|
||||
@ -38,13 +38,13 @@ import io.netty.util.CharsetUtil;
|
||||
* Channels. This API is very experimental and incomplete.
|
||||
*/
|
||||
@Sharable
|
||||
public class HelloWorldHttp2Handler extends ChannelDuplexHandler {
|
||||
public class HelloWorldHttp2Handler implements ChannelHandler {
|
||||
|
||||
static final ByteBuf RESPONSE_BYTES = unreleasableBuffer(copiedBuffer("Hello World", CharsetUtil.UTF_8));
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
super.exceptionCaught(ctx, cause);
|
||||
ctx.fireExceptionCaught(cause);
|
||||
cause.printStackTrace();
|
||||
ctx.close();
|
||||
}
|
||||
@ -56,7 +56,7 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler {
|
||||
} else if (msg instanceof Http2DataFrame) {
|
||||
onDataRead(ctx, (Http2DataFrame) msg);
|
||||
} else {
|
||||
super.channelRead(ctx, msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ package io.netty.example.memcache.binary;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.memcache.binary.BinaryMemcacheOpcodes;
|
||||
@ -27,7 +27,7 @@ import io.netty.handler.codec.memcache.binary.DefaultFullBinaryMemcacheRequest;
|
||||
import io.netty.handler.codec.memcache.binary.FullBinaryMemcacheResponse;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
public class MemcacheClientHandler extends ChannelDuplexHandler {
|
||||
public class MemcacheClientHandler implements ChannelHandler {
|
||||
|
||||
/**
|
||||
* Transforms basic string requests to binary memcache requests
|
||||
|
@ -17,7 +17,7 @@
|
||||
package io.netty.example.redis;
|
||||
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.CodecException;
|
||||
@ -36,7 +36,7 @@ import java.util.List;
|
||||
/**
|
||||
* An example Redis client handler. This handler read input from STDIN and write output to STDOUT.
|
||||
*/
|
||||
public class RedisClientHandler extends ChannelDuplexHandler {
|
||||
public class RedisClientHandler implements ChannelHandler {
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
|
||||
|
@ -19,8 +19,8 @@ package io.netty.handler.proxy;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.PendingWriteQueue;
|
||||
@ -36,7 +36,7 @@ import java.net.SocketAddress;
|
||||
import java.nio.channels.ConnectionPendingException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class ProxyHandler extends ChannelDuplexHandler {
|
||||
public abstract class ProxyHandler implements ChannelHandler {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ProxyHandler.class);
|
||||
|
||||
|
@ -19,8 +19,8 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
@ -186,7 +186,7 @@ public class HttpProxyHandlerTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addFirst(new HttpResponseEncoder());
|
||||
ch.pipeline().addFirst(new ChannelInboundHandler() {
|
||||
ch.pipeline().addFirst(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
DefaultFullHttpResponse response = new DefaultFullHttpResponse(
|
||||
@ -205,7 +205,7 @@ public class HttpProxyHandlerTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addFirst(new HttpProxyHandler(addr));
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx,
|
||||
Throwable cause) {
|
||||
|
@ -19,7 +19,6 @@ import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
@ -64,7 +63,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
*
|
||||
* @see ChannelConfig#setAutoRead(boolean)
|
||||
*/
|
||||
public class FlowControlHandler extends ChannelDuplexHandler {
|
||||
public class FlowControlHandler implements ChannelHandler {
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(FlowControlHandler.class);
|
||||
|
||||
private final boolean releaseMessages;
|
||||
|
@ -16,10 +16,8 @@
|
||||
package io.netty.handler.flush;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelOutboundInvoker;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -27,7 +25,7 @@ import io.netty.channel.ChannelPromise;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* {@link ChannelDuplexHandler} which consolidates {@link Channel#flush()} / {@link ChannelHandlerContext#flush()}
|
||||
* {@link ChannelHandler} which consolidates {@link Channel#flush()} / {@link ChannelHandlerContext#flush()}
|
||||
* operations (which also includes
|
||||
* {@link Channel#writeAndFlush(Object)} / {@link Channel#writeAndFlush(Object, ChannelPromise)} and
|
||||
* {@link ChannelOutboundInvoker#writeAndFlush(Object)} /
|
||||
@ -38,7 +36,7 @@ import java.util.concurrent.Future;
|
||||
* as much as possible.
|
||||
* <p>
|
||||
* If a read loop is currently ongoing, {@link #flush(ChannelHandlerContext)} will not be passed on to the next
|
||||
* {@link ChannelOutboundHandler} in the {@link ChannelPipeline}, as it will pick up any pending flushes when
|
||||
* {@link ChannelHandler} in the {@link ChannelPipeline}, as it will pick up any pending flushes when
|
||||
* {@link #channelReadComplete(ChannelHandlerContext)} is triggered.
|
||||
* If no read loop is ongoing, the behavior depends on the {@code consolidateWhenNoReadInProgress} constructor argument:
|
||||
* <ul>
|
||||
@ -55,7 +53,7 @@ import java.util.concurrent.Future;
|
||||
* The {@link FlushConsolidationHandler} should be put as first {@link ChannelHandler} in the
|
||||
* {@link ChannelPipeline} to have the best effect.
|
||||
*/
|
||||
public class FlushConsolidationHandler extends ChannelDuplexHandler {
|
||||
public class FlushConsolidationHandler implements ChannelHandler {
|
||||
private final int explicitFlushAfterFlushes;
|
||||
private final boolean consolidateWhenNoReadInProgress;
|
||||
private final Runnable flushTask;
|
||||
|
@ -17,7 +17,6 @@ package io.netty.handler.logging;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufHolder;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -39,7 +38,7 @@ import static java.util.Objects.requireNonNull;
|
||||
*/
|
||||
@Sharable
|
||||
@SuppressWarnings({ "StringConcatenationInsideStringBufferAppend", "StringBufferReplaceableByString" })
|
||||
public class LoggingHandler extends ChannelDuplexHandler {
|
||||
public class LoggingHandler implements ChannelHandler {
|
||||
|
||||
private static final LogLevel DEFAULT_LEVEL = LogLevel.DEBUG;
|
||||
|
||||
|
@ -18,7 +18,6 @@ package io.netty.handler.ssl;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
@ -40,7 +39,7 @@ import java.util.Locale;
|
||||
* The client will send host name in the handshake data so server could decide
|
||||
* which certificate to choose for the host name.</p>
|
||||
*/
|
||||
public abstract class AbstractSniHandler<T> extends ByteToMessageDecoder implements ChannelOutboundHandler {
|
||||
public abstract class AbstractSniHandler<T> extends ByteToMessageDecoder {
|
||||
|
||||
// Maximal number of ssl records to inspect before fallback to the default SslContext.
|
||||
private static final int MAX_SSL_RECORDS = 4;
|
||||
|
@ -26,9 +26,8 @@ import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.ChannelPromiseNotifier;
|
||||
@ -84,7 +83,7 @@ import static java.util.Objects.requireNonNull;
|
||||
* <p>
|
||||
* Beside using the handshake {@link ChannelFuture} to get notified about the completion of the handshake it's
|
||||
* also possible to detect it by implement the
|
||||
* {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)}
|
||||
* {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)}
|
||||
* method and check for a {@link SslHandshakeCompletionEvent}.
|
||||
*
|
||||
* <h3>Handshake</h3>
|
||||
@ -164,7 +163,7 @@ import static java.util.Objects.requireNonNull;
|
||||
* For more details see
|
||||
* <a href="https://github.com/netty/netty/issues/832">#832</a> in our issue tracker.
|
||||
*/
|
||||
public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundHandler {
|
||||
public class SslHandler extends ByteToMessageDecoder {
|
||||
|
||||
private static final InternalLogger logger =
|
||||
InternalLoggerFactory.getInstance(SslHandler.class);
|
||||
|
@ -18,7 +18,6 @@ package io.netty.handler.stream;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -64,7 +63,7 @@ import java.util.Queue;
|
||||
* transfer. To resume the transfer when a new chunk is available, you have to
|
||||
* call {@link #resumeTransfer()}.
|
||||
*/
|
||||
public class ChunkedWriteHandler extends ChannelDuplexHandler {
|
||||
public class ChunkedWriteHandler implements ChannelHandler {
|
||||
|
||||
private static final InternalLogger logger =
|
||||
InternalLoggerFactory.getInstance(ChunkedWriteHandler.class);
|
||||
|
@ -20,9 +20,9 @@ import static java.util.Objects.requireNonNull;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.Channel.Unsafe;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
@ -74,7 +74,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* }
|
||||
*
|
||||
* // Handler should handle the {@link IdleStateEvent} triggered by {@link IdleStateHandler}.
|
||||
* public class MyHandler extends {@link ChannelDuplexHandler} {
|
||||
* public class MyHandler implements {@link ChannelHandler} {
|
||||
* {@code @Override}
|
||||
* public void userEventTriggered({@link ChannelHandlerContext} ctx, {@link Object} evt) throws {@link Exception} {
|
||||
* if (evt instanceof {@link IdleStateEvent}) {
|
||||
@ -97,7 +97,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @see ReadTimeoutHandler
|
||||
* @see WriteTimeoutHandler
|
||||
*/
|
||||
public class IdleStateHandler extends ChannelDuplexHandler {
|
||||
public class IdleStateHandler implements ChannelHandler {
|
||||
private static final long MIN_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(1);
|
||||
|
||||
// Not create a new ChannelFutureListener per write operation to reduce GC pressure.
|
||||
@ -259,7 +259,7 @@ public class IdleStateHandler extends ChannelDuplexHandler {
|
||||
if (ctx.channel().isActive()) {
|
||||
initialize(ctx);
|
||||
}
|
||||
super.channelRegistered(ctx);
|
||||
ctx.fireChannelRegistered();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -268,13 +268,13 @@ public class IdleStateHandler extends ChannelDuplexHandler {
|
||||
// before channelActive() event is fired. If a user adds this handler
|
||||
// after the channelActive() event, initialize() will be called by beforeAdd().
|
||||
initialize(ctx);
|
||||
super.channelActive(ctx);
|
||||
ctx.fireChannelActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
destroy();
|
||||
super.channelInactive(ctx);
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,7 @@ package io.netty.handler.timeout;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
|
||||
@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* }
|
||||
*
|
||||
* // Handler should handle the {@link ReadTimeoutException}.
|
||||
* public class MyHandler extends {@link ChannelDuplexHandler} {
|
||||
* public class MyHandler implements {@link ChannelHandler} {
|
||||
* {@code @Override}
|
||||
* public void exceptionCaught({@link ChannelHandlerContext} ctx, {@link Throwable} cause)
|
||||
* throws {@link Exception} {
|
||||
|
@ -19,12 +19,11 @@ import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@ -44,7 +43,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* }
|
||||
*
|
||||
* // Handler should handle the {@link WriteTimeoutException}.
|
||||
* public class MyHandler extends {@link ChannelDuplexHandler} {
|
||||
* public class MyHandler implements {@link ChannelHandler} {
|
||||
* {@code @Override}
|
||||
* public void exceptionCaught({@link ChannelHandlerContext} ctx, {@link Throwable} cause)
|
||||
* throws {@link Exception} {
|
||||
@ -64,7 +63,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @see ReadTimeoutHandler
|
||||
* @see IdleStateHandler
|
||||
*/
|
||||
public class WriteTimeoutHandler implements ChannelOutboundHandler {
|
||||
public class WriteTimeoutHandler implements ChannelHandler {
|
||||
private static final long MIN_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(1);
|
||||
|
||||
private final long timeoutNanos;
|
||||
|
@ -20,6 +20,7 @@ import io.netty.buffer.ByteBufHolder;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -46,7 +47,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* or start the monitoring, to change the checkInterval directly, or to have access to its values.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler {
|
||||
public abstract class AbstractTrafficShapingHandler implements ChannelHandler {
|
||||
private static final InternalLogger logger =
|
||||
InternalLoggerFactory.getInstance(AbstractTrafficShapingHandler.class);
|
||||
/**
|
||||
@ -578,7 +579,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
setUserDefinedWritability(ctx, true);
|
||||
super.channelRegistered(ctx);
|
||||
ctx.fireChannelRegistered();
|
||||
}
|
||||
|
||||
void setUserDefinedWritability(ChannelHandlerContext ctx, boolean writable) {
|
||||
|
@ -23,7 +23,6 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
@ -94,7 +93,7 @@ public class FlowControlHandlerTest {
|
||||
bootstrap.group(GROUP)
|
||||
.channel(NioSocketChannel.class)
|
||||
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000)
|
||||
.handler(new ChannelInboundHandler() {
|
||||
.handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
fail("In this test the client is never receiving a message from the server.");
|
||||
@ -119,7 +118,7 @@ public class FlowControlHandlerTest {
|
||||
public void testAutoReadingOn() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(3);
|
||||
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
ReferenceCountUtil.release(msg);
|
||||
@ -161,7 +160,7 @@ public class FlowControlHandlerTest {
|
||||
final Exchanger<Channel> peerRef = new Exchanger<>();
|
||||
final CountDownLatch latch = new CountDownLatch(3);
|
||||
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
peerRef.exchange(ctx.channel(), 1L, SECONDS);
|
||||
@ -207,7 +206,7 @@ public class FlowControlHandlerTest {
|
||||
public void testFlowAutoReadOn() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(3);
|
||||
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
latch.countDown();
|
||||
@ -244,7 +243,7 @@ public class FlowControlHandlerTest {
|
||||
final CountDownLatch setAutoReadLatch1 = new CountDownLatch(1);
|
||||
final CountDownLatch setAutoReadLatch2 = new CountDownLatch(1);
|
||||
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
private int msgRcvCount;
|
||||
private int expectedMsgCount;
|
||||
@Override
|
||||
@ -324,7 +323,7 @@ public class FlowControlHandlerTest {
|
||||
final CountDownLatch msgRcvLatch2 = new CountDownLatch(2);
|
||||
final CountDownLatch msgRcvLatch3 = new CountDownLatch(3);
|
||||
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelActive();
|
||||
|
@ -15,9 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.flush;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -154,7 +153,7 @@ public class FlushConsolidationHandlerTest {
|
||||
|
||||
private static EmbeddedChannel newChannel(final AtomicInteger flushCount, boolean consolidateWhenNoReadInProgress) {
|
||||
return new EmbeddedChannel(
|
||||
new ChannelOutboundHandler() {
|
||||
new ChannelHandler() {
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx) throws Exception {
|
||||
flushCount.incrementAndGet();
|
||||
@ -162,7 +161,7 @@ public class FlushConsolidationHandlerTest {
|
||||
}
|
||||
},
|
||||
new FlushConsolidationHandler(EXPLICIT_FLUSH_AFTER_FLUSHES, consolidateWhenNoReadInProgress),
|
||||
new ChannelInboundHandler() {
|
||||
new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.writeAndFlush(msg);
|
||||
|
@ -21,8 +21,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.CompositeByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -152,7 +152,7 @@ public class ParameterizedSslHandlerTest {
|
||||
handler.setWrapDataSize(-1);
|
||||
}
|
||||
ch.pipeline().addLast(handler);
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private boolean sentData;
|
||||
private Throwable writeCause;
|
||||
|
||||
@ -206,7 +206,7 @@ public class ParameterizedSslHandlerTest {
|
||||
} else {
|
||||
ch.pipeline().addLast(new SslHandler(sslClientCtx.newEngine(ch.alloc())));
|
||||
}
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private int bytesSeen;
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
@ -314,7 +314,7 @@ public class ParameterizedSslHandlerTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(sslServerCtx.newHandler(ch.alloc()));
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
// Just trigger a close
|
||||
@ -331,7 +331,7 @@ public class ParameterizedSslHandlerTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(sslClientCtx.newHandler(ch.alloc()));
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
if (cause.getCause() instanceof SSLException) {
|
||||
@ -428,7 +428,7 @@ public class ParameterizedSslHandlerTest {
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
final AtomicBoolean closeSent = new AtomicBoolean();
|
||||
if (timeout) {
|
||||
ch.pipeline().addFirst(new ChannelInboundHandler() {
|
||||
ch.pipeline().addFirst(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (closeSent.get()) {
|
||||
|
@ -18,8 +18,8 @@ package io.netty.handler.ssl;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -53,7 +53,7 @@ public abstract class RenegotiateTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(context.newHandler(ch.alloc()));
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private boolean renegotiate;
|
||||
|
||||
@Override
|
||||
@ -100,7 +100,7 @@ public abstract class RenegotiateTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(clientContext.newHandler(ch.alloc()));
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(
|
||||
ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
|
@ -24,8 +24,8 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -745,7 +745,7 @@ public abstract class SSLEngineTest {
|
||||
}
|
||||
p.addLast(handler);
|
||||
p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == SslHandshakeCompletionEvent.SUCCESS) {
|
||||
@ -787,7 +787,7 @@ public abstract class SSLEngineTest {
|
||||
clientSslCtx.newHandler(ch.alloc(), delegatingExecutor);
|
||||
p.addLast(handler);
|
||||
p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == SslHandshakeCompletionEvent.SUCCESS) {
|
||||
@ -894,7 +894,7 @@ public abstract class SSLEngineTest {
|
||||
serverSslCtx.newHandler(ch.alloc(), delegatingExecutor);
|
||||
p.addLast(handler);
|
||||
p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == SslHandshakeCompletionEvent.SUCCESS) {
|
||||
@ -946,7 +946,7 @@ public abstract class SSLEngineTest {
|
||||
sslHandler.engine().setSSLParameters(parameters);
|
||||
p.addLast(sslHandler);
|
||||
p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == SslHandshakeCompletionEvent.SUCCESS) {
|
||||
@ -1066,7 +1066,7 @@ public abstract class SSLEngineTest {
|
||||
|
||||
p.addLast(new SslHandler(engine));
|
||||
p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
if (cause.getCause() instanceof SSLHandshakeException) {
|
||||
@ -1109,7 +1109,7 @@ public abstract class SSLEngineTest {
|
||||
ChannelPipeline p = ch.pipeline();
|
||||
p.addLast(handler);
|
||||
p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt == SslHandshakeCompletionEvent.SUCCESS) {
|
||||
@ -1305,7 +1305,7 @@ public abstract class SSLEngineTest {
|
||||
serverSslCtx.newHandler(ch.alloc(), delegatingExecutor);
|
||||
|
||||
p.addLast(handler);
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
if (evt instanceof SslHandshakeCompletionEvent &&
|
||||
@ -1366,7 +1366,7 @@ public abstract class SSLEngineTest {
|
||||
// the unit test can terminate relativley quicly.
|
||||
sslHandler.setHandshakeTimeout(1, TimeUnit.SECONDS);
|
||||
p.addLast(sslHandler);
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
private int handshakeCount;
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
@ -1655,7 +1655,7 @@ public abstract class SSLEngineTest {
|
||||
|
||||
p.addLast(sslHandler);
|
||||
p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
if (cause.getCause() instanceof SSLHandshakeException) {
|
||||
@ -1685,7 +1685,7 @@ public abstract class SSLEngineTest {
|
||||
|
||||
p.addLast(sslHandler);
|
||||
p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch));
|
||||
p.addLast(new ChannelInboundHandler() {
|
||||
p.addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
if (cause.getCause() instanceof SSLHandshakeException) {
|
||||
@ -1739,7 +1739,7 @@ public abstract class SSLEngineTest {
|
||||
serverSslCtx.newHandler(ch.alloc(), delegatingExecutor);
|
||||
|
||||
ch.pipeline().addFirst(sslHandler);
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof SslHandshakeCompletionEvent) {
|
||||
|
@ -19,8 +19,8 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
@ -108,7 +108,7 @@ final class SniClientJava8TestUtil {
|
||||
handler.engine().setSSLParameters(parameters);
|
||||
|
||||
ch.pipeline().addFirst(handler);
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof SslHandshakeCompletionEvent) {
|
||||
|
@ -23,8 +23,8 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -149,7 +149,7 @@ public class SniHandlerTest {
|
||||
final AtomicReference<SslHandshakeCompletionEvent> evtRef =
|
||||
new AtomicReference<>();
|
||||
SniHandler handler = new SniHandler(new DomainNameMappingBuilder<>(nettyContext).build());
|
||||
EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandler() {
|
||||
EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof SslHandshakeCompletionEvent) {
|
||||
@ -196,7 +196,7 @@ public class SniHandlerTest {
|
||||
|
||||
final AtomicReference<SniCompletionEvent> evtRef = new AtomicReference<>();
|
||||
SniHandler handler = new SniHandler(mapping);
|
||||
EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandler() {
|
||||
EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof SniCompletionEvent) {
|
||||
|
@ -18,8 +18,8 @@ package io.netty.handler.ssl;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -164,7 +164,7 @@ public class SslErrorTest {
|
||||
if (!serverProduceError) {
|
||||
ch.pipeline().addLast(new AlertValidationHandler(promise));
|
||||
}
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
@ -184,7 +184,7 @@ public class SslErrorTest {
|
||||
if (serverProduceError) {
|
||||
ch.pipeline().addLast(new AlertValidationHandler(promise));
|
||||
}
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
@ -239,7 +239,7 @@ public class SslErrorTest {
|
||||
}
|
||||
}
|
||||
|
||||
private final class AlertValidationHandler implements ChannelInboundHandler {
|
||||
private final class AlertValidationHandler implements ChannelHandler {
|
||||
private final Promise<Void> promise;
|
||||
|
||||
AlertValidationHandler(Promise<Void> promise) {
|
||||
|
@ -27,9 +27,7 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.DefaultChannelId;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -95,7 +93,7 @@ public class SslHandlerTest {
|
||||
|
||||
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
|
||||
EmbeddedChannel ch = new EmbeddedChannel(
|
||||
DefaultChannelId.newInstance(), false, false, new ChannelInboundHandler() {
|
||||
DefaultChannelId.newInstance(), false, false, new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
// Not forward the event to the SslHandler but just close the Channel.
|
||||
@ -110,7 +108,7 @@ public class SslHandlerTest {
|
||||
super.handlerAdded(ctx);
|
||||
inActive.set(false);
|
||||
}
|
||||
}, new ChannelInboundHandler() {
|
||||
}, new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof SslHandshakeCompletionEvent) {
|
||||
@ -274,7 +272,7 @@ public class SslHandlerTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TlsReadTest implements ChannelOutboundHandler {
|
||||
private static final class TlsReadTest implements ChannelHandler {
|
||||
private volatile boolean readIssued;
|
||||
|
||||
@Override
|
||||
@ -290,7 +288,7 @@ public class SslHandlerTest {
|
||||
EmbeddedChannel ch = new EmbeddedChannel(false, false,
|
||||
this,
|
||||
new SslHandler(engine),
|
||||
new ChannelInboundHandler() {
|
||||
new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
if (!dropChannelActive) {
|
||||
@ -375,7 +373,7 @@ public class SslHandlerTest {
|
||||
ch.eventLoop().execute(ch::close);
|
||||
});
|
||||
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
if (cause instanceof CodecException) {
|
||||
@ -418,7 +416,7 @@ public class SslHandlerTest {
|
||||
public void testEventsFired() throws Exception {
|
||||
SSLEngine engine = newServerModeSSLEngine();
|
||||
final BlockingQueue<SslCompletionEvent> events = new LinkedBlockingQueue<>();
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new SslHandler(engine), new ChannelInboundHandler() {
|
||||
EmbeddedChannel channel = new EmbeddedChannel(new SslHandler(engine), new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof SslCompletionEvent) {
|
||||
@ -457,7 +455,7 @@ public class SslHandlerTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(sslServerCtx.newHandler(ch.alloc()));
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
ByteBuf buf = ctx.alloc().buffer(10);
|
||||
@ -486,7 +484,7 @@ public class SslHandlerTest {
|
||||
.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addFirst(new ChannelInboundHandler() {
|
||||
ch.pipeline().addFirst(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
ByteBuf buf = ctx.alloc().buffer(1000);
|
||||
@ -691,7 +689,7 @@ public class SslHandlerTest {
|
||||
sc = new ServerBootstrap()
|
||||
.group(group)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(new ChannelInboundHandler() { })
|
||||
.childHandler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
|
||||
cc = new Bootstrap()
|
||||
@ -701,7 +699,7 @@ public class SslHandlerTest {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(sslHandler);
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
|
||||
throws Exception {
|
||||
@ -770,7 +768,7 @@ public class SslHandlerTest {
|
||||
sc = new ServerBootstrap()
|
||||
.group(group)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(new ChannelInboundHandler() { })
|
||||
.childHandler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
|
||||
ChannelFuture future = new Bootstrap()
|
||||
@ -781,7 +779,7 @@ public class SslHandlerTest {
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(sslHandler);
|
||||
if (startTls) {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.writeAndFlush(wrappedBuffer(new byte[] { 1, 2, 3, 4 }));
|
||||
|
@ -23,7 +23,6 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -164,7 +163,7 @@ public class OcspTest {
|
||||
*/
|
||||
private static void testClientAcceptingOcspStaple(SslProvider sslProvider) throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
ChannelInboundHandler serverHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler serverHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.writeAndFlush(Unpooled.wrappedBuffer("Hello, World!".getBytes()));
|
||||
@ -172,7 +171,7 @@ public class OcspTest {
|
||||
}
|
||||
};
|
||||
|
||||
ChannelInboundHandler clientHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler clientHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
try {
|
||||
@ -212,7 +211,7 @@ public class OcspTest {
|
||||
final AtomicReference<Throwable> causeRef = new AtomicReference<>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
ChannelInboundHandler clientHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler clientHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
try {
|
||||
@ -253,7 +252,7 @@ public class OcspTest {
|
||||
*/
|
||||
private static void testServerHasNoStaple(SslProvider sslProvider) throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
ChannelInboundHandler serverHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler serverHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.writeAndFlush(Unpooled.wrappedBuffer("Hello, World!".getBytes()));
|
||||
@ -261,7 +260,7 @@ public class OcspTest {
|
||||
}
|
||||
};
|
||||
|
||||
ChannelInboundHandler clientHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler clientHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
try {
|
||||
@ -302,7 +301,7 @@ public class OcspTest {
|
||||
final AtomicReference<Throwable> causeRef = new AtomicReference<>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
ChannelInboundHandler clientHandler = new ChannelInboundHandler() {
|
||||
ChannelHandler clientHandler = new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
try {
|
||||
|
@ -20,8 +20,8 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.util.CharsetUtil;
|
||||
@ -273,7 +273,7 @@ public class ChunkedWriteHandlerTest {
|
||||
// See https://github.com/netty/netty/issues/8700.
|
||||
@Test
|
||||
public void testFailureWhenLastChunkFailed() throws IOException {
|
||||
ChannelOutboundHandler failLast = new ChannelOutboundHandler() {
|
||||
ChannelHandler failLast = new ChannelHandler() {
|
||||
private int passedWrites;
|
||||
|
||||
@Override
|
||||
@ -409,7 +409,7 @@ public class ChunkedWriteHandlerTest {
|
||||
}
|
||||
};
|
||||
|
||||
ChannelOutboundHandler noOpWrites = new ChannelOutboundHandler() {
|
||||
ChannelHandler noOpWrites = new ChannelHandler() {
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
|
||||
ReferenceCountUtil.release(msg);
|
||||
@ -595,7 +595,7 @@ public class ChunkedWriteHandlerTest {
|
||||
}
|
||||
|
||||
private static void checkFirstFailed(Object input) {
|
||||
ChannelOutboundHandler noOpWrites = new ChannelOutboundHandler() {
|
||||
ChannelHandler noOpWrites = new ChannelHandler() {
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
|
||||
ReferenceCountUtil.release(msg);
|
||||
@ -612,7 +612,7 @@ public class ChunkedWriteHandlerTest {
|
||||
}
|
||||
|
||||
private static void checkSkipFailed(Object input1, Object input2) {
|
||||
ChannelOutboundHandler failFirst = new ChannelOutboundHandler() {
|
||||
ChannelHandler failFirst = new ChannelHandler() {
|
||||
private boolean alreadyFailed;
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
@ -72,7 +71,7 @@ public class IdleStateHandlerTest {
|
||||
assertTrue("The number of expected events must be >= 1", expected.length >= 1);
|
||||
|
||||
final List<Object> events = new ArrayList<>();
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
events.add(evt);
|
||||
@ -143,7 +142,7 @@ public class IdleStateHandlerTest {
|
||||
Action action, Object expected) throws Exception {
|
||||
|
||||
final List<Object> events = new ArrayList<>();
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
events.add(evt);
|
||||
@ -203,7 +202,7 @@ public class IdleStateHandlerTest {
|
||||
true, 0L, writerIdleTime, allIdleTime, TimeUnit.SECONDS);
|
||||
|
||||
final List<Object> events = new ArrayList<>();
|
||||
ChannelInboundHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
events.add(evt);
|
||||
|
@ -19,6 +19,7 @@ import io.netty.buffer.PooledByteBufAllocator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -79,7 +80,7 @@ public class Http2FrameWriterDataBenchmark extends AbstractMicrobenchmark {
|
||||
payload.writeZero(payloadSize);
|
||||
ctx = new EmbeddedChannelWriteReleaseHandlerContext(
|
||||
pooled ? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT,
|
||||
new ChannelInboundHandler() { }) {
|
||||
new ChannelHandler() { }) {
|
||||
@Override
|
||||
protected void handleException(Throwable t) {
|
||||
handleUnexpectedException(t);
|
||||
|
@ -17,7 +17,6 @@ package io.netty.microbench.channel;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.microbench.util.AbstractMicrobenchmark;
|
||||
@ -38,10 +37,10 @@ import org.openjdk.jmh.infra.Blackhole;
|
||||
public class DefaultChannelPipelineBenchmark extends AbstractMicrobenchmark {
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
private static final ChannelInboundHandler NOOP_HANDLER = new ChannelInboundHandler() { };
|
||||
private static final ChannelHandler NOOP_HANDLER = new ChannelHandler() { };
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
private static final ChannelInboundHandler CONSUMING_HANDLER = new ChannelInboundHandler() {
|
||||
private static final ChannelHandler CONSUMING_HANDLER = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) {
|
||||
// NOOP
|
||||
|
@ -19,7 +19,6 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelProgressivePromise;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -108,11 +107,8 @@ public abstract class EmbeddedChannelHandlerContext implements ChannelHandlerCon
|
||||
|
||||
@Override
|
||||
public final ChannelHandlerContext fireExceptionCaught(Throwable cause) {
|
||||
ChannelHandler handler = handler();
|
||||
try {
|
||||
if (handler instanceof ChannelInboundHandler) {
|
||||
((ChannelInboundHandler) handler).exceptionCaught(this, cause);
|
||||
}
|
||||
handler().exceptionCaught(this, cause);
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -57,7 +57,7 @@ public class EpollSocketChannelBenchmark extends AbstractMicrobenchmark {
|
||||
.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelDuplexHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
if (msg instanceof ByteBuf) {
|
||||
@ -77,7 +77,7 @@ public class EpollSocketChannelBenchmark extends AbstractMicrobenchmark {
|
||||
.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelDuplexHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
|
||||
private ChannelPromise lastWritePromise;
|
||||
|
||||
@ -108,7 +108,7 @@ public class EpollSocketChannelBenchmark extends AbstractMicrobenchmark {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
lastWritePromise = promise;
|
||||
super.write(ctx, msg, ctx.voidPromise());
|
||||
ctx.write(msg, ctx.voidPromise());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ import io.netty.buffer.CompositeByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
@ -54,7 +54,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest {
|
||||
sb.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.writeAndFlush(newCompositeBuffer(ctx.alloc()))
|
||||
@ -66,7 +66,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private ByteBuf aggregator;
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
@ -164,7 +164,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest {
|
||||
.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
compositeBufferPartialWriteDoesNotCorruptDataInitServerConfig(ctx.channel().config(),
|
||||
@ -208,7 +208,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private ByteBuf aggregator;
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
|
@ -19,6 +19,7 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.testsuite.transport.TestsuitePermutation;
|
||||
@ -46,7 +47,7 @@ public class DatagramConnectNotExistsTest extends AbstractClientSocketTest {
|
||||
|
||||
public void testConnectNotExists(Bootstrap cb) throws Throwable {
|
||||
final Promise<Throwable> promise = ImmediateEventExecutor.INSTANCE.newPromise();
|
||||
cb.handler(new ChannelInboundHandler() {
|
||||
cb.handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
promise.trySuccess(cause);
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import org.junit.Test;
|
||||
@ -32,7 +33,7 @@ public class SocketChannelNotYetConnectedTest extends AbstractClientSocketTest {
|
||||
}
|
||||
|
||||
public void testShutdownNotYetConnected(Bootstrap cb) throws Throwable {
|
||||
SocketChannel ch = (SocketChannel) cb.handler(new ChannelInboundHandler() { })
|
||||
SocketChannel ch = (SocketChannel) cb.handler(new ChannelHandler() { })
|
||||
.bind(newSocketAddress()).syncUninterruptibly().channel();
|
||||
try {
|
||||
try {
|
||||
|
@ -18,6 +18,7 @@ package io.netty.testsuite.transport.socket;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
@ -31,7 +32,7 @@ public class SocketCloseForciblyTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
public void testCloseForcibly(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
sb.handler(new ChannelInboundHandler() {
|
||||
sb.handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
final SocketChannel childChannel = (SocketChannel) msg;
|
||||
@ -41,9 +42,9 @@ public class SocketCloseForciblyTest extends AbstractSocketTest {
|
||||
childChannel.unsafe().closeForcibly();
|
||||
});
|
||||
}
|
||||
}).childHandler(new ChannelInboundHandler() { });
|
||||
}).childHandler(new ChannelHandler() { });
|
||||
|
||||
cb.handler(new ChannelInboundHandler() { });
|
||||
cb.handler(new ChannelHandler() { });
|
||||
|
||||
Channel sc = sb.bind().sync().channel();
|
||||
|
||||
|
@ -19,9 +19,8 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.WriteBufferWaterMark;
|
||||
@ -47,7 +46,7 @@ public class SocketConditionalWritabilityTest extends AbstractSocketTest {
|
||||
sb.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelDuplexHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private int bytesWritten;
|
||||
|
||||
@Override
|
||||
@ -90,7 +89,7 @@ public class SocketConditionalWritabilityTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private int totalRead;
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
|
@ -19,8 +19,8 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.util.concurrent.ImmediateEventExecutor;
|
||||
import io.netty.util.concurrent.Promise;
|
||||
import org.junit.Test;
|
||||
@ -43,14 +43,14 @@ public class SocketConnectTest extends AbstractSocketTest {
|
||||
Channel clientChannel = null;
|
||||
try {
|
||||
final Promise<InetSocketAddress> localAddressPromise = ImmediateEventExecutor.INSTANCE.newPromise();
|
||||
serverChannel = sb.childHandler(new ChannelInboundHandler() {
|
||||
serverChannel = sb.childHandler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
localAddressPromise.setSuccess((InetSocketAddress) ctx.channel().localAddress());
|
||||
}
|
||||
}).bind().syncUninterruptibly().channel();
|
||||
|
||||
clientChannel = cb.handler(new ChannelInboundHandler() { }).register().syncUninterruptibly().channel();
|
||||
clientChannel = cb.handler(new ChannelHandler() { }).register().syncUninterruptibly().channel();
|
||||
|
||||
assertNull(clientChannel.localAddress());
|
||||
assertNull(clientChannel.remoteAddress());
|
||||
@ -81,10 +81,10 @@ public class SocketConnectTest extends AbstractSocketTest {
|
||||
Channel sc = null;
|
||||
Channel cc = null;
|
||||
try {
|
||||
sb.childHandler(new ChannelInboundHandler() { });
|
||||
sb.childHandler(new ChannelHandler() { });
|
||||
sc = sb.bind().syncUninterruptibly().channel();
|
||||
|
||||
cb.handler(new ChannelInboundHandler() {
|
||||
cb.handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
events.add(0);
|
||||
|
@ -19,7 +19,6 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.util.internal.SocketUtils;
|
||||
import io.netty.util.NetUtil;
|
||||
@ -78,7 +77,7 @@ public class SocketConnectionAttemptTest extends AbstractClientSocketTest {
|
||||
|
||||
private static void testConnectRefused0(Bootstrap cb, boolean halfClosure) throws Throwable {
|
||||
final Promise<Error> errorPromise = GlobalEventExecutor.INSTANCE.newPromise();
|
||||
ChannelHandler handler = new ChannelInboundHandler() {
|
||||
ChannelHandler handler = new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
errorPromise.setFailure(new AssertionError("should have never been called"));
|
||||
@ -142,7 +141,7 @@ public class SocketConnectionAttemptTest extends AbstractClientSocketTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestHandler implements ChannelInboundHandler {
|
||||
private static class TestHandler implements ChannelHandler {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
InternalLoggerFactory.getInstance(
|
||||
|
@ -19,8 +19,8 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import org.junit.Test;
|
||||
@ -55,7 +55,7 @@ public class SocketDataReadInitialStateTest extends AbstractSocketTest {
|
||||
sb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
acceptorReadLatch.countDown();
|
||||
|
@ -20,8 +20,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.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import org.junit.Test;
|
||||
@ -85,7 +85,7 @@ public class SocketEchoTest extends AbstractSocketTest {
|
||||
final EchoHandler ch = new EchoHandler(autoRead);
|
||||
|
||||
sb.childHandler(sh);
|
||||
sb.handler(new ChannelInboundHandler() {
|
||||
sb.handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
cause.printStackTrace();
|
||||
|
@ -20,8 +20,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.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.DefaultFileRegion;
|
||||
import io.netty.channel.FileRegion;
|
||||
@ -113,7 +113,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
|
||||
// Just drop the message.
|
||||
}
|
||||
});
|
||||
cb.handler(new ChannelInboundHandler() { });
|
||||
cb.handler(new ChannelHandler() { });
|
||||
|
||||
Channel sc = sb.bind().sync().channel();
|
||||
Channel cc = cb.connect(sc.localAddress()).sync().channel();
|
||||
@ -156,7 +156,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
|
||||
|
||||
out.close();
|
||||
|
||||
ChannelInboundHandler ch = new SimpleChannelInboundHandler<Object>() {
|
||||
ChannelHandler ch = new SimpleChannelInboundHandler<Object>() {
|
||||
@Override
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.RecvByteBufAllocator;
|
||||
@ -61,7 +61,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
|
||||
sb.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
((DuplexChannel) ctx).shutdownOutput();
|
||||
@ -81,7 +81,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
|
||||
@Override
|
||||
public void userEventTriggered(final ChannelHandlerContext ctx, Object evt) {
|
||||
@ -141,7 +141,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
|
||||
sb.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ByteBuf buf = ctx.alloc().buffer(totalServerBytesWritten);
|
||||
@ -162,7 +162,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private int bytesRead;
|
||||
|
||||
@Override
|
||||
@ -440,7 +440,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
|
||||
sb.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ByteBuf buf = ctx.alloc().buffer(totalServerBytesWritten);
|
||||
@ -460,7 +460,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
private int bytesRead;
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.testsuite.transport.TestsuitePermutation;
|
||||
import io.netty.util.NetUtil;
|
||||
import org.junit.Test;
|
||||
@ -41,10 +41,10 @@ public class SocketMultipleConnectTest extends AbstractSocketTest {
|
||||
Channel sc = null;
|
||||
Channel cc = null;
|
||||
try {
|
||||
sb.childHandler(new ChannelInboundHandler() { });
|
||||
sb.childHandler(new ChannelHandler() { });
|
||||
sc = sb.bind(NetUtil.LOCALHOST, 0).syncUninterruptibly().channel();
|
||||
|
||||
cb.handler(new ChannelInboundHandler() { });
|
||||
cb.handler(new ChannelHandler() { });
|
||||
cc = cb.register().syncUninterruptibly().channel();
|
||||
cc.connect(sc.localAddress()).syncUninterruptibly();
|
||||
ChannelFuture connectFuture2 = cc.connect(sc.localAddress()).await();
|
||||
|
@ -18,8 +18,8 @@ package io.netty.testsuite.transport.socket;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import org.junit.Test;
|
||||
@ -62,7 +62,7 @@ public class SocketRstTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
throwableRef.compareAndSet(null, cause);
|
||||
@ -115,7 +115,7 @@ public class SocketRstTest extends AbstractSocketTest {
|
||||
cb.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
throwableRef.compareAndSet(null, cause);
|
||||
|
@ -19,8 +19,8 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.WriteBufferWaterMark;
|
||||
@ -216,7 +216,7 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest {
|
||||
ChannelFuture cf = null;
|
||||
try {
|
||||
ss.bind(newSocketAddress());
|
||||
cf = cb.option(ChannelOption.SO_LINGER, 1).handler(new ChannelInboundHandler() { })
|
||||
cf = cb.option(ChannelOption.SO_LINGER, 1).handler(new ChannelHandler() { })
|
||||
.connect(ss.getLocalSocketAddress()).sync();
|
||||
s = ss.accept();
|
||||
|
||||
|
@ -19,6 +19,7 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.unix.DomainSocketReadMode;
|
||||
@ -52,7 +53,7 @@ public class EpollDomainSocketFdTest extends AbstractSocketTest {
|
||||
|
||||
public void testSendRecvFd(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
final BlockingQueue<Object> queue = new LinkedBlockingQueue<>(1);
|
||||
sb.childHandler(new ChannelInboundHandler() {
|
||||
sb.childHandler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
// Create new channel and obtain a file descriptor from it.
|
||||
@ -66,7 +67,7 @@ public class EpollDomainSocketFdTest extends AbstractSocketTest {
|
||||
});
|
||||
}
|
||||
});
|
||||
cb.handler(new ChannelInboundHandler() {
|
||||
cb.handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
FileDescriptor fd = (FileDescriptor) msg;
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.channel.epoll;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -40,7 +40,7 @@ public class EpollServerSocketChannelConfigTest {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
ch = (EpollServerSocketChannel) bootstrap.group(group)
|
||||
.channel(EpollServerSocketChannel.class)
|
||||
.childHandler(new ChannelInboundHandler() { })
|
||||
.childHandler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
|
||||
@ -57,7 +57,7 @@ public class EpollSocketChannelConfigTest {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
ch = (EpollSocketChannel) bootstrap.group(group)
|
||||
.channel(EpollSocketChannel.class)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.channel.epoll;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -35,7 +35,7 @@ public class EpollSocketChannelTest {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
EpollSocketChannel ch = (EpollSocketChannel) bootstrap.group(group)
|
||||
.channel(EpollSocketChannel.class)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
EpollTcpInfo info = ch.tcpInfo();
|
||||
assertTcpInfo0(info);
|
||||
@ -53,7 +53,7 @@ public class EpollSocketChannelTest {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
EpollSocketChannel ch = (EpollSocketChannel) bootstrap.group(group)
|
||||
.channel(EpollSocketChannel.class)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
EpollTcpInfo info = new EpollTcpInfo();
|
||||
ch.tcpInfo(info);
|
||||
@ -111,7 +111,7 @@ public class EpollSocketChannelTest {
|
||||
EpollSocketChannel ch = (EpollSocketChannel) bootstrap.group(group)
|
||||
.channel(EpollSocketChannel.class)
|
||||
.option(ChannelOption.SO_LINGER, 10)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
ch.close().syncUninterruptibly();
|
||||
} finally {
|
||||
|
@ -17,7 +17,7 @@ package io.netty.channel.epoll;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.ConnectTimeoutException;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
@ -55,7 +55,7 @@ public class EpollSocketTcpMd5Test {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
server = (EpollServerSocketChannel) bootstrap.group(GROUP)
|
||||
.channel(EpollServerSocketChannel.class)
|
||||
.childHandler(new ChannelInboundHandler() { })
|
||||
.childHandler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(NetUtil.LOCALHOST4, 0)).syncUninterruptibly().channel();
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class EpollSocketTcpMd5Test {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
EpollServerSocketChannel ch = (EpollServerSocketChannel) bootstrap.group(GROUP)
|
||||
.channel(EpollServerSocketChannel.class)
|
||||
.childHandler(new ChannelInboundHandler() { })
|
||||
.childHandler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
|
||||
ch.config().setOption(EpollChannelOption.TCP_MD5SIG,
|
||||
@ -93,7 +93,7 @@ public class EpollSocketTcpMd5Test {
|
||||
|
||||
EpollSocketChannel client = (EpollSocketChannel) new Bootstrap().group(GROUP)
|
||||
.channel(EpollSocketChannel.class)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.option(EpollChannelOption.TCP_MD5SIG,
|
||||
Collections.singletonMap(NetUtil.LOCALHOST4, BAD_KEY))
|
||||
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000)
|
||||
@ -108,7 +108,7 @@ public class EpollSocketTcpMd5Test {
|
||||
|
||||
EpollSocketChannel client = (EpollSocketChannel) new Bootstrap().group(GROUP)
|
||||
.channel(EpollSocketChannel.class)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.option(EpollChannelOption.TCP_MD5SIG,
|
||||
Collections.singletonMap(NetUtil.LOCALHOST4, SERVER_KEY))
|
||||
.connect(server.localAddress()).syncUninterruptibly().channel();
|
||||
|
@ -22,8 +22,8 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
@ -64,7 +64,7 @@ public class EpollSpliceTest {
|
||||
ServerBootstrap bs2 = new ServerBootstrap();
|
||||
bs2.channel(EpollServerSocketChannel.class);
|
||||
bs2.childOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);
|
||||
bs2.group(group).childHandler(new ChannelInboundHandler() {
|
||||
bs2.group(group).childHandler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.channel().config().setAutoRead(false);
|
||||
@ -72,7 +72,7 @@ public class EpollSpliceTest {
|
||||
bs.option(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);
|
||||
|
||||
bs.channel(EpollSocketChannel.class);
|
||||
bs.group(ctx.channel().eventLoop()).handler(new ChannelInboundHandler() {
|
||||
bs.group(ctx.channel().eventLoop()).handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext context) throws Exception {
|
||||
final EpollSocketChannel ch = (EpollSocketChannel) ctx.channel();
|
||||
@ -195,7 +195,7 @@ public class EpollSpliceTest {
|
||||
Bootstrap cb = new Bootstrap();
|
||||
cb.group(group);
|
||||
cb.channel(EpollSocketChannel.class);
|
||||
cb.handler(new ChannelInboundHandler() { });
|
||||
cb.handler(new ChannelHandler() { });
|
||||
Channel cc = cb.connect(sc.localAddress()).syncUninterruptibly().channel();
|
||||
|
||||
for (int i = 0; i < data.length;) {
|
||||
@ -278,7 +278,7 @@ public class EpollSpliceTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static class SpliceHandler implements ChannelInboundHandler {
|
||||
private static class SpliceHandler implements ChannelHandler {
|
||||
private final File file;
|
||||
|
||||
volatile Channel channel;
|
||||
|
@ -17,6 +17,7 @@ package io.netty.channel.kqueue;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
@ -80,7 +81,7 @@ public class KQueueChannelConfigTest {
|
||||
KQueueSocketChannel ch = (KQueueSocketChannel) bootstrap.group(group)
|
||||
.channel(KQueueSocketChannel.class)
|
||||
.option(ChannelOption.SO_LINGER, 10)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
ch.close().syncUninterruptibly();
|
||||
} finally {
|
||||
|
@ -19,6 +19,7 @@ import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.unix.DomainSocketReadMode;
|
||||
@ -51,7 +52,7 @@ public class KQueueDomainSocketFdTest extends AbstractSocketTest {
|
||||
|
||||
public void testSendRecvFd(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
final BlockingQueue<Object> queue = new LinkedBlockingQueue<>(1);
|
||||
sb.childHandler(new ChannelInboundHandler() {
|
||||
sb.childHandler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
// Create new channel and obtain a file descriptor from it.
|
||||
@ -65,7 +66,7 @@ public class KQueueDomainSocketFdTest extends AbstractSocketTest {
|
||||
});
|
||||
}
|
||||
});
|
||||
cb.handler(new ChannelInboundHandler() {
|
||||
cb.handler(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
FileDescriptor fd = (FileDescriptor) msg;
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.channel.kqueue;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -42,7 +43,7 @@ public class KQueueServerSocketChannelConfigTest {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
ch = (KQueueServerSocketChannel) bootstrap.group(group)
|
||||
.channel(KQueueServerSocketChannel.class)
|
||||
.childHandler(new ChannelInboundHandler() { })
|
||||
.childHandler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ package io.netty.channel.kqueue;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.MultithreadEventLoopGroup;
|
||||
@ -59,7 +60,7 @@ public class KQueueSocketChannelConfigTest {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
ch = (KQueueSocketChannel) bootstrap.group(group)
|
||||
.channel(KQueueSocketChannel.class)
|
||||
.handler(new ChannelInboundHandler() { })
|
||||
.handler(new ChannelHandler() { })
|
||||
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@ import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
@ -82,7 +82,7 @@ public abstract class DetectPeerCloseWithoutReadTest {
|
||||
Bootstrap cb = new Bootstrap();
|
||||
cb.group(serverGroup);
|
||||
cb.channel(clientChannel());
|
||||
cb.handler(new ChannelInboundHandler() { });
|
||||
cb.handler(new ChannelHandler() { });
|
||||
Channel clientChannel = cb.connect(serverChannel.localAddress()).syncUninterruptibly().channel();
|
||||
ByteBuf buf = clientChannel.alloc().buffer(expectedBytes);
|
||||
buf.writerIndex(buf.writerIndex() + expectedBytes);
|
||||
@ -130,7 +130,7 @@ public abstract class DetectPeerCloseWithoutReadTest {
|
||||
sb.childHandler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) {
|
||||
ch.pipeline().addLast(new ChannelInboundHandler() {
|
||||
ch.pipeline().addLast(new ChannelHandler() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
ByteBuf buf = ctx.alloc().buffer(expectedBytes);
|
||||
|
@ -21,7 +21,10 @@ package io.netty.channel;
|
||||
*
|
||||
* It is a good starting point if your {@link ChannelHandler} implementation needs to intercept operations and also
|
||||
* state updates.
|
||||
*
|
||||
* @deprecated use {@link ChannelHandler}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ChannelDuplexHandler extends ChannelHandlerAdapter
|
||||
implements ChannelInboundHandler, ChannelOutboundHandler {
|
||||
}
|
||||
|
@ -24,28 +24,12 @@ 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}.
|
||||
*
|
||||
* <h3>Sub-types</h3>
|
||||
* <p>
|
||||
* {@link ChannelHandler} itself does not provide many methods, but you usually have to implement one of its subtypes:
|
||||
* <ul>
|
||||
* <li>{@link ChannelInboundHandler} to handle inbound I/O events, and</li>
|
||||
* <li>{@link ChannelOutboundHandler} to handle outbound I/O operations.</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* <p>
|
||||
* Alternatively, the following adapter classes are provided for your convenience:
|
||||
* <ul>
|
||||
* <li>{@link ChannelDuplexHandler} to handle both inbound and outbound events</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* <p>
|
||||
* For more information, please refer to the documentation of each subtype.
|
||||
* </p>
|
||||
*
|
||||
* <h3>The context object</h3>
|
||||
* <p>
|
||||
@ -235,4 +219,193 @@ public interface ChannelHandler {
|
||||
@interface Skip {
|
||||
// no value
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link EventLoop}
|
||||
*/
|
||||
@Skip
|
||||
default void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelRegistered();
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} was unregistered from its {@link EventLoop}
|
||||
*/
|
||||
@Skip
|
||||
default void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelUnregistered();
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} is now active
|
||||
*/
|
||||
@Skip
|
||||
default void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} was registered is now inactive and reached its
|
||||
* end of lifetime.
|
||||
*/
|
||||
@Skip
|
||||
default void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the current {@link Channel} has read a message from the peer.
|
||||
*/
|
||||
@Skip
|
||||
default void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Skip
|
||||
default void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelReadComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called if an user event was triggered.
|
||||
*/
|
||||
@Skip
|
||||
default void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
ctx.fireUserEventTriggered(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called once the writable state of a {@link Channel} changed. You can check the state with
|
||||
* {@link Channel#isWritable()}.
|
||||
*/
|
||||
@Skip
|
||||
default void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelWritabilityChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called if a {@link Throwable} was thrown.
|
||||
*/
|
||||
@Skip
|
||||
default void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
ctx.fireExceptionCaught(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
|
||||
ctx.bind(localAddress, promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void connect(
|
||||
ChannelHandlerContext ctx, SocketAddress remoteAddress,
|
||||
SocketAddress localAddress, ChannelPromise promise) throws Exception {
|
||||
ctx.connect(remoteAddress, localAddress, promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.disconnect(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.close(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once a register operation is made to register for IO on the {@link EventLoop}.
|
||||
*
|
||||
* @param ctx the {@link ChannelHandlerContext} for which the register operation is made
|
||||
* @param promise the {@link ChannelPromise} to notify once the operation completes
|
||||
* @throws Exception thrown if an error occurs
|
||||
*/
|
||||
@Skip
|
||||
default void register(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.register(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once a deregister operation is made from the current registered {@link EventLoop}.
|
||||
*
|
||||
* @param ctx the {@link ChannelHandlerContext} for which the deregister operation is made
|
||||
* @param promise the {@link ChannelPromise} to notify once the operation completes
|
||||
* @throws Exception thrown if an error occurs
|
||||
*/
|
||||
@Skip
|
||||
default void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.deregister(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercepts {@link ChannelHandlerContext#read()}.
|
||||
*/
|
||||
@Skip
|
||||
default void read(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.read();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
ctx.write(msg, promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void flush(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
}
|
||||
|
@ -64,20 +64,4 @@ public abstract class ChannelHandlerAdapter implements ChannelHandler {
|
||||
}
|
||||
return sharable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing by default, sub-classes may override this method.
|
||||
*/
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing by default, sub-classes may override this method.
|
||||
*/
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ 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.
|
||||
* <pre>
|
||||
* public class MyHandler extends {@link ChannelDuplexHandler} {
|
||||
* public class MyHandler extends {@link ChannelHandler} {
|
||||
*
|
||||
* <b>private {@link ChannelHandlerContext} ctx;</b>
|
||||
*
|
||||
* public void beforeAdd({@link ChannelHandlerContext} ctx) {
|
||||
* public void handlerAdded({@link ChannelHandlerContext} ctx) {
|
||||
* <b>this.ctx = ctx;</b>
|
||||
* }
|
||||
*
|
||||
|
170
transport/src/main/java/io/netty/channel/ChannelHandlerMask.java
Normal file
170
transport/src/main/java/io/netty/channel/ChannelHandlerMask.java
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright 2019 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 io.netty.util.concurrent.FastThreadLocal;
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
final class ChannelHandlerMask {
|
||||
|
||||
// Using to mask which methods must be called for a ChannelHandler.
|
||||
static final int MASK_EXCEPTION_CAUGHT = 1;
|
||||
static final int MASK_CHANNEL_REGISTERED = 1 << 1;
|
||||
static final int MASK_CHANNEL_UNREGISTERED = 1 << 2;
|
||||
static final int MASK_CHANNEL_ACTIVE = 1 << 3;
|
||||
static final int MASK_CHANNEL_INACTIVE = 1 << 4;
|
||||
static final int MASK_CHANNEL_READ = 1 << 5;
|
||||
static final int MASK_CHANNEL_READ_COMPLETE = 1 << 6;
|
||||
static final int MASK_USER_EVENT_TRIGGERED = 1 << 7;
|
||||
static final int MASK_CHANNEL_WRITABILITY_CHANGED = 1 << 8;
|
||||
static final int MASK_BIND = 1 << 9;
|
||||
static final int MASK_CONNECT = 1 << 10;
|
||||
static final int MASK_DISCONNECT = 1 << 11;
|
||||
static final int MASK_CLOSE = 1 << 12;
|
||||
static final int MASK_REGISTER = 1 << 13;
|
||||
static final int MASK_DEREGISTER = 1 << 14;
|
||||
static final int MASK_READ = 1 << 15;
|
||||
static final int MASK_WRITE = 1 << 16;
|
||||
static final int MASK_FLUSH = 1 << 17;
|
||||
|
||||
private static final int MASK_ALL_INBOUND = MASK_EXCEPTION_CAUGHT | MASK_CHANNEL_REGISTERED |
|
||||
MASK_CHANNEL_UNREGISTERED | MASK_CHANNEL_ACTIVE | MASK_CHANNEL_INACTIVE | MASK_CHANNEL_READ |
|
||||
MASK_CHANNEL_READ_COMPLETE | MASK_USER_EVENT_TRIGGERED | MASK_CHANNEL_WRITABILITY_CHANGED;
|
||||
private static final int MASK_ALL_OUTBOUND = MASK_BIND | MASK_CONNECT | MASK_DISCONNECT |
|
||||
MASK_CLOSE | MASK_REGISTER | MASK_DEREGISTER | MASK_READ | MASK_WRITE | MASK_FLUSH;
|
||||
|
||||
private static final FastThreadLocal<Map<Class<? extends ChannelHandler>, Integer>> MASKS =
|
||||
new FastThreadLocal<Map<Class<? extends ChannelHandler>, Integer>>() {
|
||||
@Override
|
||||
protected Map<Class<? extends ChannelHandler>, Integer> initialValue() {
|
||||
return new WeakHashMap<>(32);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the {@code executionMask}.
|
||||
*/
|
||||
static int mask(Class<? extends ChannelHandler> clazz) {
|
||||
// Try to obtain the mask from the cache first. If this fails calculate it and put it in the cache for fast
|
||||
// lookup in the future.
|
||||
Map<Class<? extends ChannelHandler>, Integer> cache = MASKS.get();
|
||||
Integer mask = cache.get(clazz);
|
||||
if (mask == null) {
|
||||
mask = mask0(clazz);
|
||||
cache.put(clazz, mask);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
static boolean isInbound(Class<? extends ChannelHandler> clazz) {
|
||||
return (mask(clazz) & MASK_ALL_INBOUND) != 0;
|
||||
}
|
||||
|
||||
static boolean isOutbound(Class<? extends ChannelHandler> clazz) {
|
||||
return (mask(clazz) & MASK_ALL_OUTBOUND) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the {@code executionMask}.
|
||||
*/
|
||||
private static int mask0(Class<? extends ChannelHandler> handlerType) {
|
||||
int mask = 0;
|
||||
mask |= MASK_ALL_INBOUND;
|
||||
mask |= MASK_ALL_OUTBOUND;
|
||||
|
||||
try {
|
||||
if (isSkippable(handlerType, "exceptionCaught", ChannelHandlerContext.class, Throwable.class)) {
|
||||
mask &= ~MASK_EXCEPTION_CAUGHT;
|
||||
}
|
||||
|
||||
if (isSkippable(handlerType, "channelRegistered", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_CHANNEL_REGISTERED;
|
||||
}
|
||||
if (isSkippable(handlerType, "channelUnregistered", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_CHANNEL_UNREGISTERED;
|
||||
}
|
||||
if (isSkippable(handlerType, "channelActive", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_CHANNEL_ACTIVE;
|
||||
}
|
||||
if (isSkippable(handlerType, "channelInactive", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_CHANNEL_INACTIVE;
|
||||
}
|
||||
if (isSkippable(handlerType, "channelRead", ChannelHandlerContext.class, Object.class)) {
|
||||
mask &= ~MASK_CHANNEL_READ;
|
||||
}
|
||||
if (isSkippable(handlerType, "channelReadComplete", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_CHANNEL_READ_COMPLETE;
|
||||
}
|
||||
if (isSkippable(handlerType, "channelWritabilityChanged", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_CHANNEL_WRITABILITY_CHANGED;
|
||||
}
|
||||
if (isSkippable(handlerType, "userEventTriggered", ChannelHandlerContext.class, Object.class)) {
|
||||
mask &= ~MASK_USER_EVENT_TRIGGERED;
|
||||
}
|
||||
if (isSkippable(handlerType, "bind", ChannelHandlerContext.class,
|
||||
SocketAddress.class, ChannelPromise.class)) {
|
||||
mask &= ~MASK_BIND;
|
||||
}
|
||||
if (isSkippable(handlerType, "connect", ChannelHandlerContext.class, SocketAddress.class,
|
||||
SocketAddress.class, ChannelPromise.class)) {
|
||||
mask &= ~MASK_CONNECT;
|
||||
}
|
||||
if (isSkippable(handlerType, "disconnect", ChannelHandlerContext.class, ChannelPromise.class)) {
|
||||
mask &= ~MASK_DISCONNECT;
|
||||
}
|
||||
if (isSkippable(handlerType, "close", ChannelHandlerContext.class, ChannelPromise.class)) {
|
||||
mask &= ~MASK_CLOSE;
|
||||
}
|
||||
if (isSkippable(handlerType, "register", ChannelHandlerContext.class, ChannelPromise.class)) {
|
||||
mask &= ~MASK_REGISTER;
|
||||
}
|
||||
if (isSkippable(handlerType, "deregister", ChannelHandlerContext.class, ChannelPromise.class)) {
|
||||
mask &= ~MASK_DEREGISTER;
|
||||
}
|
||||
if (isSkippable(handlerType, "read", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_READ;
|
||||
}
|
||||
if (isSkippable(handlerType, "write", ChannelHandlerContext.class,
|
||||
Object.class, ChannelPromise.class)) {
|
||||
mask &= ~MASK_WRITE;
|
||||
}
|
||||
if (isSkippable(handlerType, "flush", ChannelHandlerContext.class)) {
|
||||
mask &= ~MASK_FLUSH;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Should never reach here.
|
||||
PlatformDependent.throwException(e);
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static boolean isSkippable(
|
||||
final Class<?> handlerType, final String methodName, final Class<?>... paramTypes) throws Exception {
|
||||
|
||||
return AccessController.doPrivileged((PrivilegedExceptionAction<Boolean>) () ->
|
||||
handlerType.getMethod(methodName, paramTypes).isAnnotationPresent(ChannelHandler.Skip.class));
|
||||
}
|
||||
|
||||
private ChannelHandlerMask() { }
|
||||
}
|
@ -18,83 +18,9 @@ package io.netty.channel;
|
||||
/**
|
||||
* {@link ChannelHandler} which adds callbacks for state changes. This allows the user
|
||||
* to hook in to state changes easily.
|
||||
*
|
||||
* @deprecated use {@link ChannelHandler}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ChannelInboundHandler extends ChannelHandler {
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link EventLoop}
|
||||
*/
|
||||
@Skip
|
||||
default void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelRegistered();
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} was unregistered from its {@link EventLoop}
|
||||
*/
|
||||
@Skip
|
||||
default void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelUnregistered();
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} is now active
|
||||
*/
|
||||
@Skip
|
||||
default void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Channel} of the {@link ChannelHandlerContext} was registered is now inactive and reached its
|
||||
* end of lifetime.
|
||||
*/
|
||||
@Skip
|
||||
default void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the current {@link Channel} has read a message from the peer.
|
||||
*/
|
||||
@Skip
|
||||
default void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Skip
|
||||
default void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelReadComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called if an user event was triggered.
|
||||
*/
|
||||
@Skip
|
||||
default void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
ctx.fireUserEventTriggered(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called once the writable state of a {@link Channel} changed. You can check the state with
|
||||
* {@link Channel#isWritable()}.
|
||||
*/
|
||||
@Skip
|
||||
default void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelWritabilityChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called if a {@link Throwable} was thrown.
|
||||
*/
|
||||
@Skip
|
||||
default void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
ctx.fireExceptionCaught(cause);
|
||||
}
|
||||
}
|
||||
|
@ -15,121 +15,11 @@
|
||||
*/
|
||||
package io.netty.channel;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
/**
|
||||
* {@link ChannelHandler} which will get notified for IO-outbound-operations.
|
||||
*
|
||||
* @deprecated use {@link ChannelHandler}
|
||||
*/
|
||||
@Deprecated
|
||||
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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
|
||||
ctx.bind(localAddress, promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void connect(
|
||||
ChannelHandlerContext ctx, SocketAddress remoteAddress,
|
||||
SocketAddress localAddress, ChannelPromise promise) throws Exception {
|
||||
ctx.connect(remoteAddress, localAddress, promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.disconnect(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.close(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once a register operation is made to register for IO on the {@link EventLoop}.
|
||||
*
|
||||
* @param ctx the {@link ChannelHandlerContext} for which the register operation is made
|
||||
* @param promise the {@link ChannelPromise} to notify once the operation completes
|
||||
* @throws Exception thrown if an error occurs
|
||||
*/
|
||||
@Skip
|
||||
default void register(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.register(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once a deregister operation is made from the current registered {@link EventLoop}.
|
||||
*
|
||||
* @param ctx the {@link ChannelHandlerContext} for which the deregister operation is made
|
||||
* @param promise the {@link ChannelPromise} to notify once the operation completes
|
||||
* @throws Exception thrown if an error occurs
|
||||
*/
|
||||
@Skip
|
||||
default void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.deregister(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercepts {@link ChannelHandlerContext#read()}.
|
||||
*/
|
||||
@Skip
|
||||
default void read(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.read();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
ctx.write(msg, promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 occurs
|
||||
*/
|
||||
@Skip
|
||||
default void flush(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public interface ChannelOutboundInvoker {
|
||||
* completes, either because the operation was successful or because of an error.
|
||||
* <p>
|
||||
* 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 @@ public interface ChannelOutboundInvoker {
|
||||
* will be used.
|
||||
* <p>
|
||||
* 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 @@ public interface ChannelOutboundInvoker {
|
||||
* an error.
|
||||
* <p>
|
||||
* 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 @@ public interface ChannelOutboundInvoker {
|
||||
* either because the operation was successful or because of an error.
|
||||
* <p>
|
||||
* 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 @@ public interface ChannelOutboundInvoker {
|
||||
* After it is closed it is not possible to reuse it again.
|
||||
* <p>
|
||||
* 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();
|
||||
@ -92,8 +92,8 @@ public interface ChannelOutboundInvoker {
|
||||
* an error.
|
||||
* <p>
|
||||
* This will result in having the
|
||||
* {@link ChannelOutboundHandler#register(ChannelHandlerContext, ChannelPromise)}
|
||||
* method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link ChannelHandler#register(ChannelHandlerContext, ChannelPromise)}
|
||||
* method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link Channel}.
|
||||
*
|
||||
*/
|
||||
@ -105,8 +105,8 @@ public interface ChannelOutboundInvoker {
|
||||
* an error.
|
||||
* <p>
|
||||
* This will result in having the
|
||||
* {@link ChannelOutboundHandler#deregister(ChannelHandlerContext, ChannelPromise)}
|
||||
* method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link ChannelHandler#deregister(ChannelHandlerContext, ChannelPromise)}
|
||||
* method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link Channel}.
|
||||
*
|
||||
*/
|
||||
@ -119,8 +119,8 @@ public interface ChannelOutboundInvoker {
|
||||
* The given {@link ChannelPromise} will be notified.
|
||||
* <p>
|
||||
* 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);
|
||||
@ -137,8 +137,8 @@ public interface ChannelOutboundInvoker {
|
||||
* will be used.
|
||||
* <p>
|
||||
* 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);
|
||||
@ -151,8 +151,8 @@ public interface ChannelOutboundInvoker {
|
||||
* The given {@link ChannelPromise} will be notified and also returned.
|
||||
* <p>
|
||||
* 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);
|
||||
@ -164,8 +164,8 @@ public interface ChannelOutboundInvoker {
|
||||
* The given {@link ChannelPromise} will be notified.
|
||||
* <p>
|
||||
* 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);
|
||||
@ -207,22 +207,22 @@ public interface ChannelOutboundInvoker {
|
||||
* The given {@link ChannelPromise} will be notified.
|
||||
* <p>
|
||||
* This will result in having the
|
||||
* {@link ChannelOutboundHandler#deregister(ChannelHandlerContext, ChannelPromise)}
|
||||
* method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link ChannelHandler#deregister(ChannelHandlerContext, ChannelPromise)}
|
||||
* method called of the next {@link ChannelHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link Channel}.
|
||||
*/
|
||||
ChannelFuture deregister(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.
|
||||
* <p>
|
||||
* 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}.
|
||||
*/
|
||||
ChannelOutboundInvoker read();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user