Fixed issue: NETTY-158 Can't set the default byte order to little endian on the client side if FrameDecoder or ReplayingDecoder is used.

* FrameDecoder and ReplayingDecoder now create their internal buffers only on demand so that a user has a chance to decide what ChannelBufferFactory FrameDecoder and ReplayingDecoder will use.
This commit is contained in:
Trustin Lee 2009-05-21 11:58:40 +00:00
parent 25eee122cb
commit 031c26482c
2 changed files with 2 additions and 53 deletions

View File

@ -29,14 +29,12 @@ import java.util.concurrent.atomic.AtomicReference;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ChannelUpstreamHandler;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
@ -148,8 +146,7 @@ import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
* @apiviz.landmark
*/
@ChannelPipelineCoverage("one")
public abstract class FrameDecoder
extends SimpleChannelUpstreamHandler implements LifeCycleAwareChannelHandler {
public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
private final boolean unfold;
private final AtomicReference<ChannelBuffer> cumulation =
@ -163,29 +160,6 @@ public abstract class FrameDecoder
this.unfold = unfold;
}
@Override
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
throws Exception {
cumulation(ctx);
super.handleUpstream(ctx, e);
}
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
cumulation(ctx);
}
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// Unused
}
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
}
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
}
@Override
public void messageReceived(
ChannelHandlerContext ctx, MessageEvent e) throws Exception {

View File

@ -29,13 +29,11 @@ import java.util.concurrent.atomic.AtomicReference;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBufferFactory;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
@ -256,7 +254,7 @@ import org.jboss.netty.handler.codec.frame.FrameDecoder;
*/
@ChannelPipelineCoverage("one")
public abstract class ReplayingDecoder<T extends Enum<T>>
extends SimpleChannelUpstreamHandler implements LifeCycleAwareChannelHandler {
extends SimpleChannelUpstreamHandler {
private final AtomicReference<ChannelBuffer> cumulation =
@ -352,29 +350,6 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
return decode(ctx, channel, buffer, state);
}
@Override
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
throws Exception {
cumulation(ctx);
super.handleUpstream(ctx, e);
}
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
cumulation(ctx);
}
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// Unused
}
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
}
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
}
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws Exception {