Overhaul - Split ChannelHandler & Merge ChannelHandlerContext

- Extracted some handler methods from ChannelInboundHandler into
  ChannelStateHandler
- Extracted some handler methods from ChannelOutboundHandler into
  ChannelOperationHandler
- Moved exceptionCaught and userEventTriggered are now in
  ChannelHandler
  
- Channel(Inbound|Outbound)HandlerContext is merged into
  ChannelHandlerContext
- ChannelHandlerContext adds direct access methods for inboud and
  outbound buffers
  - The use of ChannelBufferHolder is minimal now.
    - Before: inbound().byteBuffer()
    - After: inboundByteBuffer()
    - Simpler and better performance
    
- Bypass buffer types were removed because it just does not work at all
  with the thread model.
  - All handlers that uses a bypass buffer are broken.  Will fix soon.

- CombinedHandlerAdapter does not make sense anymore either because
  there are four handler interfaces to consider and often the two
  handlers will implement the same handler interface such as
  ChannelStateHandler.  Thinking of better ways to provide this feature
This commit is contained in:
Trustin Lee 2012-06-07 14:52:33 +09:00
parent 3def2e6598
commit 5e93d206ff
146 changed files with 853 additions and 1246 deletions

View File

@ -19,7 +19,7 @@ import static io.netty.handler.codec.http.HttpHeaders.*;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.TooLongFrameException;
@ -77,7 +77,7 @@ public class HttpChunkAggregator extends MessageToMessageDecoder<Object, HttpMes
}
@Override
public HttpMessage decode(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public HttpMessage decode(ChannelHandlerContext ctx, Object msg) throws Exception {
HttpMessage currentMessage = this.currentMessage;
if (msg instanceof HttpMessage) {

View File

@ -17,9 +17,7 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.CombinedChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.PrematureChannelClosureException;
import io.netty.util.internal.QueueFactory;
@ -84,7 +82,7 @@ public class HttpClientCodec extends CombinedChannelHandler {
private final class Encoder extends HttpRequestEncoder {
@Override
public void encode(
ChannelOutboundHandlerContext<Object> ctx, Object msg, ChannelBuffer out) throws Exception {
ChannelHandlerContext ctx, Object msg, ChannelBuffer out) throws Exception {
if (msg instanceof HttpRequest && !done) {
queue.offer(((HttpRequest) msg).getMethod());
}
@ -111,7 +109,7 @@ public class HttpClientCodec extends CombinedChannelHandler {
@Override
public Object decode(
ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws Exception {
ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
if (done) {
return buffer.readBytes(actualReadableBytes());
} else {
@ -193,7 +191,7 @@ public class HttpClientCodec extends CombinedChannelHandler {
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx)
public void channelInactive(ChannelHandlerContext ctx)
throws Exception {
super.channelInactive(ctx);

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.embedder.DecoderEmbedder;
@ -56,7 +56,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<Object,
}
@Override
public Object decode(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public Object decode(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().getCode() == 100) {
// 100-continue response must be passed through.
return msg;

View File

@ -17,8 +17,7 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageCodec;
import io.netty.handler.codec.embedder.EncoderEmbedder;
import io.netty.util.internal.QueueFactory;
@ -64,7 +63,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
}
@Override
public HttpMessage decode(ChannelInboundHandlerContext<HttpMessage> ctx, HttpMessage msg)
public HttpMessage decode(ChannelHandlerContext ctx, HttpMessage msg)
throws Exception {
String acceptedEncoding = msg.getHeader(HttpHeaders.Names.ACCEPT_ENCODING);
if (acceptedEncoding == null) {
@ -81,7 +80,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
}
@Override
public Object encode(ChannelOutboundHandlerContext<Object> ctx, Object msg)
public Object encode(ChannelHandlerContext ctx, Object msg)
throws Exception {
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().getCode() == 100) {
// 100-continue response must be passed through.

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.ReplayingDecoder;
import io.netty.handler.codec.TooLongFrameException;
@ -166,7 +166,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<Object, HttpMe
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
switch (state()) {
case SKIP_CONTROL_CHARS: {
try {

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
import static io.netty.buffer.ChannelBuffers.*;
import static io.netty.handler.codec.http.HttpConstants.*;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import io.netty.handler.codec.UnsupportedMessageTypeException;
import io.netty.handler.codec.http.HttpHeaders.Names;
@ -61,7 +61,7 @@ public abstract class HttpMessageEncoder extends MessageToStreamEncoder<Object>
}
@Override
public void encode(ChannelOutboundHandlerContext<Object> ctx, Object msg, ChannelBuffer out) throws Exception {
public void encode(ChannelHandlerContext ctx, Object msg, ChannelBuffer out) throws Exception {
if (msg instanceof HttpMessage) {
HttpMessage m = (HttpMessage) msg;
boolean chunked;

View File

@ -15,7 +15,6 @@
*/
package io.netty.handler.codec.http;
import io.netty.channel.CombinedChannelHandler;
/**
* A combination of {@link HttpRequestDecoder} and {@link HttpResponseEncoder}

View File

@ -16,7 +16,7 @@
package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.util.VoidEnum;
@ -53,7 +53,7 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder<WebSocketFrame, Vo
}
@Override
public WebSocketFrame decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public WebSocketFrame decode(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
// Discard all data received if closing handshake was received before.
if (receivedClosingHandshake) {
in.skipBytes(actualReadableBytes());

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
/**
@ -39,7 +39,7 @@ public class WebSocket00FrameEncoder extends MessageToStreamEncoder<WebSocketFra
@Override
public void encode(
ChannelOutboundHandlerContext<WebSocketFrame> ctx,
ChannelHandlerContext ctx,
WebSocketFrame msg, ChannelBuffer out) throws Exception {
if (msg instanceof TextWebSocketFrame) {
// Text frame

View File

@ -56,7 +56,7 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.ReplayingDecoder;
import io.netty.handler.codec.TooLongFrameException;
@ -119,7 +119,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocketFrame, We
@Override
public WebSocketFrame decode(
ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
// Discard all data received if closing handshake was received before.
if (receivedClosingHandshake) {
@ -366,7 +366,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocketFrame, We
}
}
private void protocolViolation(ChannelInboundHandlerContext<Byte> ctx, String reason) throws CorruptedFrameException {
private void protocolViolation(ChannelHandlerContext ctx, String reason) throws CorruptedFrameException {
checkpoint(State.CORRUPT);
if (ctx.channel().isActive()) {
ctx.flush().addListener(ChannelFutureListener.CLOSE);
@ -382,7 +382,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocketFrame, We
}
}
private void checkUTF8String(ChannelInboundHandlerContext<Byte> ctx, byte[] bytes) throws CorruptedFrameException {
private void checkUTF8String(ChannelHandlerContext ctx, byte[] bytes) throws CorruptedFrameException {
try {
// StringBuilder sb = new StringBuilder("UTF8 " + bytes.length +
// " bytes: ");
@ -401,7 +401,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocketFrame, We
}
}
protected void checkCloseFrameBody(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws CorruptedFrameException {
protected void checkCloseFrameBody(ChannelHandlerContext ctx, ChannelBuffer buffer) throws CorruptedFrameException {
if (buffer == null || buffer.capacity() == 0) {
return;
}

View File

@ -55,7 +55,7 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.logging.InternalLogger;
@ -99,7 +99,7 @@ public class WebSocket08FrameEncoder extends MessageToStreamEncoder<WebSocketFra
}
@Override
public void encode(ChannelOutboundHandlerContext<WebSocketFrame> ctx,
public void encode(ChannelHandlerContext ctx,
WebSocketFrame msg, ChannelBuffer out) throws Exception {
byte[] mask;

View File

@ -16,7 +16,7 @@
package io.netty.handler.codec.rtsp;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.handler.codec.embedder.DecoderEmbedder;
import io.netty.handler.codec.http.HttpChunkAggregator;
@ -75,7 +75,7 @@ public abstract class RtspMessageDecoder extends HttpMessageDecoder {
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
Object o = super.decode(ctx, buffer);
if (o != null && aggregator.offer(o)) {
return aggregator.poll();

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.rtsp;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.UnsupportedMessageTypeException;
import io.netty.handler.codec.http.HttpMessage;
import io.netty.handler.codec.http.HttpMessageEncoder;
@ -39,7 +39,7 @@ public abstract class RtspMessageEncoder extends HttpMessageEncoder {
}
@Override
public void encode(ChannelOutboundHandlerContext<Object> ctx, Object msg,
public void encode(ChannelHandlerContext ctx, Object msg,
ChannelBuffer out) throws Exception {
// Ignore unrelated message types such as HttpChunk.
if (!(msg instanceof HttpMessage)) {

View File

@ -15,7 +15,6 @@
*/
package io.netty.handler.codec.spdy;
import io.netty.channel.CombinedChannelHandler;
/**
* A combination of {@link SpdyFrameDecoder} and {@link SpdyFrameEncoder}.

View File

@ -19,7 +19,6 @@ import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.handler.codec.StreamToMessageDecoder;
import io.netty.handler.codec.TooLongFrameException;
@ -102,7 +101,7 @@ public class SpdyFrameDecoder extends StreamToMessageDecoder<Object> {
}
@Override
public Object decodeLast(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public Object decodeLast(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
try {
return decode(ctx, in);
} finally {
@ -111,7 +110,7 @@ public class SpdyFrameDecoder extends StreamToMessageDecoder<Object> {
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
switch(state) {
case READ_COMMON_HEADER:
state = readCommonHeader(buffer);

View File

@ -21,7 +21,6 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import io.netty.handler.codec.UnsupportedMessageTypeException;
@ -92,7 +91,7 @@ public class SpdyFrameEncoder extends MessageToStreamEncoder<Object> {
}
@Override
public void encode(ChannelOutboundHandlerContext<Object> ctx, Object msg, ChannelBuffer out) throws Exception {
public void encode(ChannelHandlerContext ctx, Object msg, ChannelBuffer out) throws Exception {
if (msg instanceof SpdyDataFrame) {
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;

View File

@ -15,7 +15,6 @@
*/
package io.netty.handler.codec.spdy;
import io.netty.channel.CombinedChannelHandler;
/**
* A combination of {@link SpdyHttpDecoder} and {@link SpdyHttpEncoder}

View File

@ -15,10 +15,9 @@
*/
package io.netty.handler.codec.spdy;
import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.handler.codec.http.DefaultHttpRequest;
@ -67,7 +66,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder<Object, HttpMessage
}
@Override
public HttpMessage decode(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public HttpMessage decode(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof SpdySynStreamFrame) {
// HTTP requests/responses are mapped one-to-one to SPDY streams.

View File

@ -15,8 +15,7 @@
*/
package io.netty.handler.codec.spdy;
import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import io.netty.handler.codec.UnsupportedMessageTypeException;
import io.netty.handler.codec.http.HttpChunk;
@ -145,7 +144,7 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<Object, Object> {
}
@Override
public Object encode(ChannelOutboundHandlerContext<Object> ctx, Object msg) throws Exception {
public Object encode(ChannelHandlerContext ctx, Object msg) throws Exception {
List<Object> out = new ArrayList<Object>();
if (msg instanceof HttpRequest) {

View File

@ -15,15 +15,12 @@
*/
package io.netty.handler.codec.spdy;
import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import java.nio.channels.ClosedChannelException;
import java.util.Queue;
@ -87,19 +84,19 @@ public class SpdySessionHandler extends ChannelHandlerAdapter<Object, Object> {
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public ChannelBufferHolder<Object> newOutboundBuffer(
ChannelOutboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Object> ctx) throws Exception {
Queue<Object> in = ctx.inbound().messageBuffer();
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
Queue<Object> in = ctx.inboundMessageBuffer();
for (;;) {
Object msg = in.poll();
if (msg == null) {
@ -422,7 +419,7 @@ public class SpdySessionHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof SpdyProtocolException) {
issueSessionError(ctx, SpdySessionStatus.PROTOCOL_ERROR);
}
@ -432,20 +429,20 @@ public class SpdySessionHandler extends ChannelHandlerAdapter<Object, Object> {
@Override
public void close(ChannelOutboundHandlerContext<Object> ctx, ChannelFuture future) throws Exception {
public void close(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
sendGoAwayFrame(ctx);
super.close(ctx, future);
}
@Override
public void disconnect(ChannelOutboundHandlerContext<Object> ctx, ChannelFuture future) throws Exception {
public void disconnect(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
sendGoAwayFrame(ctx);
super.close(ctx, future);
}
@Override
public void flush(ChannelOutboundHandlerContext<Object> ctx, ChannelFuture future) throws Exception {
Queue<Object> in = ctx.outbound().messageBuffer();
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
Queue<Object> in = ctx.outboundMessageBuffer();
for (;;) {
Object msg = in.poll();
if (msg == null) {

View File

@ -15,8 +15,7 @@
*/
package io.netty.handler.codec.spdy;
import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.embedder.DecoderEmbedder;
import io.netty.logging.InternalLogger;
@ -283,7 +282,7 @@ public class SpdySessionHandlerTest {
}
@Override
public void channelActive(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// Initiate 4 new streams
int streamID = server ? 2 : 1;
SpdySynStreamFrame spdySynStreamFrame =
@ -304,7 +303,7 @@ public class SpdySessionHandlerTest {
}
@Override
public void messageReceived(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof SpdyDataFrame ||
msg instanceof SpdyPingFrame ||
msg instanceof SpdyHeadersFrame) {

View File

@ -17,7 +17,6 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
/**
* A decoder that splits the received {@link ChannelBuffer}s by one or more
@ -187,7 +186,7 @@ public class DelimiterBasedFrameDecoder extends StreamToMessageDecoder<Object> {
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
// Try all delimiters and choose the delimiter which yields the shortest frame.
int minFrameLength = Integer.MAX_VALUE;
ChannelBuffer minDelim = null;

View File

@ -19,7 +19,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
/**
* A decoder that splits the received {@link ChannelBuffer}s by the fixed number
@ -66,7 +66,7 @@ public class FixedLengthFrameDecoder extends StreamToMessageDecoder<Object> {
@Override
public ChannelBufferHolder<Byte> newInboundBuffer(
ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
if (allocateFullBuffer) {
return ChannelBufferHolders.byteBuffer(ChannelBuffers.dynamicBuffer(frameLength));
} else {
@ -75,7 +75,7 @@ public class FixedLengthFrameDecoder extends StreamToMessageDecoder<Object> {
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
if (in.readableBytes() < frameLength) {
return null;
} else {

View File

@ -18,7 +18,6 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferFactory;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.handler.codec.serialization.ObjectDecoder;
/**
@ -308,7 +307,7 @@ public class LengthFieldBasedFrameDecoder extends StreamToMessageDecoder<Object>
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
if (discardingTooLongFrame) {
long bytesToDiscard = this.bytesToDiscard;
int localBytesToDiscard = (int) Math.min(bytesToDiscard, in.readableBytes());

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferFactory;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import java.nio.ByteOrder;
@ -103,7 +103,7 @@ public class LengthFieldPrepender extends MessageToStreamEncoder<ChannelBuffer>
@Override
public void encode(
ChannelOutboundHandlerContext<ChannelBuffer> ctx,
ChannelHandlerContext ctx,
ChannelBuffer msg, ChannelBuffer out) throws Exception {
int length = lengthIncludesLengthFieldLength?

View File

@ -18,8 +18,7 @@ package io.netty.handler.codec;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
public abstract class MessageToMessageCodec<INBOUND_IN, INBOUND_OUT, OUTBOUND_IN, OUTBOUND_OUT>
extends ChannelHandlerAdapter<INBOUND_IN, OUTBOUND_IN> {
@ -32,7 +31,7 @@ public abstract class MessageToMessageCodec<INBOUND_IN, INBOUND_OUT, OUTBOUND_IN
}
@Override
public OUTBOUND_OUT encode(ChannelOutboundHandlerContext<OUTBOUND_IN> ctx, OUTBOUND_IN msg) throws Exception {
public OUTBOUND_OUT encode(ChannelHandlerContext ctx, OUTBOUND_IN msg) throws Exception {
return MessageToMessageCodec.this.encode(ctx, msg);
}
};
@ -45,29 +44,29 @@ public abstract class MessageToMessageCodec<INBOUND_IN, INBOUND_OUT, OUTBOUND_IN
}
@Override
public INBOUND_OUT decode(ChannelInboundHandlerContext<INBOUND_IN> ctx, INBOUND_IN msg) throws Exception {
public INBOUND_OUT decode(ChannelHandlerContext ctx, INBOUND_IN msg) throws Exception {
return MessageToMessageCodec.this.decode(ctx, msg);
}
};
@Override
public ChannelBufferHolder<INBOUND_IN> newInboundBuffer(ChannelInboundHandlerContext<INBOUND_IN> ctx) throws Exception {
public ChannelBufferHolder<INBOUND_IN> newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
return decoder.newInboundBuffer(ctx);
}
@Override
public void inboundBufferUpdated(
ChannelInboundHandlerContext<INBOUND_IN> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
decoder.inboundBufferUpdated(ctx);
}
@Override
public ChannelBufferHolder<OUTBOUND_IN> newOutboundBuffer(ChannelOutboundHandlerContext<OUTBOUND_IN> ctx) throws Exception {
public ChannelBufferHolder<OUTBOUND_IN> newOutboundBuffer(ChannelHandlerContext ctx) throws Exception {
return encoder.newOutboundBuffer(ctx);
}
@Override
public void flush(ChannelOutboundHandlerContext<OUTBOUND_IN> ctx, ChannelFuture future) throws Exception {
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
encoder.flush(ctx, future);
}
@ -89,6 +88,6 @@ public abstract class MessageToMessageCodec<INBOUND_IN, INBOUND_OUT, OUTBOUND_IN
return true;
}
public abstract OUTBOUND_OUT encode(ChannelOutboundHandlerContext<OUTBOUND_IN> ctx, OUTBOUND_IN msg) throws Exception;
public abstract INBOUND_OUT decode(ChannelInboundHandlerContext<INBOUND_IN> ctx, INBOUND_IN msg) throws Exception;
public abstract OUTBOUND_OUT encode(ChannelHandlerContext ctx, OUTBOUND_IN msg) throws Exception;
public abstract INBOUND_OUT decode(ChannelHandlerContext ctx, INBOUND_IN msg) throws Exception;
}

View File

@ -17,8 +17,8 @@ package io.netty.handler.codec;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import java.util.Queue;
@ -26,14 +26,14 @@ public abstract class MessageToMessageDecoder<I, O> extends ChannelInboundHandle
@Override
public ChannelBufferHolder<I> newInboundBuffer(
ChannelInboundHandlerContext<I> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<I> ctx)
public void inboundBufferUpdated(ChannelHandlerContext ctx)
throws Exception {
Queue<I> in = ctx.inbound().messageBuffer();
Queue<I> in = ctx.inboundMessageBuffer();
boolean notify = false;
for (;;) {
try {
@ -81,5 +81,5 @@ public abstract class MessageToMessageDecoder<I, O> extends ChannelInboundHandle
return true;
}
public abstract O decode(ChannelInboundHandlerContext<I> ctx, I msg) throws Exception;
public abstract O decode(ChannelHandlerContext ctx, I msg) throws Exception;
}

View File

@ -18,8 +18,8 @@ package io.netty.handler.codec;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerContext;
import java.util.Queue;
@ -27,13 +27,13 @@ public abstract class MessageToMessageEncoder<I, O> extends ChannelOutboundHandl
@Override
public ChannelBufferHolder<I> newOutboundBuffer(
ChannelOutboundHandlerContext<I> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void flush(ChannelOutboundHandlerContext<I> ctx, ChannelFuture future) throws Exception {
Queue<I> in = ctx.outbound().messageBuffer();
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
Queue<I> in = ctx.outboundMessageBuffer();
boolean notify = false;
for (;;) {
try {
@ -83,5 +83,5 @@ public abstract class MessageToMessageEncoder<I, O> extends ChannelOutboundHandl
return true;
}
public abstract O encode(ChannelOutboundHandlerContext<I> ctx, I msg) throws Exception;
public abstract O encode(ChannelHandlerContext ctx, I msg) throws Exception;
}

View File

@ -19,8 +19,8 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerContext;
import java.util.Queue;
@ -28,13 +28,13 @@ public abstract class MessageToStreamEncoder<I> extends ChannelOutboundHandlerAd
@Override
public ChannelBufferHolder<I> newOutboundBuffer(
ChannelOutboundHandlerContext<I> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void flush(ChannelOutboundHandlerContext<I> ctx, ChannelFuture future) throws Exception {
Queue<I> in = ctx.outbound().messageBuffer();
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
Queue<I> in = ctx.outboundMessageBuffer();
ChannelBuffer out = ctx.nextOutboundByteBuffer();
boolean notify = false;
@ -78,5 +78,5 @@ public abstract class MessageToStreamEncoder<I> extends ChannelOutboundHandlerAd
return true;
}
public abstract void encode(ChannelOutboundHandlerContext<I> ctx, I msg, ChannelBuffer out) throws Exception;
public abstract void encode(ChannelHandlerContext ctx, I msg, ChannelBuffer out) throws Exception;
}

View File

@ -21,7 +21,6 @@ import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.util.Signal;
import io.netty.util.VoidEnum;
@ -359,7 +358,7 @@ public abstract class ReplayingDecoder<O, S extends Enum<S>> extends StreamToMes
@Override
public ChannelBufferHolder<Byte> newInboundBuffer(
ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
if (inUse) {
throw new IllegalStateException(
ReplayingDecoder.class.getSimpleName() + " cannot be shared.");
@ -369,7 +368,7 @@ public abstract class ReplayingDecoder<O, S extends Enum<S>> extends StreamToMes
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
replayable.terminate();
ChannelBuffer in = cumulation;
if (in.readable()) {
@ -395,7 +394,7 @@ public abstract class ReplayingDecoder<O, S extends Enum<S>> extends StreamToMes
}
@Override
protected void callDecode(ChannelInboundHandlerContext<Byte> ctx) {
protected void callDecode(ChannelHandlerContext ctx) {
ChannelBuffer in = cumulation;
boolean decoded = false;
while (in.readable()) {
@ -463,7 +462,7 @@ public abstract class ReplayingDecoder<O, S extends Enum<S>> extends StreamToMes
}
}
private void fireInboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) {
private void fireInboundBufferUpdated(ChannelHandlerContext ctx, ChannelBuffer in) {
checkpoint -= in.readerIndex();
in.discardReadBytes();
ctx.fireInboundBufferUpdated();

View File

@ -19,8 +19,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
public abstract class StreamToMessageCodec<INBOUND_OUT, OUTBOUND_IN>
extends ChannelHandlerAdapter<Byte, OUTBOUND_IN> {
@ -29,7 +28,7 @@ public abstract class StreamToMessageCodec<INBOUND_OUT, OUTBOUND_IN>
new MessageToStreamEncoder<OUTBOUND_IN>() {
@Override
public void encode(
ChannelOutboundHandlerContext<OUTBOUND_IN> ctx,
ChannelHandlerContext ctx,
OUTBOUND_IN msg, ChannelBuffer out) throws Exception {
StreamToMessageCodec.this.encode(ctx, msg, out);
}
@ -39,38 +38,38 @@ public abstract class StreamToMessageCodec<INBOUND_OUT, OUTBOUND_IN>
new StreamToMessageDecoder<INBOUND_OUT>() {
@Override
public INBOUND_OUT decode(
ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
return StreamToMessageCodec.this.decode(ctx, in);
}
};
@Override
public ChannelBufferHolder<Byte> newInboundBuffer(
ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return decoder.newInboundBuffer(ctx);
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
decoder.inboundBufferUpdated(ctx);
}
@Override
public ChannelBufferHolder<OUTBOUND_IN> newOutboundBuffer(
ChannelOutboundHandlerContext<OUTBOUND_IN> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return encoder.newOutboundBuffer(ctx);
}
@Override
public void flush(
ChannelOutboundHandlerContext<OUTBOUND_IN> ctx, ChannelFuture future) throws Exception {
ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
encoder.flush(ctx, future);
}
public abstract void encode(
ChannelOutboundHandlerContext<OUTBOUND_IN> ctx,
ChannelHandlerContext ctx,
OUTBOUND_IN msg, ChannelBuffer out) throws Exception;
public abstract INBOUND_OUT decode(
ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception;
ChannelHandlerContext ctx, ChannelBuffer in) throws Exception;
}

View File

@ -18,30 +18,30 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelPipeline;
public abstract class StreamToMessageDecoder<O> extends ChannelInboundHandlerAdapter<Byte> {
private ChannelInboundHandlerContext<Byte> ctx;
private ChannelHandlerContext ctx;
@Override
public ChannelBufferHolder<Byte> newInboundBuffer(
ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
return ChannelBufferHolders.byteBuffer();
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
callDecode(ctx);
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelBuffer in = ctx.inbound().byteBuffer();
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
ChannelBuffer in = ctx.inboundByteBuffer();
if (in.readable()) {
callDecode(ctx);
}
@ -62,8 +62,8 @@ public abstract class StreamToMessageDecoder<O> extends ChannelInboundHandlerAda
ctx.fireChannelInactive();
}
protected void callDecode(ChannelInboundHandlerContext<Byte> ctx) {
ChannelBuffer in = ctx.inbound().byteBuffer();
protected void callDecode(ChannelHandlerContext ctx) {
ChannelBuffer in = ctx.inboundByteBuffer();
boolean decoded = false;
for (;;) {
@ -123,10 +123,10 @@ public abstract class StreamToMessageDecoder<O> extends ChannelInboundHandlerAda
// the new handler.
ctx.pipeline().addAfter(ctx.name(), newHandlerName, newHandler);
ChannelBuffer in = ctx.inbound().byteBuffer();
ChannelBuffer in = ctx.inboundByteBuffer();
try {
if (in.readable()) {
ctx.nextInboundByteBuffer().writeBytes(ctx.inbound().byteBuffer());
ctx.nextInboundByteBuffer().writeBytes(ctx.inboundByteBuffer());
ctx.fireInboundBufferUpdated();
}
} finally {
@ -134,9 +134,9 @@ public abstract class StreamToMessageDecoder<O> extends ChannelInboundHandlerAda
}
}
public abstract O decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception;
public abstract O decode(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception;
public O decodeLast(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public O decodeLast(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
return decode(ctx, in);
}
}

View File

@ -19,15 +19,14 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
public abstract class StreamToStreamCodec extends ChannelHandlerAdapter<Byte, Byte> {
private final StreamToStreamEncoder encoder = new StreamToStreamEncoder() {
@Override
public void encode(
ChannelOutboundHandlerContext<Byte> ctx,
ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception {
StreamToStreamCodec.this.encode(ctx, in, out);
}
@ -36,7 +35,7 @@ public abstract class StreamToStreamCodec extends ChannelHandlerAdapter<Byte, By
private final StreamToStreamDecoder decoder = new StreamToStreamDecoder() {
@Override
public void decode(
ChannelInboundHandlerContext<Byte> ctx,
ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception {
StreamToStreamCodec.this.decode(ctx, in, out);
}
@ -44,32 +43,32 @@ public abstract class StreamToStreamCodec extends ChannelHandlerAdapter<Byte, By
@Override
public ChannelBufferHolder<Byte> newInboundBuffer(
ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return decoder.newInboundBuffer(ctx);
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
decoder.inboundBufferUpdated(ctx);
}
@Override
public ChannelBufferHolder<Byte> newOutboundBuffer(
ChannelOutboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return encoder.newOutboundBuffer(ctx);
}
@Override
public void flush(
ChannelOutboundHandlerContext<Byte> ctx, ChannelFuture future) throws Exception {
ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
encoder.flush(ctx, future);
}
public abstract void encode(
ChannelOutboundHandlerContext<Byte> ctx,
ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception;
public abstract void decode(
ChannelInboundHandlerContext<Byte> ctx,
ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception;
}

View File

@ -18,25 +18,25 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
public abstract class StreamToStreamDecoder extends ChannelInboundHandlerAdapter<Byte> {
@Override
public ChannelBufferHolder<Byte> newInboundBuffer(
ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.byteBuffer();
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
callDecode(ctx);
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelBuffer in = ctx.inbound().byteBuffer();
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
ChannelBuffer in = ctx.inboundByteBuffer();
if (!in.readable()) {
callDecode(ctx);
}
@ -61,8 +61,8 @@ public abstract class StreamToStreamDecoder extends ChannelInboundHandlerAdapter
ctx.fireChannelInactive();
}
private void callDecode(ChannelInboundHandlerContext<Byte> ctx) {
ChannelBuffer in = ctx.inbound().byteBuffer();
private void callDecode(ChannelHandlerContext ctx) {
ChannelBuffer in = ctx.inboundByteBuffer();
ChannelBuffer out = ctx.nextInboundByteBuffer();
int oldOutSize = out.readableBytes();
@ -88,9 +88,9 @@ public abstract class StreamToStreamDecoder extends ChannelInboundHandlerAdapter
}
}
public abstract void decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in, ChannelBuffer out) throws Exception;
public abstract void decode(ChannelHandlerContext ctx, ChannelBuffer in, ChannelBuffer out) throws Exception;
public void decodeLast(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in, ChannelBuffer out) throws Exception {
public void decodeLast(ChannelHandlerContext ctx, ChannelBuffer in, ChannelBuffer out) throws Exception {
decode(ctx, in, out);
}
}

View File

@ -19,20 +19,20 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerContext;
public abstract class StreamToStreamEncoder extends ChannelOutboundHandlerAdapter<Byte> {
@Override
public ChannelBufferHolder<Byte> newOutboundBuffer(
ChannelOutboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.byteBuffer();
}
@Override
public void flush(ChannelOutboundHandlerContext<Byte> ctx, ChannelFuture future) throws Exception {
ChannelBuffer in = ctx.outbound().byteBuffer();
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
ChannelBuffer in = ctx.outboundByteBuffer();
ChannelBuffer out = ctx.nextOutboundByteBuffer();
int oldOutSize = out.readableBytes();
@ -58,5 +58,5 @@ public abstract class StreamToStreamEncoder extends ChannelOutboundHandlerAdapte
}
}
public abstract void encode(ChannelOutboundHandlerContext<Byte> ctx, ChannelBuffer in, ChannelBuffer out) throws Exception;
public abstract void encode(ChannelHandlerContext ctx, ChannelBuffer in, ChannelBuffer out) throws Exception;
}

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.base64;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
@ -65,7 +65,7 @@ public class Base64Decoder extends MessageToMessageDecoder<ChannelBuffer, Channe
}
@Override
public ChannelBuffer decode(ChannelInboundHandlerContext<ChannelBuffer> ctx, ChannelBuffer msg) throws Exception {
public ChannelBuffer decode(ChannelHandlerContext ctx, ChannelBuffer msg) throws Exception {
return Base64.decode(msg, msg.readerIndex(), msg.readableBytes(), dialect);
}
}

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.base64;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
@ -68,7 +68,7 @@ public class Base64Encoder extends MessageToMessageEncoder<ChannelBuffer, Channe
}
@Override
public ChannelBuffer encode(ChannelOutboundHandlerContext<ChannelBuffer> ctx,
public ChannelBuffer encode(ChannelHandlerContext ctx,
ChannelBuffer msg) throws Exception {
return Base64.encode(msg, msg.readerIndex(), msg.readableBytes(), breakLines, dialect);
}

View File

@ -17,7 +17,6 @@ package io.netty.handler.codec.bytes;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
@ -56,7 +55,7 @@ public class ByteArrayDecoder extends MessageToMessageDecoder<ChannelBuffer, byt
}
@Override
public byte[] decode(ChannelInboundHandlerContext<ChannelBuffer> ctx, ChannelBuffer msg) throws Exception {
public byte[] decode(ChannelHandlerContext ctx, ChannelBuffer msg) throws Exception {
byte[] array;
if (msg.hasArray()) {
if (msg.arrayOffset() == 0 && msg.readableBytes() == msg.capacity()) {

View File

@ -20,7 +20,6 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
@ -54,7 +53,7 @@ import io.netty.handler.codec.MessageToMessageEncoder;
public class ByteArrayEncoder extends MessageToMessageEncoder<byte[], ChannelBuffer> {
@Override
public ChannelBufferHolder<byte[]> newOutboundBuffer(ChannelOutboundHandlerContext<byte[]> ctx) throws Exception {
public ChannelBufferHolder<byte[]> newOutboundBuffer(ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@ -64,7 +63,7 @@ public class ByteArrayEncoder extends MessageToMessageEncoder<byte[], ChannelBuf
}
@Override
public ChannelBuffer encode(ChannelOutboundHandlerContext<byte[]> ctx, byte[] msg) throws Exception {
public ChannelBuffer encode(ChannelHandlerContext ctx, byte[] msg) throws Exception {
if (msg.length == 0) {
return null;
}

View File

@ -16,7 +16,7 @@
package io.netty.handler.codec.compression;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.StreamToStreamDecoder;
import io.netty.util.internal.jzlib.JZlib;
import io.netty.util.internal.jzlib.ZStream;
@ -88,7 +88,7 @@ public class ZlibDecoder extends StreamToStreamDecoder {
@Override
public void decode(
ChannelInboundHandlerContext<Byte> ctx,
ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception {
if (!in.readable()) {

View File

@ -20,7 +20,6 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.handler.codec.StreamToStreamEncoder;
import io.netty.util.internal.jzlib.JZlib;
import io.netty.util.internal.jzlib.ZStream;
@ -263,7 +262,7 @@ public class ZlibEncoder extends StreamToStreamEncoder {
}
@Override
public void encode(ChannelOutboundHandlerContext<Byte> ctx,
public void encode(ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception {
if (finished.get()) {
return;
@ -336,7 +335,7 @@ public class ZlibEncoder extends StreamToStreamEncoder {
@Override
public void disconnect(
final ChannelOutboundHandlerContext<Byte> ctx,
final ChannelHandlerContext ctx,
final ChannelFuture future) throws Exception {
finishEncode(ctx, ctx.newFuture()).addListener(new ChannelFutureListener() {
@Override
@ -348,7 +347,7 @@ public class ZlibEncoder extends StreamToStreamEncoder {
@Override
public void close(
final ChannelOutboundHandlerContext<Byte> ctx,
final ChannelHandlerContext ctx,
final ChannelFuture future) throws Exception {
finishEncode(ctx, ctx.newFuture()).addListener(new ChannelFutureListener() {
@Override

View File

@ -23,9 +23,7 @@ import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoop;
import io.netty.handler.codec.CodecException;
@ -68,7 +66,7 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
ChannelHandlerContext ctx = p.context(h);
if (inboundType == 0) {
if (ctx.canHandleInbound()) {
ChannelInboundHandlerContext<?> inCtx = (ChannelInboundHandlerContext<?>) ctx;
ChannelHandlerContext inCtx = (ChannelHandlerContext) ctx;
if (inCtx.inbound().hasByteBuffer()) {
inboundType = 1;
} else {
@ -77,7 +75,7 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
}
}
if (ctx.canHandleOutbound()) {
ChannelOutboundHandlerContext<?> outCtx = (ChannelOutboundHandlerContext<?>) ctx;
ChannelHandlerContext outCtx = (ChannelHandlerContext) ctx;
if (outCtx.outbound().hasByteBuffer()) {
outboundType = 1;
} else {
@ -211,17 +209,17 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
private final class LastHandler extends ChannelInboundHandlerAdapter<Object> {
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer(productQueue);
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
// NOOP
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
productQueue.add(cause);
}
}
@ -233,13 +231,13 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
@Override
public ChannelBufferHolder<Byte> newOutboundBuffer(
ChannelOutboundHandlerContext<Byte> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.byteBuffer();
}
@Override
public void flush(ChannelOutboundHandlerContext<Byte> ctx, ChannelFuture future) throws Exception {
ChannelBuffer in = ctx.outbound().byteBuffer();
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
ChannelBuffer in = ctx.outboundByteBuffer();
if (in.readable()) {
ctx.nextOutboundMessageBuffer().add(in.readBytes(in.readableBytes()));
}
@ -254,13 +252,13 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Object> ctx) throws Exception {
Queue<Object> in = ctx.inbound().messageBuffer();
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
Queue<Object> in = ctx.inboundMessageBuffer();
for (;;) {
Object msg = in.poll();
if (msg == null) {
@ -284,13 +282,13 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
@Override
public ChannelBufferHolder<Object> newOutboundBuffer(
ChannelOutboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void flush(ChannelOutboundHandlerContext<Object> ctx, ChannelFuture future) throws Exception {
Queue<Object> in = ctx.outbound().messageBuffer();
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
Queue<Object> in = ctx.outboundMessageBuffer();
for (;;) {
Object msg = in.poll();
if (msg == null) {

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.marshalling;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.util.VoidEnum;
@ -52,7 +52,7 @@ public class CompatibleMarshallingDecoder extends ReplayingDecoder<Object, VoidE
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
Unmarshaller unmarshaller = provider.getUnmarshaller(ctx);
ByteInput input = new ChannelBufferByteInput(buffer);
if (maxObjectSize != Integer.MAX_VALUE) {
@ -73,7 +73,7 @@ public class CompatibleMarshallingDecoder extends ReplayingDecoder<Object, VoidE
}
@Override
public Object decodeLast(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer buffer) throws Exception {
public Object decodeLast(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
switch (buffer.readableBytes()) {
case 0:
return null;
@ -90,7 +90,7 @@ public class CompatibleMarshallingDecoder extends ReplayingDecoder<Object, VoidE
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof TooLongFrameException) {
ctx.close();
} else {

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.marshalling;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import org.jboss.marshalling.Marshaller;
@ -50,7 +50,7 @@ public class CompatibleMarshallingEncoder extends MessageToStreamEncoder<Object>
@Override
public void encode(ChannelOutboundHandlerContext<Object> ctx, Object msg, ChannelBuffer out) throws Exception {
public void encode(ChannelHandlerContext ctx, Object msg, ChannelBuffer out) throws Exception {
Marshaller marshaller = provider.getMarshaller(ctx);
marshaller.start(new ChannelBufferByteOutput(out));
marshaller.writeObject(msg);

View File

@ -16,7 +16,7 @@
package io.netty.handler.codec.marshalling;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.TooLongFrameException;
@ -60,7 +60,7 @@ public class MarshallingDecoder extends LengthFieldBasedFrameDecoder {
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
ChannelBuffer frame = (ChannelBuffer) super.decode(ctx, in);
if (frame == null) {
return null;

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.marshalling;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import org.jboss.marshalling.Marshaller;
@ -50,7 +50,7 @@ public class MarshallingEncoder extends MessageToStreamEncoder<Object> {
}
@Override
public void encode(ChannelOutboundHandlerContext<Object> ctx, Object msg, ChannelBuffer out) throws Exception {
public void encode(ChannelHandlerContext ctx, Object msg, ChannelBuffer out) throws Exception {
Marshaller marshaller = provider.getMarshaller(ctx);
int lengthPos = out.writerIndex();
out.writeBytes(LENGTH_PLACEHOLDER);

View File

@ -19,7 +19,6 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferInputStream;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
@ -88,7 +87,7 @@ public class ProtobufDecoder extends MessageToMessageDecoder<ChannelBuffer, Mess
}
@Override
public MessageLite decode(ChannelInboundHandlerContext<ChannelBuffer> ctx, ChannelBuffer msg) throws Exception {
public MessageLite decode(ChannelHandlerContext ctx, ChannelBuffer msg) throws Exception {
if (msg.hasArray()) {
final int offset = msg.readerIndex();
if (extensionRegistry == null) {

View File

@ -19,7 +19,6 @@ import static io.netty.buffer.ChannelBuffers.*;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
@ -66,7 +65,7 @@ public class ProtobufEncoder extends MessageToMessageEncoder<Object, ChannelBuff
}
@Override
public ChannelBuffer encode(ChannelOutboundHandlerContext<Object> ctx, Object msg) throws Exception {
public ChannelBuffer encode(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof MessageLite) {
return wrappedBuffer(((MessageLite) msg).toByteArray());
}

View File

@ -16,7 +16,7 @@
package io.netty.handler.codec.protobuf;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.StreamToMessageDecoder;
@ -49,7 +49,7 @@ public class ProtobufVarint32FrameDecoder extends StreamToMessageDecoder<Object>
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
in.markReaderIndex();
final byte[] buf = new byte[5];
for (int i = 0; i < buf.length; i ++) {

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.protobuf;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferOutputStream;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import com.google.protobuf.CodedOutputStream;
@ -53,7 +53,7 @@ public class ProtobufVarint32LengthFieldPrepender extends MessageToStreamEncoder
@Override
public void encode(
ChannelOutboundHandlerContext<ChannelBuffer> ctx, ChannelBuffer msg, ChannelBuffer out) throws Exception {
ChannelHandlerContext ctx, ChannelBuffer msg, ChannelBuffer out) throws Exception {
ChannelBuffer body = msg;
int bodyLen = body.readableBytes();
int headerLen = CodedOutputStream.computeRawVarint32Size(bodyLen);

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.serialization;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferOutputStream;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
@ -81,7 +81,7 @@ public class CompatibleObjectEncoder extends MessageToStreamEncoder<Object> {
}
@Override
public void encode(ChannelOutboundHandlerContext<Object> ctx, Object msg, ChannelBuffer out) throws Exception {
public void encode(ChannelHandlerContext ctx, Object msg, ChannelBuffer out) throws Exception {
Attribute<ObjectOutputStream> oosAttr = ctx.attr(OOS);
ObjectOutputStream oos = oosAttr.get();
if (oos == null) {

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.serialization;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferInputStream;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import java.io.ObjectOutputStream;
@ -66,7 +66,7 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
}
@Override
public Object decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public Object decode(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
ChannelBuffer frame = (ChannelBuffer) super.decode(ctx, in);
if (frame == null) {
return null;

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.serialization;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferOutputStream;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import java.io.ObjectInputStream;
@ -45,7 +45,7 @@ public class ObjectEncoder extends MessageToStreamEncoder<Object> {
}
@Override
public void encode(ChannelOutboundHandlerContext<Object> ctx, Object msg, ChannelBuffer out) throws Exception {
public void encode(ChannelHandlerContext ctx, Object msg, ChannelBuffer out) throws Exception {
int startIdx = out.writerIndex();
ChannelBufferOutputStream bout = new ChannelBufferOutputStream(out);

View File

@ -18,7 +18,6 @@ package io.netty.handler.codec.string;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
@ -81,7 +80,7 @@ public class StringDecoder extends MessageToMessageDecoder<ChannelBuffer, String
}
@Override
public String decode(ChannelInboundHandlerContext<ChannelBuffer> ctx, ChannelBuffer msg) throws Exception {
public String decode(ChannelHandlerContext ctx, ChannelBuffer msg) throws Exception {
return msg.toString(charset);
}
}

View File

@ -19,7 +19,6 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
@ -79,7 +78,7 @@ public class StringEncoder extends MessageToMessageEncoder<String, ChannelBuffer
}
@Override
public ChannelBuffer encode(ChannelOutboundHandlerContext<String> ctx, String msg) throws Exception {
public ChannelBuffer encode(ChannelHandlerContext ctx, String msg) throws Exception {
return ChannelBuffers.copiedBuffer(msg, charset);
}
}

View File

@ -19,7 +19,7 @@ import static org.junit.Assert.*;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferIndexFinder;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.embedder.DecoderEmbedder;
import io.netty.util.VoidEnum;
@ -54,7 +54,7 @@ public class ReplayingDecoderTest {
}
@Override
public ChannelBuffer decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) {
public ChannelBuffer decode(ChannelHandlerContext ctx, ChannelBuffer in) {
ChannelBuffer msg = in.readBytes(in.bytesBefore(ChannelBufferIndexFinder.LF));
in.skipBytes(1);
return msg;

View File

@ -18,7 +18,7 @@ package io.netty.example.discard;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
import java.util.logging.Level;
@ -33,7 +33,7 @@ public class DiscardClientHandler extends ChannelInboundStreamHandlerAdapter {
DiscardClientHandler.class.getName());
private final byte[] content;
private ChannelInboundHandlerContext<Byte> ctx;
private ChannelHandlerContext ctx;
public DiscardClientHandler(int messageSize) {
if (messageSize <= 0) {
@ -45,7 +45,7 @@ public class DiscardClientHandler extends ChannelInboundStreamHandlerAdapter {
@Override
public void channelActive(ChannelInboundHandlerContext<Byte> ctx)
public void channelActive(ChannelHandlerContext ctx)
throws Exception {
this.ctx = ctx;
// Send the initial messages.
@ -54,7 +54,7 @@ public class DiscardClientHandler extends ChannelInboundStreamHandlerAdapter {
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in)
public void inboundBufferUpdated(ChannelHandlerContext ctx, ChannelBuffer in)
throws Exception {
// Server is supposed to send nothing, but if it sends something, discard it.
in.clear();
@ -62,7 +62,7 @@ public class DiscardClientHandler extends ChannelInboundStreamHandlerAdapter {
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx,
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) throws Exception {
// Close the connection when an exception is raised.
logger.log(

View File

@ -16,7 +16,7 @@
package io.netty.example.discard;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
import java.util.logging.Level;
@ -32,7 +32,7 @@ public class DiscardServerHandler extends ChannelInboundStreamHandlerAdapter {
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in)
public void inboundBufferUpdated(ChannelHandlerContext ctx, ChannelBuffer in)
throws Exception {
// Discard the received data silently.
in.clear();
@ -40,7 +40,7 @@ public class DiscardServerHandler extends ChannelInboundStreamHandlerAdapter {
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx,
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) throws Exception {
// Close the connection when an exception is raised.
logger.log(

View File

@ -17,7 +17,7 @@ package io.netty.example.echo;
import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
import java.util.logging.Level;
@ -49,12 +49,12 @@ public class EchoClientHandler extends ChannelInboundStreamHandlerAdapter {
}
@Override
public void channelActive(ChannelInboundHandlerContext<Byte> ctx) {
public void channelActive(ChannelHandlerContext ctx) {
ctx.write(firstMessage);
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) {
public void inboundBufferUpdated(ChannelHandlerContext ctx, ChannelBuffer in) {
ChannelBuffer out = ctx.nextOutboundByteBuffer();
out.discardReadBytes();
out.writeBytes(in);
@ -62,8 +62,7 @@ public class EchoClientHandler extends ChannelInboundStreamHandlerAdapter {
}
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<Byte> ctx, Throwable cause) {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// Close the connection when an exception is raised.
logger.log(Level.WARNING, "Unexpected exception from downstream.", cause);
ctx.close();

View File

@ -23,8 +23,6 @@ import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioEventLoop;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import java.net.InetSocketAddress;
@ -51,7 +49,7 @@ public class EchoServer {
.handler(new ChannelInitializer<ServerSocketChannel>() {
@Override
public void initChannel(ServerSocketChannel ch) throws Exception {
ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
//ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
}
})
.childHandler(new ChannelInitializer<SocketChannel>() {

View File

@ -16,7 +16,7 @@
package io.netty.example.echo;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
import java.util.logging.Level;
@ -31,7 +31,7 @@ public class EchoServerHandler extends ChannelInboundStreamHandlerAdapter {
EchoServerHandler.class.getName());
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) {
public void inboundBufferUpdated(ChannelHandlerContext ctx, ChannelBuffer in) {
ChannelBuffer out = ctx.nextOutboundByteBuffer();
out.discardReadBytes();
out.writeBytes(in);
@ -39,7 +39,7 @@ public class EchoServerHandler extends ChannelInboundStreamHandlerAdapter {
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx, Throwable cause) {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// Close the connection when an exception is raised.
logger.log(Level.WARNING, "Unexpected exception from downstream.", cause);
ctx.close();

View File

@ -16,7 +16,7 @@
package io.netty.example.factorial;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.StreamToMessageDecoder;
@ -31,7 +31,7 @@ import java.math.BigInteger;
public class BigIntegerDecoder extends StreamToMessageDecoder<BigInteger> {
@Override
public BigInteger decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) {
public BigInteger decode(ChannelHandlerContext ctx, ChannelBuffer in) {
// Wait until the length prefix is available.
if (in.readableBytes() < 5) {
return null;

View File

@ -17,7 +17,7 @@ package io.netty.example.factorial;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import java.math.BigInteger;
@ -39,7 +39,7 @@ public class FactorialClientHandler extends ChannelInboundMessageHandlerAdapter<
private static final Logger logger = Logger.getLogger(
FactorialClientHandler.class.getName());
private ChannelInboundHandlerContext<BigInteger> ctx;
private ChannelHandlerContext ctx;
private int i = 1;
private int receivedMessages;
private final int count;
@ -65,7 +65,7 @@ public class FactorialClientHandler extends ChannelInboundMessageHandlerAdapter<
}
@Override
public void channelActive(ChannelInboundHandlerContext<BigInteger> ctx) {
public void channelActive(ChannelHandlerContext ctx) {
this.ctx = ctx;
sendNumbers();
}
@ -73,7 +73,7 @@ public class FactorialClientHandler extends ChannelInboundMessageHandlerAdapter<
@Override
public void messageReceived(
ChannelInboundHandlerContext<BigInteger> ctx, final BigInteger msg) {
ChannelHandlerContext ctx, final BigInteger msg) {
receivedMessages ++;
if (receivedMessages == count) {
// Offer the answer after closing the connection.
@ -89,7 +89,7 @@ public class FactorialClientHandler extends ChannelInboundMessageHandlerAdapter<
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<BigInteger> ctx, Throwable cause) throws Exception {
ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -15,7 +15,7 @@
*/
package io.netty.example.factorial;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import java.math.BigInteger;
@ -40,7 +40,7 @@ public class FactorialServerHandler extends ChannelInboundMessageHandlerAdapter<
@Override
public void messageReceived(
ChannelInboundHandlerContext<BigInteger> ctx, BigInteger msg) throws Exception {
ChannelHandlerContext ctx, BigInteger msg) throws Exception {
// Calculate the cumulative factorial and send it to the client.
lastMultiplier = msg;
factorial = factorial.multiply(msg);
@ -49,14 +49,14 @@ public class FactorialServerHandler extends ChannelInboundMessageHandlerAdapter<
@Override
public void channelInactive(
ChannelInboundHandlerContext<BigInteger> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
logger.info(new Formatter().format(
"Factorial of %,d is: %,d", lastMultiplier, factorial).toString());
}
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<BigInteger> ctx, Throwable cause) throws Exception {
ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -16,7 +16,7 @@
package io.netty.example.factorial;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder;
import java.math.BigInteger;
@ -30,7 +30,7 @@ public class NumberEncoder extends MessageToStreamEncoder<Number> {
@Override
public void encode(
ChannelOutboundHandlerContext<Number> ctx, Number msg, ChannelBuffer out) throws Exception {
ChannelHandlerContext ctx, Number msg, ChannelBuffer out) throws Exception {
// Convert to a BigInteger first for easier implementation.
BigInteger v;
if (msg instanceof BigInteger) {

View File

@ -24,7 +24,6 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.handler.codec.http.DefaultHttpResponse;
@ -103,7 +102,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
@Override
public void messageReceived(
ChannelInboundHandlerContext<HttpRequest> ctx, HttpRequest request) throws Exception {
ChannelHandlerContext ctx, HttpRequest request) throws Exception {
if (request.getMethod() != GET) {
sendError(ctx, METHOD_NOT_ALLOWED);
@ -173,7 +172,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<HttpRequest> ctx, Throwable cause) throws Exception {
ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof TooLongFrameException) {
sendError(ctx, BAD_REQUEST);
return;

View File

@ -17,8 +17,8 @@ package io.netty.example.http.snoop;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.socket.nio.NioEventLoop;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.CookieEncoder;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpHeaders;

View File

@ -18,7 +18,7 @@ package io.netty.example.http.snoop;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.http.HttpChunk;
import io.netty.handler.codec.http.HttpResponse;
@ -31,13 +31,13 @@ public class HttpSnoopClientHandler extends ChannelInboundMessageHandlerAdapter<
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void messageReceived(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (!readingChunks) {
HttpResponse response = (HttpResponse) msg;
@ -79,7 +79,7 @@ public class HttpSnoopClientHandler extends ChannelInboundMessageHandlerAdapter<
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
ctx.close();
}

View File

@ -17,8 +17,8 @@ package io.netty.example.http.snoop;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioEventLoop;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import java.net.InetSocketAddress;

View File

@ -25,7 +25,7 @@ import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.http.Cookie;
import io.netty.handler.codec.http.CookieDecoder;
@ -53,12 +53,12 @@ public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter<
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer();
}
@Override
public void messageReceived(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (!readingChunks) {
HttpRequest request = this.request = (HttpRequest) msg;
@ -125,7 +125,7 @@ public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter<
}
}
private void writeResponse(ChannelInboundHandlerContext<Object> ctx) {
private void writeResponse(ChannelHandlerContext ctx) {
// Decide whether to close the connection or not.
boolean keepAlive = isKeepAlive(request);
@ -165,14 +165,14 @@ public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter<
}
}
private static void send100Continue(ChannelInboundHandlerContext<Object> ctx) {
private static void send100Continue(ChannelHandlerContext ctx) {
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, CONTINUE);
ctx.write(response);
}
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
ctx.close();
}

View File

@ -23,7 +23,6 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.HttpHeaders;
@ -51,7 +50,7 @@ public class AutobahnServerHandler extends ChannelInboundMessageHandlerAdapter<O
private WebSocketServerHandshaker handshaker;
@Override
public void messageReceived(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpRequest) {
handleHttpRequest(ctx, (HttpRequest) msg);
} else if (msg instanceof WebSocketFrame) {
@ -121,7 +120,7 @@ public class AutobahnServerHandler extends ChannelInboundMessageHandlerAdapter<O
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
ctx.close();
}

View File

@ -38,7 +38,7 @@
package io.netty.example.http.websocketx.client;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
@ -57,12 +57,12 @@ public class WebSocketClientHandler extends ChannelInboundMessageHandlerAdapter<
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
System.out.println("WebSocket Client disconnected!");
}
@Override
public void messageReceived(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
Channel ch = ctx.channel();
if (!handshaker.isHandshakeComplete()) {
handshaker.finishHandshake(ch, (HttpResponse) msg);
@ -89,7 +89,7 @@ public class WebSocketClientHandler extends ChannelInboundMessageHandlerAdapter<
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
ctx.close();
}

View File

@ -25,7 +25,6 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.HttpHeaders;
@ -53,7 +52,7 @@ public class WebSocketServerHandler extends ChannelInboundMessageHandlerAdapter<
private WebSocketServerHandshaker handshaker;
@Override
public void messageReceived(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpRequest) {
handleHttpRequest(ctx, (HttpRequest) msg);
} else if (msg instanceof WebSocketFrame) {
@ -134,7 +133,7 @@ public class WebSocketServerHandler extends ChannelInboundMessageHandlerAdapter<
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
ctx.close();
}

View File

@ -25,7 +25,6 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.HttpHeaders;
@ -53,7 +52,7 @@ public class WebSocketSslServerHandler extends ChannelInboundMessageHandlerAdapt
private WebSocketServerHandshaker handshaker;
@Override
public void messageReceived(ChannelInboundHandlerContext<Object> ctx, Object msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpRequest) {
handleHttpRequest(ctx, (HttpRequest) msg);
} else if (msg instanceof WebSocketFrame) {
@ -134,7 +133,7 @@ public class WebSocketSslServerHandler extends ChannelInboundMessageHandlerAdapt
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
ctx.close();
}

View File

@ -15,6 +15,9 @@
*/
package io.netty.example.http.websocketx.sslserver;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.Security;
@ -22,9 +25,6 @@ import java.security.Security;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Creates a {@link SSLContext} for just server certificates.
*/

View File

@ -15,19 +15,19 @@
*/
package io.netty.example.localecho;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
public class LocalEchoClientHandler extends ChannelInboundMessageHandlerAdapter<String> {
@Override
public void messageReceived(ChannelInboundHandlerContext<String> ctx, String msg) {
public void messageReceived(ChannelHandlerContext ctx, String msg) {
// Print as received
System.out.println(msg);
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<String> ctx, Throwable cause) {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}

View File

@ -15,19 +15,19 @@
*/
package io.netty.example.localecho;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
public class LocalEchoServerHandler extends ChannelInboundMessageHandlerAdapter<String> {
@Override
public void messageReceived(ChannelInboundHandlerContext<String> ctx, String msg) {
public void messageReceived(ChannelHandlerContext ctx, String msg) {
// Write back as received
ctx.write(msg);
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<String> ctx, Throwable cause) {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}

View File

@ -16,7 +16,7 @@
package io.netty.example.localtime;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.example.localtime.LocalTimeProtocol.Continent;
import io.netty.example.localtime.LocalTimeProtocol.LocalTime;
@ -87,17 +87,17 @@ public class LocalTimeClientHandler extends ChannelInboundMessageHandlerAdapter<
}
@Override
public void channelRegistered(ChannelInboundHandlerContext<LocalTimes> ctx) throws Exception {
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
channel = ctx.channel();
}
@Override
public void messageReceived(ChannelInboundHandlerContext<LocalTimes> ctx, LocalTimes msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, LocalTimes msg) throws Exception {
answer.add(msg);
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<LocalTimes> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -16,7 +16,7 @@
package io.netty.example.localtime;
import static java.util.Calendar.*;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.example.localtime.LocalTimeProtocol.Continent;
import io.netty.example.localtime.LocalTimeProtocol.DayOfWeek;
@ -36,7 +36,7 @@ public class LocalTimeServerHandler extends ChannelInboundMessageHandlerAdapter<
LocalTimeServerHandler.class.getName());
@Override
public void messageReceived(ChannelInboundHandlerContext<Locations> ctx, Locations locations) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, Locations locations) throws Exception {
long currentTime = System.currentTimeMillis();
LocalTimes.Builder builder = LocalTimes.newBuilder();
@ -60,7 +60,7 @@ public class LocalTimeServerHandler extends ChannelInboundMessageHandlerAdapter<
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Locations> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -15,7 +15,7 @@
*/
package io.netty.example.objectecho;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import java.util.ArrayList;
@ -50,20 +50,20 @@ public class ObjectEchoClientHandler extends ChannelInboundMessageHandlerAdapter
}
@Override
public void channelActive(ChannelInboundHandlerContext<List<Integer>> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// Send the first message if this handler is a client-side handler.
ctx.write(firstMessage);
}
@Override
public void messageReceived(ChannelInboundHandlerContext<List<Integer>> ctx, List<Integer> msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, List<Integer> msg) throws Exception {
// Echo back the received object to the client.
ctx.write(msg);
}
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<List<Integer>> ctx, Throwable cause) throws Exception {
ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -15,7 +15,7 @@
*/
package io.netty.example.objectecho;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import java.util.List;
@ -33,14 +33,14 @@ public class ObjectEchoServerHandler extends ChannelInboundMessageHandlerAdapter
@Override
public void messageReceived(
ChannelInboundHandlerContext<List<Integer>> ctx, List<Integer> msg) throws Exception {
ChannelHandlerContext ctx, List<Integer> msg) throws Exception {
// Echo back the received object to the client.
ctx.write(msg);
}
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<List<Integer>> ctx, Throwable cause) throws Exception {
ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -17,7 +17,6 @@ package io.netty.example.portunification;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.example.factorial.BigIntegerDecoder;
@ -54,8 +53,8 @@ public class PortUnificationServerHandler extends ChannelInboundStreamHandlerAda
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelBuffer buffer = ctx.inbound().byteBuffer();
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
ChannelBuffer buffer = ctx.inboundByteBuffer();
// Will use the first two bytes to detect a protocol.
if (buffer.readableBytes() < 2) {

View File

@ -17,7 +17,7 @@ package io.netty.example.proxy;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
public class HexDumpProxyBackendHandler extends ChannelInboundStreamHandlerAdapter {
@ -29,13 +29,13 @@ public class HexDumpProxyBackendHandler extends ChannelInboundStreamHandlerAdapt
}
@Override
public void channelActive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
ctx.flush();
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelBuffer in = ctx.inbound().byteBuffer();
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
ChannelBuffer in = ctx.inboundByteBuffer();
ChannelBuffer out = inboundChannel.outboundByteBuffer();
out.discardReadBytes();
out.writeBytes(in);
@ -44,12 +44,12 @@ public class HexDumpProxyBackendHandler extends ChannelInboundStreamHandlerAdapt
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
HexDumpProxyFrontendHandler.closeOnFlush(inboundChannel);
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
HexDumpProxyFrontendHandler.closeOnFlush(ctx.channel());
}

View File

@ -20,7 +20,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
import io.netty.channel.socket.nio.NioSocketChannel;
@ -37,7 +37,7 @@ public class HexDumpProxyFrontendHandler extends ChannelInboundStreamHandlerAdap
}
@Override
public void channelActive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// TODO: Suspend incoming traffic until connected to the remote host.
// Currently, we just keep the inbound traffic in the client channel's outbound buffer.
final Channel inboundChannel = ctx.channel();
@ -66,8 +66,8 @@ public class HexDumpProxyFrontendHandler extends ChannelInboundStreamHandlerAdap
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
ChannelBuffer in = ctx.inbound().byteBuffer();
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
ChannelBuffer in = ctx.inboundByteBuffer();
ChannelBuffer out = outboundChannel.outboundByteBuffer();
out.discardReadBytes();
out.writeBytes(in);
@ -78,14 +78,14 @@ public class HexDumpProxyFrontendHandler extends ChannelInboundStreamHandlerAdap
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
if (outboundChannel != null) {
closeOnFlush(outboundChannel);
}
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
closeOnFlush(ctx.channel());
}

View File

@ -15,7 +15,7 @@
*/
package io.netty.example.qotm;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.socket.DatagramPacket;
import io.netty.util.CharsetUtil;
@ -25,7 +25,7 @@ public class QuoteOfTheMomentClientHandler extends ChannelInboundMessageHandlerA
@Override
public void messageReceived(
ChannelInboundHandlerContext<DatagramPacket> ctx, DatagramPacket msg)
ChannelHandlerContext ctx, DatagramPacket msg)
throws Exception {
String response = msg.data().toString(CharsetUtil.UTF_8);
if (response.startsWith("QOTM: ")) {
@ -36,7 +36,7 @@ public class QuoteOfTheMomentClientHandler extends ChannelInboundMessageHandlerA
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<DatagramPacket> ctx, Throwable cause)
ChannelHandlerContext ctx, Throwable cause)
throws Exception {
cause.printStackTrace();
ctx.close();

View File

@ -16,7 +16,7 @@
package io.netty.example.qotm;
import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.socket.DatagramPacket;
import io.netty.util.CharsetUtil;
@ -45,7 +45,7 @@ public class QuoteOfTheMomentServerHandler extends ChannelInboundMessageHandlerA
@Override
public void messageReceived(
ChannelInboundHandlerContext<DatagramPacket> ctx, DatagramPacket msg)
ChannelHandlerContext ctx, DatagramPacket msg)
throws Exception {
if (msg.data().toString(CharsetUtil.UTF_8).equals("QOTM?")) {
ctx.write(new DatagramPacket(
@ -56,7 +56,7 @@ public class QuoteOfTheMomentServerHandler extends ChannelInboundMessageHandlerA
@Override
public void exceptionCaught(
ChannelInboundHandlerContext<DatagramPacket> ctx, Throwable cause)
ChannelHandlerContext ctx, Throwable cause)
throws Exception {
cause.printStackTrace();
// We don't close the channel because we can keep serving requests.

View File

@ -15,7 +15,7 @@
*/
package io.netty.example.securechat;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.ssl.SslHandler;
@ -31,7 +31,7 @@ public class SecureChatClientHandler extends ChannelInboundMessageHandlerAdapter
SecureChatClientHandler.class.getName());
@Override
public void channelActive(ChannelInboundHandlerContext<String> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// Get the SslHandler from the pipeline
// which were added in SecureChatPipelineFactory.
SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
@ -41,12 +41,12 @@ public class SecureChatClientHandler extends ChannelInboundMessageHandlerAdapter
}
@Override
public void messageReceived(ChannelInboundHandlerContext<String> ctx, String msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
System.err.println(msg);
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<String> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -18,7 +18,7 @@ package io.netty.example.securechat;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.group.DefaultChannelGroup;
@ -39,7 +39,7 @@ public class SecureChatServerHandler extends ChannelInboundMessageHandlerAdapter
static final ChannelGroup channels = new DefaultChannelGroup();
@Override
public void channelActive(ChannelInboundHandlerContext<String> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// Get the SslHandler in the current pipeline.
// We added it in SecureChatPipelineFactory.
final SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
@ -50,7 +50,7 @@ public class SecureChatServerHandler extends ChannelInboundMessageHandlerAdapter
}
@Override
public void messageReceived(ChannelInboundHandlerContext<String> ctx, String request) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, String request) throws Exception {
// Send the received message to all channels but the current one.
for (Channel c: channels) {
if (c != ctx.channel()) {
@ -68,7 +68,7 @@ public class SecureChatServerHandler extends ChannelInboundMessageHandlerAdapter
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<String> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -15,6 +15,8 @@
*/
package io.netty.example.securechat;
import io.netty.handler.ssl.SslHandler;
import java.security.KeyStore;
import java.security.Security;
@ -24,8 +26,6 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.TrustManager;
import io.netty.handler.ssl.SslHandler;
/**
* Creates a bogus {@link SSLContext}. A client-side context created by this
* factory accepts any certificate even if it is invalid. A server-side context

View File

@ -15,9 +15,9 @@
*/
package io.netty.example.telnet;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -32,13 +32,13 @@ public class TelnetClientHandler extends ChannelInboundMessageHandlerAdapter<Str
TelnetClientHandler.class.getName());
@Override
public void messageReceived(ChannelInboundHandlerContext<String> ctx, String msg) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
// Print out the line received from the server.
System.err.println(msg);
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<String> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -18,7 +18,7 @@ package io.netty.example.telnet;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import java.net.InetAddress;
@ -36,7 +36,7 @@ public class TelnetServerHandler extends ChannelInboundMessageHandlerAdapter<Str
TelnetServerHandler.class.getName());
@Override
public void channelActive(ChannelInboundHandlerContext<String> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// Send greeting for a new connection.
ctx.write(
"Welcome to " + InetAddress.getLocalHost().getHostName() + "!\r\n");
@ -44,7 +44,7 @@ public class TelnetServerHandler extends ChannelInboundMessageHandlerAdapter<Str
}
@Override
public void messageReceived(ChannelInboundHandlerContext<String> ctx, String request) throws Exception {
public void messageReceived(ChannelHandlerContext ctx, String request) throws Exception {
// Generate and write a response.
String response;
boolean close = false;
@ -69,7 +69,7 @@ public class TelnetServerHandler extends ChannelInboundMessageHandlerAdapter<Str
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<String> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.", cause);

View File

@ -18,7 +18,7 @@ package io.netty.example.uptime;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter;
import io.netty.channel.EventLoop;
import io.netty.handler.timeout.IdleState;
@ -42,7 +42,7 @@ public class UptimeClientHandler extends ChannelInboundStreamHandlerAdapter {
}
@Override
public void channelActive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
if (startTime < 0) {
startTime = System.currentTimeMillis();
}
@ -50,13 +50,13 @@ public class UptimeClientHandler extends ChannelInboundStreamHandlerAdapter {
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
// Discard received data
in.clear();
}
@Override
public void userEventTriggered(ChannelInboundHandlerContext<Byte> ctx, Object evt) throws Exception {
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (!(evt instanceof IdleStateEvent)) {
return;
}
@ -70,12 +70,12 @@ public class UptimeClientHandler extends ChannelInboundStreamHandlerAdapter {
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
println("Disconnected from: " + ctx.channel().remoteAddress());
}
@Override
public void channelUnregistered(final ChannelInboundHandlerContext<Byte> ctx)
public void channelUnregistered(final ChannelHandlerContext ctx)
throws Exception {
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + "s");
@ -90,7 +90,7 @@ public class UptimeClientHandler extends ChannelInboundStreamHandlerAdapter {
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof ConnectException) {
startTime = -1;
println("Failed to connect: " + cause.getMessage());

View File

@ -23,8 +23,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.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.logging.InternalLogLevel;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
@ -284,18 +282,18 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
@Override
public ChannelBufferHolder<Object> newOutboundBuffer(
ChannelOutboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.outboundBypassBuffer(ctx);
}
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.inboundBypassBuffer(ctx);
}
@Override
public void channelRegistered(ChannelInboundHandlerContext<Object> ctx)
public void channelRegistered(ChannelHandlerContext ctx)
throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "REGISTERED"));
@ -304,7 +302,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void channelUnregistered(ChannelInboundHandlerContext<Object> ctx)
public void channelUnregistered(ChannelHandlerContext ctx)
throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "UNREGISTERED"));
@ -313,7 +311,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void channelActive(ChannelInboundHandlerContext<Object> ctx)
public void channelActive(ChannelHandlerContext ctx)
throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "ACTIVE"));
@ -322,7 +320,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Object> ctx)
public void channelInactive(ChannelHandlerContext ctx)
throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "INACTIVE"));
@ -331,7 +329,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx,
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "EXCEPTION: " + cause), cause);
@ -340,7 +338,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void userEventTriggered(ChannelInboundHandlerContext<Object> ctx,
public void userEventTriggered(ChannelHandlerContext ctx,
Object evt) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "USER_EVENT: " + evt));
@ -349,7 +347,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Object> ctx)
public void inboundBufferUpdated(ChannelHandlerContext ctx)
throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, formatBuffer("INBUF", ctx.inbound())));
@ -358,7 +356,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void bind(ChannelOutboundHandlerContext<Object> ctx,
public void bind(ChannelHandlerContext ctx,
SocketAddress localAddress, ChannelFuture future) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "BIND(" + localAddress + ')'));
@ -367,7 +365,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void connect(ChannelOutboundHandlerContext<Object> ctx,
public void connect(ChannelHandlerContext ctx,
SocketAddress remoteAddress, SocketAddress localAddress,
ChannelFuture future) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
@ -377,7 +375,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void disconnect(ChannelOutboundHandlerContext<Object> ctx,
public void disconnect(ChannelHandlerContext ctx,
ChannelFuture future) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "DISCONNECT()"));
@ -386,7 +384,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void close(ChannelOutboundHandlerContext<Object> ctx,
public void close(ChannelHandlerContext ctx,
ChannelFuture future) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "CLOSE()"));
@ -395,7 +393,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void deregister(ChannelOutboundHandlerContext<Object> ctx,
public void deregister(ChannelHandlerContext ctx,
ChannelFuture future) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, "DEREGISTER()"));
@ -404,7 +402,7 @@ public class LoggingHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void flush(ChannelOutboundHandlerContext<Object> ctx,
public void flush(ChannelHandlerContext ctx,
ChannelFuture future) throws Exception {
if (getLogger().isEnabled(internalLevel)) {
logger.log(internalLevel, format(ctx, formatBuffer("OUTBUF", ctx.outbound())));

View File

@ -22,7 +22,6 @@ import io.netty.channel.ChannelBufferHolder;
import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.util.internal.QueueFactory;
@ -98,7 +97,7 @@ public class BlockingReadHandler<E> extends ChannelInboundHandlerAdapter<Object>
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
return ChannelBufferHolders.messageBuffer(queue);
}
@ -193,12 +192,12 @@ public class BlockingReadHandler<E> extends ChannelInboundHandlerAdapter<Object>
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
addEvent(INACTIVE);
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Object> ctx,
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) throws Exception {
addEvent(cause);
}

View File

@ -21,8 +21,6 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.DefaultChannelFuture;
import io.netty.handler.codec.StreamToStreamCodec;
@ -437,19 +435,19 @@ public class SslHandler extends StreamToStreamCodec {
}
@Override
public void disconnect(final ChannelOutboundHandlerContext<Byte> ctx,
public void disconnect(final ChannelHandlerContext ctx,
final ChannelFuture future) throws Exception {
closeOutboundAndChannel(ctx, future, true);
}
@Override
public void close(final ChannelOutboundHandlerContext<Byte> ctx,
public void close(final ChannelHandlerContext ctx,
final ChannelFuture future) throws Exception {
closeOutboundAndChannel(ctx, future, false);
}
@Override
public void encode(ChannelOutboundHandlerContext<Byte> ctx, ChannelBuffer in, ChannelBuffer out) throws Exception {
public void encode(ChannelHandlerContext ctx, ChannelBuffer in, ChannelBuffer out) throws Exception {
// Do not encrypt the first write request if this handler is
@ -544,7 +542,7 @@ public class SslHandler extends StreamToStreamCodec {
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// Make sure the handshake future is notified when a connection has
// been closed during handshake.
synchronized (handshakeLock) {
@ -571,7 +569,7 @@ public class SslHandler extends StreamToStreamCodec {
}
@Override
public void exceptionCaught(ChannelInboundHandlerContext<Byte> ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof IOException) {
if (cause instanceof ClosedChannelException) {
synchronized (ignoreClosedChannelExceptionLock) {
@ -611,7 +609,7 @@ public class SslHandler extends StreamToStreamCodec {
@Override
public void decode(ChannelInboundHandlerContext<Byte> ctx, ChannelBuffer in, ChannelBuffer out) throws Exception {
public void decode(ChannelHandlerContext ctx, ChannelBuffer in, ChannelBuffer out) throws Exception {
// check if the packet lenght was read before
if (packetLength == -1) {
@ -1001,7 +999,7 @@ public class SslHandler extends StreamToStreamCodec {
}
private void closeOutboundAndChannel(
final ChannelOutboundHandlerContext<Byte> context, final ChannelFuture future, boolean disconnect) throws Exception {
final ChannelHandlerContext context, final ChannelFuture future, boolean disconnect) throws Exception {
if (!context.channel().isActive()) {
if (disconnect) {
ctx.disconnect(future);
@ -1082,7 +1080,7 @@ public class SslHandler extends StreamToStreamCodec {
* Calls {@link #handshake()} once the {@link Channel} is connected
*/
@Override
public void channelActive(final ChannelInboundHandlerContext<Byte> ctx) throws Exception {
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
if (issueHandshake) {
// issue and handshake and add a listener to it which will fire an exception event if an exception was thrown while doing the handshake
handshake().addListener(new ChannelFutureListener() {

View File

@ -16,12 +16,11 @@
package io.netty.handler.stream;
import static io.netty.buffer.ChannelBuffers.*;
import io.netty.buffer.ChannelBuffer;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import io.netty.buffer.ChannelBuffer;
/**
* A {@link ChunkedInput} that fetches data from a {@link ReadableByteChannel}
* chunk by chunk. Please note that the {@link ReadableByteChannel} must

View File

@ -25,8 +25,6 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
@ -84,14 +82,14 @@ public class ChunkedWriteHandler extends ChannelHandlerAdapter<Object, Object> {
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
return ChannelBufferHolders.inboundBypassBuffer(ctx);
}
@Override
public ChannelBufferHolder<Object> newOutboundBuffer(
ChannelOutboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.messageBuffer(queue);
}
@ -134,7 +132,7 @@ public class ChunkedWriteHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void flush(ChannelOutboundHandlerContext<Object> ctx, ChannelFuture future) throws Exception {
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
queue.add(future);
if (isWritable() || !ctx.channel().isActive()) {
doFlush(ctx);
@ -142,7 +140,7 @@ public class ChunkedWriteHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
doFlush(ctx);
super.channelInactive(ctx);
}

View File

@ -24,8 +24,6 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventExecutor;
import io.netty.util.HashedWheelTimer;
@ -205,12 +203,12 @@ public class IdleStateHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public ChannelBufferHolder<Object> newInboundBuffer(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public ChannelBufferHolder<Object> newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.inboundBypassBuffer(ctx);
}
@Override
public ChannelBufferHolder<Object> newOutboundBuffer(ChannelOutboundHandlerContext<Object> ctx) throws Exception {
public ChannelBufferHolder<Object> newOutboundBuffer(ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.outboundBypassBuffer(ctx);
}
@ -232,7 +230,7 @@ public class IdleStateHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void channelActive(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// This method will be invoked only if this handler was added
// before channelActive() event is fired. If a user adds this handler
// after the channelActive() event, initialize() will be called by beforeAdd().
@ -241,21 +239,21 @@ public class IdleStateHandler extends ChannelHandlerAdapter<Object, Object> {
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
destroy();
super.channelInactive(ctx);
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
lastReadTime = System.currentTimeMillis();
readerIdleCount = allIdleCount = 0;
ctx.fireInboundBufferUpdated();
}
@Override
public void flush(final ChannelOutboundHandlerContext<Object> ctx, ChannelFuture future) throws Exception {
public void flush(final ChannelHandlerContext ctx, ChannelFuture future) throws Exception {
future.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {

View File

@ -21,7 +21,6 @@ import io.netty.channel.ChannelBufferHolders;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
@ -113,7 +112,7 @@ public class ReadTimeoutHandler extends ChannelInboundHandlerAdapter<Object> {
@Override
public ChannelBufferHolder<Object> newInboundBuffer(
ChannelInboundHandlerContext<Object> ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.inboundBypassBuffer(ctx);
}
@ -135,7 +134,7 @@ public class ReadTimeoutHandler extends ChannelInboundHandlerAdapter<Object> {
}
@Override
public void channelActive(ChannelInboundHandlerContext<Object> ctx)
public void channelActive(ChannelHandlerContext ctx)
throws Exception {
// This method will be invoked only if this handler was added
// before channelActive() event is fired. If a user adds this handler
@ -145,13 +144,13 @@ public class ReadTimeoutHandler extends ChannelInboundHandlerAdapter<Object> {
}
@Override
public void channelInactive(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
destroy();
super.channelInactive(ctx);
}
@Override
public void inboundBufferUpdated(ChannelInboundHandlerContext<Object> ctx) throws Exception {
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
lastReadTime = System.currentTimeMillis();
ctx.fireInboundBufferUpdated();
}

View File

@ -22,7 +22,6 @@ import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
@ -105,12 +104,12 @@ public class WriteTimeoutHandler extends ChannelOutboundHandlerAdapter<Object> {
}
@Override
public ChannelBufferHolder<Object> newOutboundBuffer(ChannelOutboundHandlerContext<Object> ctx) throws Exception {
public ChannelBufferHolder<Object> newOutboundBuffer(ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.outboundBypassBuffer(ctx);
}
@Override
public void flush(final ChannelOutboundHandlerContext<Object> ctx, final ChannelFuture future) throws Exception {
public void flush(final ChannelHandlerContext ctx, final ChannelFuture future) throws Exception {
if (timeoutMillis > 0) {
// Schedule a timeout.
final ScheduledFuture<?> sf = ctx.executor().schedule(new Runnable() {

Some files were not shown because too many files have changed in this diff Show More