From ddb839eaf99b45619bf95fe115f63c4d196e0129 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 18 May 2012 17:38:44 +0900 Subject: [PATCH] Make ReplayingDecoder extend StreamToMessageDecoder --- .../netty/handler/codec/ReplayingDecoder.java | 45 ++----------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java index 04c4972297..1d786b5387 100644 --- a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java @@ -22,7 +22,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.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerContext; import io.netty.channel.ChannelPipeline; import io.netty.util.Signal; @@ -275,13 +274,13 @@ import io.netty.util.VoidEnum; * } * } * - * @param + * @param * the state type; use {@link VoidEnum} if state management is unused * * @apiviz.landmark * @apiviz.has io.netty.handler.codec.UnreplayableOperationException oneway - - throws */ -public abstract class ReplayingDecoder> extends ChannelInboundHandlerAdapter { +public abstract class ReplayingDecoder> extends StreamToMessageDecoder { static final Signal REPLAY = new Signal(ReplayingDecoder.class.getName() + ".REPLAY"); @@ -351,11 +350,6 @@ public abstract class ReplayingDecoder> extends ChannelInbo return in; } - @Override - public void inboundBufferUpdated(ChannelInboundHandlerContext ctx) throws Exception { - callDecode(ctx); - } - @Override public void channelInactive(ChannelInboundHandlerContext ctx) throws Exception { replayable.terminate(); @@ -365,7 +359,7 @@ public abstract class ReplayingDecoder> extends ChannelInbo } try { - if (unfoldAndAdd(ctx, ctx.nextIn(), decodeLast(ctx, replayable, state))) { + if (unfoldAndAdd(ctx, ctx.nextIn(), decodeLast(ctx, replayable))) { in.discardReadBytes(); ctx.fireInboundBufferUpdated(); } @@ -391,7 +385,7 @@ public abstract class ReplayingDecoder> extends ChannelInbo Object result = null; S oldState = state; try { - result = decode(ctx, replayable, state); + result = decode(ctx, replayable); if (result == null) { if (oldReaderIndex == in.readerIndex() && oldState == state) { throw new IllegalStateException( @@ -438,35 +432,4 @@ public abstract class ReplayingDecoder> extends ChannelInbo } } } - - /** - * Decodes the received packets so far into a frame. - * - * @param ctx the context of this handler - * @param in the cumulative buffer of received packets so far. - * Note that the buffer might be empty, which means you - * should not make an assumption that the buffer contains - * at least one byte in your decoder implementation. - * @param state the current decoder state ({@code null} if unused) - * - * @return the decoded frame - */ - public abstract O decode(ChannelInboundHandlerContext ctx, ChannelBuffer in, S state) throws Exception; - - /** - * Decodes the received data so far into a frame when the channel is - * disconnected. - * - * @param ctx the context of this handler - * @param in the cumulative buffer of received packets so far. - * Note that the buffer might be empty, which means you - * should not make an assumption that the buffer contains - * at least one byte in your decoder implementation. - * @param state the current decoder state ({@code null} if unused) - * - * @return the decoded frame - */ - public O decodeLast(ChannelInboundHandlerContext ctx, ChannelBuffer in, S state) throws Exception { - return decode(ctx, in, state); - } }