Replace 'Stream' with 'Byte'

- In computing, 'stream' means both byte stream and message stream,
  which is confusing.
- Also, we were already mixing stream and byte in some places and
  it's better use the terms consistently.
  (e.g. inboundByteBuffer & inbound stream)
This commit is contained in:
Trustin Lee 2012-06-09 21:05:59 +09:00
parent 24e1f936a8
commit e376888d48
63 changed files with 169 additions and 169 deletions

View File

@ -15,7 +15,7 @@
*/ */
package io.netty.handler.codec.http; package io.netty.handler.codec.http;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.compression.ZlibEncoder; import io.netty.handler.codec.compression.ZlibEncoder;
import io.netty.handler.codec.compression.ZlibWrapper; import io.netty.handler.codec.compression.ZlibWrapper;
@ -118,7 +118,7 @@ public class HttpContentCompressor extends HttpContentEncoder {
return new Result( return new Result(
targetContentEncoding, targetContentEncoding,
new EmbeddedStreamChannel( new EmbeddedByteChannel(
new ZlibEncoder(wrapper, compressionLevel, windowBits, memLevel))); new ZlibEncoder(wrapper, compressionLevel, windowBits, memLevel)));
} }

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.handler.codec.MessageToMessageDecoder;
/** /**
@ -42,7 +42,7 @@ import io.netty.handler.codec.MessageToMessageDecoder;
*/ */
public abstract class HttpContentDecoder extends MessageToMessageDecoder<Object, Object> { public abstract class HttpContentDecoder extends MessageToMessageDecoder<Object, Object> {
private EmbeddedStreamChannel decoder; private EmbeddedByteChannel decoder;
/** /**
* Creates a new instance. * Creates a new instance.
@ -137,7 +137,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<Object,
* {@code null} otherwise (alternatively, you can throw an exception * {@code null} otherwise (alternatively, you can throw an exception
* to block unknown encoding). * to block unknown encoding).
*/ */
protected abstract EmbeddedStreamChannel newContentDecoder(String contentEncoding) throws Exception; protected abstract EmbeddedByteChannel newContentDecoder(String contentEncoding) throws Exception;
/** /**
* Returns the expected content encoding of the decoded content. * Returns the expected content encoding of the decoded content.

View File

@ -15,7 +15,7 @@
*/ */
package io.netty.handler.codec.http; package io.netty.handler.codec.http;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.compression.ZlibDecoder; import io.netty.handler.codec.compression.ZlibDecoder;
import io.netty.handler.codec.compression.ZlibWrapper; import io.netty.handler.codec.compression.ZlibWrapper;
@ -26,12 +26,12 @@ import io.netty.handler.codec.compression.ZlibWrapper;
*/ */
public class HttpContentDecompressor extends HttpContentDecoder { public class HttpContentDecompressor extends HttpContentDecoder {
@Override @Override
protected EmbeddedStreamChannel newContentDecoder(String contentEncoding) throws Exception { protected EmbeddedByteChannel newContentDecoder(String contentEncoding) throws Exception {
if ("gzip".equalsIgnoreCase(contentEncoding) || "x-gzip".equalsIgnoreCase(contentEncoding)) { if ("gzip".equalsIgnoreCase(contentEncoding) || "x-gzip".equalsIgnoreCase(contentEncoding)) {
return new EmbeddedStreamChannel(new ZlibDecoder(ZlibWrapper.GZIP)); return new EmbeddedByteChannel(new ZlibDecoder(ZlibWrapper.GZIP));
} else if ("deflate".equalsIgnoreCase(contentEncoding) || "x-deflate".equalsIgnoreCase(contentEncoding)) { } else if ("deflate".equalsIgnoreCase(contentEncoding) || "x-deflate".equalsIgnoreCase(contentEncoding)) {
// To be strict, 'deflate' means ZLIB, but some servers were not implemented correctly. // To be strict, 'deflate' means ZLIB, but some servers were not implemented correctly.
return new EmbeddedStreamChannel(new ZlibDecoder(ZlibWrapper.ZLIB_OR_NONE)); return new EmbeddedByteChannel(new ZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
} }
// 'identity' or unsupported // 'identity' or unsupported

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.MessageToMessageCodec; import io.netty.handler.codec.MessageToMessageCodec;
import io.netty.util.internal.QueueFactory; import io.netty.util.internal.QueueFactory;
@ -49,7 +49,7 @@ import java.util.Queue;
public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessage, HttpMessage, Object, Object> { public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessage, HttpMessage, Object, Object> {
private final Queue<String> acceptEncodingQueue = QueueFactory.createQueue(); private final Queue<String> acceptEncodingQueue = QueueFactory.createQueue();
private EmbeddedStreamChannel encoder; private EmbeddedByteChannel encoder;
/** /**
* Creates a new instance. * Creates a new instance.
@ -200,9 +200,9 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
public static final class Result { public static final class Result {
private final String targetContentEncoding; private final String targetContentEncoding;
private final EmbeddedStreamChannel contentEncoder; private final EmbeddedByteChannel contentEncoder;
public Result(String targetContentEncoding, EmbeddedStreamChannel contentEncoder) { public Result(String targetContentEncoding, EmbeddedByteChannel contentEncoder) {
if (targetContentEncoding == null) { if (targetContentEncoding == null) {
throw new NullPointerException("targetContentEncoding"); throw new NullPointerException("targetContentEncoding");
} }
@ -218,7 +218,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
return targetContentEncoding; return targetContentEncoding;
} }
public EmbeddedStreamChannel getContentEncoder() { public EmbeddedByteChannel getContentEncoder() {
return contentEncoder; return contentEncoder;
} }
} }

View File

@ -19,7 +19,7 @@ import static io.netty.buffer.ChannelBuffers.*;
import static io.netty.handler.codec.http.HttpConstants.*; import static io.netty.handler.codec.http.HttpConstants.*;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.UnsupportedMessageTypeException; import io.netty.handler.codec.UnsupportedMessageTypeException;
import io.netty.handler.codec.http.HttpHeaders.Names; import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values; import io.netty.handler.codec.http.HttpHeaders.Values;
@ -42,7 +42,7 @@ import java.util.Map;
* implement all abstract methods properly. * implement all abstract methods properly.
* @apiviz.landmark * @apiviz.landmark
*/ */
public abstract class HttpMessageEncoder extends MessageToStreamEncoder<Object> { public abstract class HttpMessageEncoder extends MessageToByteEncoder<Object> {
private static final ChannelBuffer LAST_CHUNK = private static final ChannelBuffer LAST_CHUNK =
copiedBuffer("0\r\n\r\n", CharsetUtil.US_ASCII); copiedBuffer("0\r\n\r\n", CharsetUtil.US_ASCII);

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
/** /**
* Encodes a {@link WebSocketFrame} into a {@link ChannelBuffer}. * Encodes a {@link WebSocketFrame} into a {@link ChannelBuffer}.
@ -30,7 +30,7 @@ import io.netty.handler.codec.MessageToStreamEncoder;
* @apiviz.uses io.netty.handler.codec.http.websocket.WebSocketFrame * @apiviz.uses io.netty.handler.codec.http.websocket.WebSocketFrame
*/ */
@Sharable @Sharable
public class WebSocket00FrameEncoder extends MessageToStreamEncoder<WebSocketFrame> { public class WebSocket00FrameEncoder extends MessageToByteEncoder<WebSocketFrame> {
@Override @Override
public boolean isEncodable(Object msg) throws Exception { public boolean isEncodable(Object msg) throws Exception {

View File

@ -56,7 +56,7 @@ package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.TooLongFrameException; import io.netty.handler.codec.TooLongFrameException;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;
@ -69,7 +69,7 @@ import java.nio.ByteBuffer;
* href="https://github.com/joewalnes/webbit">webbit</a> and modified. * href="https://github.com/joewalnes/webbit">webbit</a> and modified.
* </p> * </p>
*/ */
public class WebSocket08FrameEncoder extends MessageToStreamEncoder<WebSocketFrame> { public class WebSocket08FrameEncoder extends MessageToByteEncoder<WebSocketFrame> {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocket08FrameEncoder.class); private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocket08FrameEncoder.class);

View File

@ -19,13 +19,13 @@ import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.StreamToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.TooLongFrameException; import io.netty.handler.codec.TooLongFrameException;
/** /**
* Decodes {@link ChannelBuffer}s into SPDY Data and Control Frames. * Decodes {@link ChannelBuffer}s into SPDY Data and Control Frames.
*/ */
public class SpdyFrameDecoder extends StreamToMessageDecoder<Object> { public class SpdyFrameDecoder extends ByteToMessageDecoder<Object> {
private final int spdyVersion; private final int spdyVersion;
private final int maxChunkSize; private final int maxChunkSize;

View File

@ -21,7 +21,7 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.UnsupportedMessageTypeException; import io.netty.handler.codec.UnsupportedMessageTypeException;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@ -30,7 +30,7 @@ import java.util.Set;
/** /**
* Encodes a SPDY Data or Control Frame into a {@link ChannelBuffer}. * Encodes a SPDY Data or Control Frame into a {@link ChannelBuffer}.
*/ */
public class SpdyFrameEncoder extends MessageToStreamEncoder<Object> { public class SpdyFrameEncoder extends MessageToByteEncoder<Object> {
private final int version; private final int version;
private volatile boolean finished; private volatile boolean finished;

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.http;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.CodecException; import io.netty.handler.codec.CodecException;
import io.netty.handler.codec.PrematureChannelClosureException; import io.netty.handler.codec.PrematureChannelClosureException;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
@ -36,7 +36,7 @@ public class HttpClientCodecTest {
@Test @Test
public void testFailsNotOnRequestResponse() { public void testFailsNotOnRequestResponse() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(codec); EmbeddedByteChannel ch = new EmbeddedByteChannel(codec);
ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")); ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"));
ch.writeInbound(ChannelBuffers.copiedBuffer(RESPONSE, CharsetUtil.ISO_8859_1)); ch.writeInbound(ChannelBuffers.copiedBuffer(RESPONSE, CharsetUtil.ISO_8859_1));
@ -46,7 +46,7 @@ public class HttpClientCodecTest {
@Test @Test
public void testFailsNotOnRequestResponseChunked() { public void testFailsNotOnRequestResponseChunked() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(codec); EmbeddedByteChannel ch = new EmbeddedByteChannel(codec);
ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")); ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"));
ch.writeInbound(ChannelBuffers.copiedBuffer(CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1)); ch.writeInbound(ChannelBuffers.copiedBuffer(CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1));
@ -56,7 +56,7 @@ public class HttpClientCodecTest {
@Test @Test
public void testFailsOnMissingResponse() { public void testFailsOnMissingResponse() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(codec); EmbeddedByteChannel ch = new EmbeddedByteChannel(codec);
assertTrue(ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"))); assertTrue(ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")));
assertNotNull(ch.readOutbound()); assertNotNull(ch.readOutbound());
@ -73,7 +73,7 @@ public class HttpClientCodecTest {
@Test @Test
public void testFailsOnIncompleteChunkedResponse() { public void testFailsOnIncompleteChunkedResponse() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(codec); EmbeddedByteChannel ch = new EmbeddedByteChannel(codec);
ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")); ch.writeOutbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"));
ch.writeInbound(ChannelBuffers.copiedBuffer(INCOMPLETE_CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1)); ch.writeInbound(ChannelBuffers.copiedBuffer(INCOMPLETE_CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1));

View File

@ -23,25 +23,25 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelOutboundHandler;
public abstract class StreamToStreamCodec public abstract class ByteToByteCodec
extends ChannelHandlerAdapter extends ChannelHandlerAdapter
implements ChannelInboundHandler<Byte>, ChannelOutboundHandler<Byte> { implements ChannelInboundHandler<Byte>, ChannelOutboundHandler<Byte> {
private final StreamToStreamEncoder encoder = new StreamToStreamEncoder() { private final ByteToByteEncoder encoder = new ByteToByteEncoder() {
@Override @Override
public void encode( public void encode(
ChannelHandlerContext ctx, ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception { ChannelBuffer in, ChannelBuffer out) throws Exception {
StreamToStreamCodec.this.encode(ctx, in, out); ByteToByteCodec.this.encode(ctx, in, out);
} }
}; };
private final StreamToStreamDecoder decoder = new StreamToStreamDecoder() { private final ByteToByteDecoder decoder = new ByteToByteDecoder() {
@Override @Override
public void decode( public void decode(
ChannelHandlerContext ctx, ChannelHandlerContext ctx,
ChannelBuffer in, ChannelBuffer out) throws Exception { ChannelBuffer in, ChannelBuffer out) throws Exception {
StreamToStreamCodec.this.decode(ctx, in, out); ByteToByteCodec.this.decode(ctx, in, out);
} }
}; };

View File

@ -17,9 +17,9 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
public abstract class StreamToStreamDecoder extends ChannelInboundStreamHandlerAdapter { public abstract class ByteToByteDecoder extends ChannelInboundByteHandlerAdapter {
@Override @Override
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception { public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {

View File

@ -18,9 +18,9 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundStreamHandlerAdapter; import io.netty.channel.ChannelOutboundByteHandlerAdapter;
public abstract class StreamToStreamEncoder extends ChannelOutboundStreamHandlerAdapter { public abstract class ByteToByteEncoder extends ChannelOutboundByteHandlerAdapter {
@Override @Override
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception { public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {

View File

@ -23,26 +23,26 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelOutboundHandler;
public abstract class StreamToMessageCodec<INBOUND_OUT, OUTBOUND_IN> public abstract class ByteToMessageCodec<INBOUND_OUT, OUTBOUND_IN>
extends ChannelHandlerAdapter extends ChannelHandlerAdapter
implements ChannelInboundHandler<Byte>, ChannelOutboundHandler<OUTBOUND_IN> { implements ChannelInboundHandler<Byte>, ChannelOutboundHandler<OUTBOUND_IN> {
private final MessageToStreamEncoder<OUTBOUND_IN> encoder = private final MessageToByteEncoder<OUTBOUND_IN> encoder =
new MessageToStreamEncoder<OUTBOUND_IN>() { new MessageToByteEncoder<OUTBOUND_IN>() {
@Override @Override
public void encode( public void encode(
ChannelHandlerContext ctx, ChannelHandlerContext ctx,
OUTBOUND_IN msg, ChannelBuffer out) throws Exception { OUTBOUND_IN msg, ChannelBuffer out) throws Exception {
StreamToMessageCodec.this.encode(ctx, msg, out); ByteToMessageCodec.this.encode(ctx, msg, out);
} }
}; };
private final StreamToMessageDecoder<INBOUND_OUT> decoder = private final ByteToMessageDecoder<INBOUND_OUT> decoder =
new StreamToMessageDecoder<INBOUND_OUT>() { new ByteToMessageDecoder<INBOUND_OUT>() {
@Override @Override
public INBOUND_OUT decode( public INBOUND_OUT decode(
ChannelHandlerContext ctx, ChannelBuffer in) throws Exception { ChannelHandlerContext ctx, ChannelBuffer in) throws Exception {
return StreamToMessageCodec.this.decode(ctx, in); return ByteToMessageCodec.this.decode(ctx, in);
} }
}; };

View File

@ -18,10 +18,10 @@ package io.netty.handler.codec;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
public abstract class StreamToMessageDecoder<O> extends ChannelInboundStreamHandlerAdapter { public abstract class ByteToMessageDecoder<O> extends ChannelInboundByteHandlerAdapter {
private ChannelHandlerContext ctx; private ChannelHandlerContext ctx;

View File

@ -54,7 +54,7 @@ import io.netty.channel.ChannelHandlerContext;
* </pre> * </pre>
* @apiviz.uses io.netty.handler.codec.frame.Delimiters - - useful * @apiviz.uses io.netty.handler.codec.frame.Delimiters - - useful
*/ */
public class DelimiterBasedFrameDecoder extends StreamToMessageDecoder<Object> { public class DelimiterBasedFrameDecoder extends ByteToMessageDecoder<Object> {
private final ChannelBuffer[] delimiters; private final ChannelBuffer[] delimiters;
private final int maxFrameLength; private final int maxFrameLength;

View File

@ -37,7 +37,7 @@ import io.netty.channel.ChannelHandlerContext;
* +-----+-----+-----+ * +-----+-----+-----+
* </pre> * </pre>
*/ */
public class FixedLengthFrameDecoder extends StreamToMessageDecoder<Object> { public class FixedLengthFrameDecoder extends ByteToMessageDecoder<Object> {
private final int frameLength; private final int frameLength;
private final boolean allocateFullBuffer; private final boolean allocateFullBuffer;

View File

@ -179,7 +179,7 @@ import io.netty.handler.codec.serialization.ObjectDecoder;
* </pre> * </pre>
* @see LengthFieldPrepender * @see LengthFieldPrepender
*/ */
public class LengthFieldBasedFrameDecoder extends StreamToMessageDecoder<Object> { public class LengthFieldBasedFrameDecoder extends ByteToMessageDecoder<Object> {
private final int maxFrameLength; private final int maxFrameLength;
private final int lengthFieldOffset; private final int lengthFieldOffset;

View File

@ -51,7 +51,7 @@ import java.nio.ByteOrder;
* </pre> * </pre>
*/ */
@Sharable @Sharable
public class LengthFieldPrepender extends MessageToStreamEncoder<ChannelBuffer> { public class LengthFieldPrepender extends MessageToByteEncoder<ChannelBuffer> {
private final int lengthFieldLength; private final int lengthFieldLength;
private final boolean lengthIncludesLengthFieldLength; private final boolean lengthIncludesLengthFieldLength;

View File

@ -22,7 +22,7 @@ import io.netty.channel.ChannelOutboundMessageHandlerAdapter;
import java.util.Queue; import java.util.Queue;
public abstract class MessageToStreamEncoder<I> extends ChannelOutboundMessageHandlerAdapter<I> { public abstract class MessageToByteEncoder<I> extends ChannelOutboundMessageHandlerAdapter<I> {
@Override @Override
public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception { public void flush(ChannelHandlerContext ctx, ChannelFuture future) throws Exception {

View File

@ -26,7 +26,7 @@ import io.netty.util.Signal;
import io.netty.util.VoidEnum; import io.netty.util.VoidEnum;
/** /**
* A specialized variation of {@link StreamToMessageDecoder} which enables implementation * A specialized variation of {@link ByteToMessageDecoder} which enables implementation
* of a non-blocking decoder in the blocking I/O paradigm. * of a non-blocking decoder in the blocking I/O paradigm.
* <p> * <p>
* The biggest difference between {@link ReplayingDecoder} and * The biggest difference between {@link ReplayingDecoder} and
@ -278,7 +278,7 @@ import io.netty.util.VoidEnum;
* @apiviz.landmark * @apiviz.landmark
* @apiviz.has io.netty.handler.codec.UnreplayableOperationException oneway - - throws * @apiviz.has io.netty.handler.codec.UnreplayableOperationException oneway - - throws
*/ */
public abstract class ReplayingDecoder<O, S extends Enum<S>> extends StreamToMessageDecoder<O> { public abstract class ReplayingDecoder<O, S extends Enum<S>> extends ByteToMessageDecoder<O> {
static final Signal REPLAY = new Signal(ReplayingDecoder.class.getName() + ".REPLAY"); static final Signal REPLAY = new Signal(ReplayingDecoder.class.getName() + ".REPLAY");

View File

@ -19,15 +19,15 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.DelimiterBasedFrameDecoder; import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters; import io.netty.handler.codec.Delimiters;
import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.StreamToMessageDecoder;
/** /**
* Decodes a Base64-encoded {@link ChannelBuffer} or US-ASCII {@link String} * Decodes a Base64-encoded {@link ChannelBuffer} or US-ASCII {@link String}
* into a {@link ChannelBuffer}. Please note that this decoder must be used * into a {@link ChannelBuffer}. Please note that this decoder must be used
* with a proper {@link StreamToMessageDecoder} such as {@link DelimiterBasedFrameDecoder} * with a proper {@link ByteToMessageDecoder} such as {@link DelimiterBasedFrameDecoder}
* if you are using a stream-based transport such as TCP/IP. A typical decoder * if you are using a stream-based transport such as TCP/IP. A typical decoder
* setup for TCP/IP would be: * setup for TCP/IP would be:
* <pre> * <pre>

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.compression;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.StreamToStreamDecoder; import io.netty.handler.codec.ByteToByteDecoder;
import io.netty.util.internal.jzlib.JZlib; import io.netty.util.internal.jzlib.JZlib;
import io.netty.util.internal.jzlib.ZStream; import io.netty.util.internal.jzlib.ZStream;
@ -27,7 +27,7 @@ import io.netty.util.internal.jzlib.ZStream;
* @apiviz.landmark * @apiviz.landmark
* @apiviz.has io.netty.handler.codec.compression.ZlibWrapper * @apiviz.has io.netty.handler.codec.compression.ZlibWrapper
*/ */
public class ZlibDecoder extends StreamToStreamDecoder { public class ZlibDecoder extends ByteToByteDecoder {
private final ZStream z = new ZStream(); private final ZStream z = new ZStream();
private byte[] dictionary; private byte[] dictionary;

View File

@ -20,7 +20,7 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.StreamToStreamEncoder; import io.netty.handler.codec.ByteToByteEncoder;
import io.netty.util.internal.jzlib.JZlib; import io.netty.util.internal.jzlib.JZlib;
import io.netty.util.internal.jzlib.ZStream; import io.netty.util.internal.jzlib.ZStream;
@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @apiviz.landmark * @apiviz.landmark
* @apiviz.has io.netty.handler.codec.compression.ZlibWrapper * @apiviz.has io.netty.handler.codec.compression.ZlibWrapper
*/ */
public class ZlibEncoder extends StreamToStreamEncoder { public class ZlibEncoder extends ByteToByteEncoder {
private static final byte[] EMPTY_ARRAY = new byte[0]; private static final byte[] EMPTY_ARRAY = new byte[0];

View File

@ -19,12 +19,12 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import org.jboss.marshalling.Marshaller; import org.jboss.marshalling.Marshaller;
/** /**
* {@link MessageToStreamEncoder} implementation which uses JBoss Marshalling to marshal * {@link MessageToByteEncoder} implementation which uses JBoss Marshalling to marshal
* an Object. * an Object.
* *
* See <a href="http://www.jboss.org/jbossmarshalling">JBoss Marshalling website</a> * See <a href="http://www.jboss.org/jbossmarshalling">JBoss Marshalling website</a>
@ -34,7 +34,7 @@ import org.jboss.marshalling.Marshaller;
* *
*/ */
@Sharable @Sharable
public class CompatibleMarshallingEncoder extends MessageToStreamEncoder<Object> { public class CompatibleMarshallingEncoder extends MessageToByteEncoder<Object> {
private final MarshallerProvider provider; private final MarshallerProvider provider;

View File

@ -18,12 +18,12 @@ package io.netty.handler.codec.marshalling;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import org.jboss.marshalling.Marshaller; import org.jboss.marshalling.Marshaller;
/** /**
* {@link MessageToStreamEncoder} implementation which uses JBoss Marshalling to marshal * {@link MessageToByteEncoder} implementation which uses JBoss Marshalling to marshal
* an Object. Be aware that this encoder is not compatible with an other client that just use * an Object. Be aware that this encoder is not compatible with an other client that just use
* JBoss Marshalling as it includes the size of every {@link Object} that gets serialized in * JBoss Marshalling as it includes the size of every {@link Object} that gets serialized in
* front of the {@link Object} itself. * front of the {@link Object} itself.
@ -35,7 +35,7 @@ import org.jboss.marshalling.Marshaller;
* *
*/ */
@Sharable @Sharable
public class MarshallingEncoder extends MessageToStreamEncoder<Object> { public class MarshallingEncoder extends MessageToByteEncoder<Object> {
private static final byte[] LENGTH_PLACEHOLDER = new byte[4]; private static final byte[] LENGTH_PLACEHOLDER = new byte[4];
private final MarshallerProvider provider; private final MarshallerProvider provider;

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.protobuf;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.CorruptedFrameException; import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.StreamToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
import com.google.protobuf.CodedInputStream; import com.google.protobuf.CodedInputStream;
@ -37,7 +37,7 @@ import com.google.protobuf.CodedInputStream;
* *
* @see com.google.protobuf.CodedInputStream * @see com.google.protobuf.CodedInputStream
*/ */
public class ProtobufVarint32FrameDecoder extends StreamToMessageDecoder<Object> { public class ProtobufVarint32FrameDecoder extends ByteToMessageDecoder<Object> {
// TODO maxFrameLength + safe skip + fail-fast option // TODO maxFrameLength + safe skip + fail-fast option
// (just like LengthFieldBasedFrameDecoder) // (just like LengthFieldBasedFrameDecoder)

View File

@ -19,7 +19,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferOutputStream; import io.netty.buffer.ChannelBufferOutputStream;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import com.google.protobuf.CodedOutputStream; import com.google.protobuf.CodedOutputStream;
@ -38,7 +38,7 @@ import com.google.protobuf.CodedOutputStream;
* @see com.google.protobuf.CodedOutputStream * @see com.google.protobuf.CodedOutputStream
*/ */
@Sharable @Sharable
public class ProtobufVarint32LengthFieldPrepender extends MessageToStreamEncoder<ChannelBuffer> { public class ProtobufVarint32LengthFieldPrepender extends MessageToByteEncoder<ChannelBuffer> {
/** /**
* Creates a new instance. * Creates a new instance.

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.serialization;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferOutputStream; import io.netty.buffer.ChannelBufferOutputStream;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.Attribute; import io.netty.util.Attribute;
import io.netty.util.AttributeKey; import io.netty.util.AttributeKey;
@ -34,7 +34,7 @@ import java.io.Serializable;
* This encoder is interoperable with the standard Java object streams such as * This encoder is interoperable with the standard Java object streams such as
* {@link ObjectInputStream} and {@link ObjectOutputStream}. * {@link ObjectInputStream} and {@link ObjectOutputStream}.
*/ */
public class CompatibleObjectEncoder extends MessageToStreamEncoder<Object> { public class CompatibleObjectEncoder extends MessageToByteEncoder<Object> {
private static final AttributeKey<ObjectOutputStream> OOS = private static final AttributeKey<ObjectOutputStream> OOS =
new AttributeKey<ObjectOutputStream>(CompatibleObjectEncoder.class.getName() + ".oos"); new AttributeKey<ObjectOutputStream>(CompatibleObjectEncoder.class.getName() + ".oos");

View File

@ -19,7 +19,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferOutputStream; import io.netty.buffer.ChannelBufferOutputStream;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
@ -36,7 +36,7 @@ import java.io.Serializable;
* @apiviz.has io.netty.handler.codec.serialization.ObjectEncoderOutputStream - - - compatible with * @apiviz.has io.netty.handler.codec.serialization.ObjectEncoderOutputStream - - - compatible with
*/ */
@Sharable @Sharable
public class ObjectEncoder extends MessageToStreamEncoder<Object> { public class ObjectEncoder extends MessageToByteEncoder<Object> {
private static final byte[] LENGTH_PLACEHOLDER = new byte[4]; private static final byte[] LENGTH_PLACEHOLDER = new byte[4];
@Override @Override

View File

@ -20,7 +20,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBufferIndexFinder; import io.netty.buffer.ChannelBufferIndexFinder;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.util.VoidEnum; import io.netty.util.VoidEnum;
import org.junit.Test; import org.junit.Test;
@ -29,7 +29,7 @@ public class ReplayingDecoderTest {
@Test @Test
public void testLineProtocol() { public void testLineProtocol() {
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(new LineDecoder()); EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineDecoder());
// Ordinary input // Ordinary input
ch.writeInbound(ChannelBuffers.wrappedBuffer(new byte[] { 'A' })); ch.writeInbound(ChannelBuffers.wrappedBuffer(new byte[] { 'A' }));

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.frame;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.DelimiterBasedFrameDecoder; import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters; import io.netty.handler.codec.Delimiters;
@ -32,7 +32,7 @@ public class DelimiterBasedFrameDecoderTest {
@Test @Test
public void testFailSlowTooLongFrameRecovery() throws Exception { public void testFailSlowTooLongFrameRecovery() throws Exception {
EmbeddedStreamChannel ch = new EmbeddedStreamChannel( EmbeddedByteChannel ch = new EmbeddedByteChannel(
new DelimiterBasedFrameDecoder(1, true, false, Delimiters.nulDelimiter())); new DelimiterBasedFrameDecoder(1, true, false, Delimiters.nulDelimiter()));
for (int i = 0; i < 2; i ++) { for (int i = 0; i < 2; i ++) {
@ -52,7 +52,7 @@ public class DelimiterBasedFrameDecoderTest {
@Test @Test
public void testFailFastTooLongFrameRecovery() throws Exception { public void testFailFastTooLongFrameRecovery() throws Exception {
EmbeddedStreamChannel ch = new EmbeddedStreamChannel( EmbeddedByteChannel ch = new EmbeddedByteChannel(
new DelimiterBasedFrameDecoder(1, Delimiters.nulDelimiter())); new DelimiterBasedFrameDecoder(1, Delimiters.nulDelimiter()));
for (int i = 0; i < 2; i ++) { for (int i = 0; i < 2; i ++) {

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.frame;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder; import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.TooLongFrameException; import io.netty.handler.codec.TooLongFrameException;
@ -30,7 +30,7 @@ import org.junit.Test;
public class LengthFieldBasedFrameDecoderTest { public class LengthFieldBasedFrameDecoderTest {
@Test @Test
public void testFailSlowTooLongFrameRecovery() throws Exception { public void testFailSlowTooLongFrameRecovery() throws Exception {
EmbeddedStreamChannel ch = new EmbeddedStreamChannel( EmbeddedByteChannel ch = new EmbeddedByteChannel(
new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4, false)); new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4, false));
for (int i = 0; i < 2; i ++) { for (int i = 0; i < 2; i ++) {
@ -50,7 +50,7 @@ public class LengthFieldBasedFrameDecoderTest {
@Test @Test
public void testFailFastTooLongFrameRecovery() throws Exception { public void testFailFastTooLongFrameRecovery() throws Exception {
EmbeddedStreamChannel ch = new EmbeddedStreamChannel( EmbeddedByteChannel ch = new EmbeddedByteChannel(
new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4)); new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4));
for (int i = 0; i < 2; i ++) { for (int i = 0; i < 2; i ++) {

View File

@ -19,7 +19,7 @@ import static org.junit.Assert.*;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.CodecException; import io.netty.handler.codec.CodecException;
import io.netty.handler.codec.TooLongFrameException; import io.netty.handler.codec.TooLongFrameException;
@ -42,7 +42,7 @@ public abstract class AbstractCompatibleMarshallingDecoderTest {
MarshallerFactory marshallerFactory = createMarshallerFactory(); MarshallerFactory marshallerFactory = createMarshallerFactory();
MarshallingConfiguration configuration = createMarshallingConfig(); MarshallingConfiguration configuration = createMarshallingConfig();
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(createDecoder(Integer.MAX_VALUE)); EmbeddedByteChannel ch = new EmbeddedByteChannel(createDecoder(Integer.MAX_VALUE));
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
Marshaller marshaller = marshallerFactory.createMarshaller(configuration); Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
@ -72,7 +72,7 @@ public abstract class AbstractCompatibleMarshallingDecoderTest {
MarshallerFactory marshallerFactory = createMarshallerFactory(); MarshallerFactory marshallerFactory = createMarshallerFactory();
MarshallingConfiguration configuration = createMarshallingConfig(); MarshallingConfiguration configuration = createMarshallingConfig();
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(createDecoder(Integer.MAX_VALUE)); EmbeddedByteChannel ch = new EmbeddedByteChannel(createDecoder(Integer.MAX_VALUE));
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
Marshaller marshaller = marshallerFactory.createMarshaller(configuration); Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
@ -103,7 +103,7 @@ public abstract class AbstractCompatibleMarshallingDecoderTest {
MarshallingConfiguration configuration = createMarshallingConfig(); MarshallingConfiguration configuration = createMarshallingConfig();
ChannelHandler mDecoder = createDecoder(4); ChannelHandler mDecoder = createDecoder(4);
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(mDecoder); EmbeddedByteChannel ch = new EmbeddedByteChannel(mDecoder);
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
Marshaller marshaller = marshallerFactory.createMarshaller(configuration); Marshaller marshaller = marshallerFactory.createMarshaller(configuration);

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.marshalling;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import java.io.IOException; import java.io.IOException;
@ -38,7 +38,7 @@ public abstract class AbstractCompatibleMarshallingEncoderTest {
final MarshallerFactory marshallerFactory = createMarshallerFactory(); final MarshallerFactory marshallerFactory = createMarshallerFactory();
final MarshallingConfiguration configuration = createMarshallingConfig(); final MarshallingConfiguration configuration = createMarshallingConfig();
EmbeddedStreamChannel ch = new EmbeddedStreamChannel(createEncoder()); EmbeddedByteChannel ch = new EmbeddedByteChannel(createEncoder());
ch.writeOutbound(testObject); ch.writeOutbound(testObject);
Assert.assertTrue(ch.finish()); Assert.assertTrue(ch.finish());

View File

@ -20,18 +20,18 @@ import static org.hamcrest.core.Is.*;
import static org.hamcrest.core.IsNull.*; import static org.hamcrest.core.IsNull.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class ProtobufVarint32FrameDecoderTest { public class ProtobufVarint32FrameDecoderTest {
private EmbeddedStreamChannel ch; private EmbeddedByteChannel ch;
@Before @Before
public void setUp() { public void setUp() {
ch = new EmbeddedStreamChannel(new ProtobufVarint32FrameDecoder()); ch = new EmbeddedByteChannel(new ProtobufVarint32FrameDecoder());
} }
@Test @Test

View File

@ -18,18 +18,18 @@ package io.netty.handler.codec.protobuf;
import static io.netty.buffer.ChannelBuffers.*; import static io.netty.buffer.ChannelBuffers.*;
import static org.hamcrest.core.Is.*; import static org.hamcrest.core.Is.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import io.netty.channel.embedded.EmbeddedStreamChannel; import io.netty.channel.embedded.EmbeddedByteChannel;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class ProtobufVarint32LengthFieldPrependerTest { public class ProtobufVarint32LengthFieldPrependerTest {
private EmbeddedStreamChannel ch; private EmbeddedByteChannel ch;
@Before @Before
public void setUp() { public void setUp() {
ch = new EmbeddedStreamChannel(new ProtobufVarint32LengthFieldPrepender()); ch = new EmbeddedByteChannel(new ProtobufVarint32LengthFieldPrepender());
} }
@Test @Test

View File

@ -19,7 +19,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -27,7 +27,7 @@ import java.util.logging.Logger;
/** /**
* Handles a client-side channel. * Handles a client-side channel.
*/ */
public class DiscardClientHandler extends ChannelInboundStreamHandlerAdapter { public class DiscardClientHandler extends ChannelInboundByteHandlerAdapter {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
DiscardClientHandler.class.getName()); DiscardClientHandler.class.getName());

View File

@ -17,7 +17,7 @@ package io.netty.example.discard;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -25,7 +25,7 @@ import java.util.logging.Logger;
/** /**
* Handles a server-side channel. * Handles a server-side channel.
*/ */
public class DiscardServerHandler extends ChannelInboundStreamHandlerAdapter { public class DiscardServerHandler extends ChannelInboundByteHandlerAdapter {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
DiscardServerHandler.class.getName()); DiscardServerHandler.class.getName());

View File

@ -18,7 +18,7 @@ package io.netty.example.echo;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -28,7 +28,7 @@ import java.util.logging.Logger;
* traffic between the echo client and server by sending the first message to * traffic between the echo client and server by sending the first message to
* the server. * the server.
*/ */
public class EchoClientHandler extends ChannelInboundStreamHandlerAdapter { public class EchoClientHandler extends ChannelInboundByteHandlerAdapter {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
EchoClientHandler.class.getName()); EchoClientHandler.class.getName());

View File

@ -18,7 +18,7 @@ package io.netty.example.echo;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -27,7 +27,7 @@ import java.util.logging.Logger;
* Handler implementation for the echo server. * Handler implementation for the echo server.
*/ */
@Sharable @Sharable
public class EchoServerHandler extends ChannelInboundStreamHandlerAdapter { public class EchoServerHandler extends ChannelInboundByteHandlerAdapter {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
EchoServerHandler.class.getName()); EchoServerHandler.class.getName());

View File

@ -18,7 +18,7 @@ package io.netty.example.factorial;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.CorruptedFrameException; import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.StreamToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
import java.math.BigInteger; import java.math.BigInteger;
@ -28,7 +28,7 @@ import java.math.BigInteger;
* {@link BigInteger} instance. For example, { 'F', 0, 0, 0, 1, 42 } will be * {@link BigInteger} instance. For example, { 'F', 0, 0, 0, 1, 42 } will be
* decoded into new BigInteger("42"). * decoded into new BigInteger("42").
*/ */
public class BigIntegerDecoder extends StreamToMessageDecoder<BigInteger> { public class BigIntegerDecoder extends ByteToMessageDecoder<BigInteger> {
@Override @Override
public BigInteger decode(ChannelHandlerContext ctx, ChannelBuffer in) { public BigInteger decode(ChannelHandlerContext ctx, ChannelBuffer in) {

View File

@ -17,7 +17,7 @@ package io.netty.example.factorial;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToStreamEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import java.math.BigInteger; import java.math.BigInteger;
@ -26,7 +26,7 @@ import java.math.BigInteger;
* a magic number ('F' or 0x46) and a 32-bit length prefix. For example, 42 * a magic number ('F' or 0x46) and a 32-bit length prefix. For example, 42
* will be encoded to { 'F', 0, 0, 0, 1, 42 }. * will be encoded to { 'F', 0, 0, 0, 1, 42 }.
*/ */
public class NumberEncoder extends MessageToStreamEncoder<Number> { public class NumberEncoder extends MessageToByteEncoder<Number> {
@Override @Override
public void encode( public void encode(

View File

@ -17,7 +17,7 @@ package io.netty.example.portunification;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.example.factorial.BigIntegerDecoder; import io.netty.example.factorial.BigIntegerDecoder;
import io.netty.example.factorial.FactorialServerHandler; import io.netty.example.factorial.FactorialServerHandler;
@ -38,7 +38,7 @@ import javax.net.ssl.SSLEngine;
* Manipulates the current pipeline dynamically to switch protocols or enable * Manipulates the current pipeline dynamically to switch protocols or enable
* SSL or GZIP. * SSL or GZIP.
*/ */
public class PortUnificationServerHandler extends ChannelInboundStreamHandlerAdapter { public class PortUnificationServerHandler extends ChannelInboundByteHandlerAdapter {
private final boolean detectSsl; private final boolean detectSsl;
private final boolean detectGzip; private final boolean detectGzip;

View File

@ -18,9 +18,9 @@ package io.netty.example.proxy;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
public class HexDumpProxyBackendHandler extends ChannelInboundStreamHandlerAdapter { public class HexDumpProxyBackendHandler extends ChannelInboundByteHandlerAdapter {
private final Channel inboundChannel; private final Channel inboundChannel;

View File

@ -21,10 +21,10 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
public class HexDumpProxyFrontendHandler extends ChannelInboundStreamHandlerAdapter { public class HexDumpProxyFrontendHandler extends ChannelInboundByteHandlerAdapter {
private final String remoteHost; private final String remoteHost;
private final int remotePort; private final int remotePort;

View File

@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import io.netty.handler.timeout.IdleState; import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent; import io.netty.handler.timeout.IdleStateEvent;
@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
* connection attempt status. * connection attempt status.
*/ */
@Sharable @Sharable
public class UptimeClientHandler extends ChannelInboundStreamHandlerAdapter { public class UptimeClientHandler extends ChannelInboundByteHandlerAdapter {
private final UptimeClient client; private final UptimeClient client;
private long startTime = -1; private long startTime = -1;

View File

@ -23,7 +23,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelOutboundHandler;
public class StreamLoggingHandler public class ByteLoggingHandler
extends LoggingHandler extends LoggingHandler
implements ChannelInboundHandler<Byte>, ChannelOutboundHandler<Byte> { implements ChannelInboundHandler<Byte>, ChannelOutboundHandler<Byte> {
@ -87,27 +87,27 @@ public class StreamLoggingHandler
} }
} }
public StreamLoggingHandler() { public ByteLoggingHandler() {
super(); super();
} }
public StreamLoggingHandler(Class<?> clazz, LogLevel level) { public ByteLoggingHandler(Class<?> clazz, LogLevel level) {
super(clazz, level); super(clazz, level);
} }
public StreamLoggingHandler(Class<?> clazz) { public ByteLoggingHandler(Class<?> clazz) {
super(clazz); super(clazz);
} }
public StreamLoggingHandler(LogLevel level) { public ByteLoggingHandler(LogLevel level) {
super(level); super(level);
} }
public StreamLoggingHandler(String name, LogLevel level) { public ByteLoggingHandler(String name, LogLevel level) {
super(name, level); super(name, level);
} }
public StreamLoggingHandler(String name) { public ByteLoggingHandler(String name) {
super(name); super(name);
} }
@Override @Override

View File

@ -22,7 +22,7 @@ import io.netty.buffer.ChannelBuffer;
import io.netty.buffer.ChannelBuffers; import io.netty.buffer.ChannelBuffers;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
@ -108,7 +108,7 @@ public class SocketEchoTest extends AbstractSocketTest {
} }
} }
private static class EchoHandler extends ChannelInboundStreamHandlerAdapter { private static class EchoHandler extends ChannelInboundByteHandlerAdapter {
volatile Channel channel; volatile Channel channel;
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>(); final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
volatile int counter; volatile int counter;

View File

@ -23,7 +23,7 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter; import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.spdy.SpdyConstants; import io.netty.handler.codec.spdy.SpdyConstants;
@ -245,7 +245,7 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
} }
} }
private class SpdyEchoTestClientHandler extends ChannelInboundStreamHandlerAdapter { private class SpdyEchoTestClientHandler extends ChannelInboundByteHandlerAdapter {
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>(); final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
final ChannelBuffer frames; final ChannelBuffer frames;
volatile int counter; volatile int counter;

View File

@ -23,7 +23,7 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.handler.ssl.SslHandler; import io.netty.handler.ssl.SslHandler;
@ -148,7 +148,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
} }
} }
private class EchoHandler extends ChannelInboundStreamHandlerAdapter { private class EchoHandler extends ChannelInboundByteHandlerAdapter {
volatile Channel channel; volatile Channel channel;
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>(); final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
volatile int counter; volatile int counter;

View File

@ -41,7 +41,7 @@ public final class ChannelBufferHolder<E> {
} }
msgBuf = null; msgBuf = null;
this.byteBuf = byteBuf; this.byteBuf = byteBuf;
type = ChannelBufferType.STREAM; type = ChannelBufferType.BYTE;
} }
public ChannelBufferType type() { public ChannelBufferType type() {
@ -67,7 +67,7 @@ public final class ChannelBufferHolder<E> {
switch (type) { switch (type) {
case MESSAGE: case MESSAGE:
return "MessageBuffer(" + msgBuf.size() + ')'; return "MessageBuffer(" + msgBuf.size() + ')';
case STREAM: case BYTE:
return byteBuf.toString(); return byteBuf.toString();
default: default:
throw new Error(); throw new Error();
@ -78,7 +78,7 @@ public final class ChannelBufferHolder<E> {
switch (type) { switch (type) {
case MESSAGE: case MESSAGE:
return msgBuf.size(); return msgBuf.size();
case STREAM: case BYTE:
return byteBuf.readableBytes(); return byteBuf.readableBytes();
default: default:
throw new Error(); throw new Error();
@ -89,7 +89,7 @@ public final class ChannelBufferHolder<E> {
switch (type) { switch (type) {
case MESSAGE: case MESSAGE:
return msgBuf.isEmpty(); return msgBuf.isEmpty();
case STREAM: case BYTE:
return !byteBuf.readable(); return !byteBuf.readable();
default: default:
throw new Error(); throw new Error();

View File

@ -16,6 +16,6 @@
package io.netty.channel; package io.netty.channel;
public enum ChannelBufferType { public enum ChannelBufferType {
STREAM, BYTE,
MESSAGE; MESSAGE;
} }

View File

@ -18,7 +18,7 @@ package io.netty.channel;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
public class ChannelInboundStreamHandlerAdapter extends ChannelInboundHandlerAdapter<Byte> { public class ChannelInboundByteHandlerAdapter extends ChannelInboundHandlerAdapter<Byte> {
@Override @Override
public ChannelBufferHolder<Byte> newInboundBuffer(ChannelHandlerContext ctx) throws Exception { public ChannelBufferHolder<Byte> newInboundBuffer(ChannelHandlerContext ctx) throws Exception {

View File

@ -15,7 +15,7 @@
*/ */
package io.netty.channel; package io.netty.channel;
public class ChannelOutboundStreamHandlerAdapter extends ChannelOutboundHandlerAdapter<Byte> { public class ChannelOutboundByteHandlerAdapter extends ChannelOutboundHandlerAdapter<Byte> {
@Override @Override
public ChannelBufferHolder<Byte> newOutboundBuffer(ChannelHandlerContext ctx) throws Exception { public ChannelBufferHolder<Byte> newOutboundBuffer(ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.byteBuffer(); return ChannelBufferHolders.byteBuffer();

View File

@ -59,8 +59,8 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
// The content written into a bridge is flushed into the actual buffer by flushBridge(). // The content written into a bridge is flushed into the actual buffer by flushBridge().
final AtomicReference<MessageBridge> inMsgBridge; final AtomicReference<MessageBridge> inMsgBridge;
final AtomicReference<MessageBridge> outMsgBridge; final AtomicReference<MessageBridge> outMsgBridge;
final AtomicReference<StreamBridge> inByteBridge; final AtomicReference<ByteBridge> inByteBridge;
final AtomicReference<StreamBridge> outByteBridge; final AtomicReference<ByteBridge> outByteBridge;
// Runnables that calls handlers // Runnables that calls handlers
final Runnable fireChannelRegisteredTask = new Runnable() { final Runnable fireChannelRegisteredTask = new Runnable() {
@ -208,9 +208,9 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
} }
switch (holder.type()) { switch (holder.type()) {
case STREAM: case BYTE:
inByteBuf = holder.byteBuffer(); inByteBuf = holder.byteBuffer();
inByteBridge = new AtomicReference<StreamBridge>(); inByteBridge = new AtomicReference<ByteBridge>();
inMsgBuf = null; inMsgBuf = null;
inMsgBridge = null; inMsgBridge = null;
break; break;
@ -239,9 +239,9 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
} }
switch (holder.type()) { switch (holder.type()) {
case STREAM: case BYTE:
outByteBuf = holder.byteBuffer(); outByteBuf = holder.byteBuffer();
outByteBridge = new AtomicReference<StreamBridge>(); outByteBridge = new AtomicReference<ByteBridge>();
outMsgBuf = null; outMsgBuf = null;
outMsgBridge = null; outMsgBridge = null;
break; break;
@ -269,7 +269,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
bridge.fill(); bridge.fill();
} }
} else if (inByteBridge != null) { } else if (inByteBridge != null) {
StreamBridge bridge = inByteBridge.get(); ByteBridge bridge = inByteBridge.get();
if (bridge != null) { if (bridge != null) {
bridge.fill(); bridge.fill();
} }
@ -281,7 +281,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
bridge.fill(); bridge.fill();
} }
} else if (outByteBridge != null) { } else if (outByteBridge != null) {
StreamBridge bridge = outByteBridge.get(); ByteBridge bridge = outByteBridge.get();
if (bridge != null) { if (bridge != null) {
bridge.fill(); bridge.fill();
} }
@ -295,7 +295,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
bridge.flush(inMsgBuf); bridge.flush(inMsgBuf);
} }
} else if (inByteBridge != null) { } else if (inByteBridge != null) {
StreamBridge bridge = inByteBridge.get(); ByteBridge bridge = inByteBridge.get();
if (bridge != null) { if (bridge != null) {
bridge.flush(inByteBuf); bridge.flush(inByteBuf);
} }
@ -307,7 +307,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
bridge.flush(outMsgBuf); bridge.flush(outMsgBuf);
} }
} else if (outByteBridge != null) { } else if (outByteBridge != null) {
StreamBridge bridge = outByteBridge.get(); ByteBridge bridge = outByteBridge.get();
if (bridge != null) { if (bridge != null) {
bridge.flush(outByteBuf); bridge.flush(outByteBuf);
} }
@ -452,9 +452,9 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
if (ctx.executor().inEventLoop(currentThread)) { if (ctx.executor().inEventLoop(currentThread)) {
return ctx.inByteBuf; return ctx.inByteBuf;
} else { } else {
StreamBridge bridge = ctx.inByteBridge.get(); ByteBridge bridge = ctx.inByteBridge.get();
if (bridge == null) { if (bridge == null) {
bridge = new StreamBridge(); bridge = new ByteBridge();
if (!ctx.inByteBridge.compareAndSet(null, bridge)) { if (!ctx.inByteBridge.compareAndSet(null, bridge)) {
bridge = ctx.inByteBridge.get(); bridge = ctx.inByteBridge.get();
} }
@ -762,7 +762,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
} }
} }
static final class StreamBridge { static final class ByteBridge {
final ChannelBuffer byteBuf = ChannelBuffers.dynamicBuffer(); final ChannelBuffer byteBuf = ChannelBuffers.dynamicBuffer();
final BlockingQueue<ChannelBuffer> exchangeBuf = QueueFactory.createQueue(); final BlockingQueue<ChannelBuffer> exchangeBuf = QueueFactory.createQueue();

View File

@ -18,7 +18,7 @@ package io.netty.channel;
import static io.netty.channel.DefaultChannelHandlerContext.*; import static io.netty.channel.DefaultChannelHandlerContext.*;
import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffer;
import io.netty.channel.DefaultChannelHandlerContext.MessageBridge; import io.netty.channel.DefaultChannelHandlerContext.MessageBridge;
import io.netty.channel.DefaultChannelHandlerContext.StreamBridge; import io.netty.channel.DefaultChannelHandlerContext.ByteBridge;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;
@ -893,7 +893,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
@Override @Override
public ChannelBuffer inboundByteBuffer() { public ChannelBuffer inboundByteBuffer() {
if (channel.bufferType() != ChannelBufferType.STREAM) { if (channel.bufferType() != ChannelBufferType.BYTE) {
throw new NoSuchBufferException( throw new NoSuchBufferException(
"The first inbound buffer of this channel must be a byte buffer."); "The first inbound buffer of this channel must be a byte buffer.");
} }
@ -947,9 +947,9 @@ public class DefaultChannelPipeline implements ChannelPipeline {
if (ctx.executor().inEventLoop(currentThread)) { if (ctx.executor().inEventLoop(currentThread)) {
return ctx.outByteBuf; return ctx.outByteBuf;
} else { } else {
StreamBridge bridge = ctx.outByteBridge.get(); ByteBridge bridge = ctx.outByteBridge.get();
if (bridge == null) { if (bridge == null) {
bridge = new StreamBridge(); bridge = new ByteBridge();
if (!ctx.outByteBridge.compareAndSet(null, bridge)) { if (!ctx.outByteBridge.compareAndSet(null, bridge)) {
bridge = ctx.outByteBridge.get(); bridge = ctx.outByteBridge.get();
} }
@ -1434,7 +1434,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
@Override @Override
public ChannelBufferHolder newOutboundBuffer(ChannelHandlerContext ctx) throws Exception { public ChannelBufferHolder newOutboundBuffer(ChannelHandlerContext ctx) throws Exception {
switch (channel.bufferType()) { switch (channel.bufferType()) {
case STREAM: case BYTE:
return ChannelBufferHolders.byteBuffer(); return ChannelBufferHolders.byteBuffer();
case MESSAGE: case MESSAGE:
if (channel instanceof ServerChannel) { if (channel instanceof ServerChannel) {

View File

@ -83,7 +83,7 @@ public abstract class AbstractEmbeddedChannel extends AbstractChannel {
throw new IllegalArgumentException("handlers does not provide any buffers."); throw new IllegalArgumentException("handlers does not provide any buffers.");
} }
p.addLast(new LastInboundMessageHandler(), new LastInboundStreamHandler()); p.addLast(new LastInboundMessageHandler(), new LastInboundByteHandler());
loop.register(this); loop.register(this);
} }
@ -222,7 +222,7 @@ public abstract class AbstractEmbeddedChannel extends AbstractChannel {
} }
} }
private final class LastInboundStreamHandler extends ChannelInboundHandlerAdapter<Byte> { private final class LastInboundByteHandler extends ChannelInboundHandlerAdapter<Byte> {
@Override @Override
public ChannelBufferHolder<Byte> newInboundBuffer(ChannelHandlerContext ctx) throws Exception { public ChannelBufferHolder<Byte> newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
return ChannelBufferHolders.byteBuffer(lastInboundByteBuffer); return ChannelBufferHolders.byteBuffer(lastInboundByteBuffer);

View File

@ -20,15 +20,15 @@ import io.netty.buffer.ChannelBuffers;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelBufferType; import io.netty.channel.ChannelBufferType;
public class EmbeddedStreamChannel extends AbstractEmbeddedChannel { public class EmbeddedByteChannel extends AbstractEmbeddedChannel {
public EmbeddedStreamChannel(ChannelHandler... handlers) { public EmbeddedByteChannel(ChannelHandler... handlers) {
super(ChannelBuffers.dynamicBuffer(), handlers); super(ChannelBuffers.dynamicBuffer(), handlers);
} }
@Override @Override
public ChannelBufferType bufferType() { public ChannelBufferType bufferType() {
return ChannelBufferType.STREAM; return ChannelBufferType.BYTE;
} }
public ChannelBuffer inboundBuffer() { public ChannelBuffer inboundBuffer() {

View File

@ -24,24 +24,24 @@ import java.io.IOException;
import java.nio.channels.SelectableChannel; import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;
abstract class AbstractNioStreamChannel extends AbstractNioChannel { abstract class AbstractNioByteChannel extends AbstractNioChannel {
protected AbstractNioStreamChannel( protected AbstractNioByteChannel(
Channel parent, Integer id, SelectableChannel ch) { Channel parent, Integer id, SelectableChannel ch) {
super(parent, id, ch, SelectionKey.OP_READ); super(parent, id, ch, SelectionKey.OP_READ);
} }
@Override @Override
public ChannelBufferType bufferType() { public ChannelBufferType bufferType() {
return ChannelBufferType.STREAM; return ChannelBufferType.BYTE;
} }
@Override @Override
protected Unsafe newUnsafe() { protected Unsafe newUnsafe() {
return new NioStreamUnsafe(); return new NioByteUnsafe();
} }
private class NioStreamUnsafe extends AbstractNioUnsafe { private class NioByteUnsafe extends AbstractNioUnsafe {
@Override @Override
public void read() { public void read() {
assert eventLoop().inEventLoop(); assert eventLoop().inEventLoop();

View File

@ -28,7 +28,7 @@ import java.net.SocketAddress;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
public class NioSocketChannel extends AbstractNioStreamChannel implements io.netty.channel.socket.SocketChannel { public class NioSocketChannel extends AbstractNioByteChannel implements io.netty.channel.socket.SocketChannel {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(NioSocketChannel.class); private static final InternalLogger logger = InternalLoggerFactory.getInstance(NioSocketChannel.class);

View File

@ -22,23 +22,23 @@ import io.netty.channel.ChannelBufferType;
import java.io.IOException; import java.io.IOException;
abstract class AbstractOioStreamChannel extends AbstractOioChannel { abstract class AbstractOioByteChannel extends AbstractOioChannel {
protected AbstractOioStreamChannel(Channel parent, Integer id) { protected AbstractOioByteChannel(Channel parent, Integer id) {
super(parent, id); super(parent, id);
} }
@Override @Override
public ChannelBufferType bufferType() { public ChannelBufferType bufferType() {
return ChannelBufferType.STREAM; return ChannelBufferType.BYTE;
} }
@Override @Override
protected Unsafe newUnsafe() { protected Unsafe newUnsafe() {
return new OioStreamUnsafe(); return new OioByteUnsafe();
} }
private class OioStreamUnsafe extends AbstractOioUnsafe { private class OioByteUnsafe extends AbstractOioUnsafe {
@Override @Override
public void read() { public void read() {
assert eventLoop().inEventLoop(); assert eventLoop().inEventLoop();

View File

@ -32,7 +32,7 @@ import java.net.SocketAddress;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.nio.channels.NotYetConnectedException; import java.nio.channels.NotYetConnectedException;
public class OioSocketChannel extends AbstractOioStreamChannel public class OioSocketChannel extends AbstractOioByteChannel
implements SocketChannel { implements SocketChannel {
private static final InternalLogger logger = private static final InternalLogger logger =