Rename methods of EmbeddedChannel and mark old ones as @deprecated

This commit is contained in:
Norman Maurer 2013-07-29 21:17:03 +02:00 committed by Trustin Lee
parent d4b8f16d1f
commit e09aea5902
2 changed files with 32 additions and 17 deletions

View File

@ -42,7 +42,6 @@ public class WebSocketFrameAggregatorTest {
Assert.assertTrue(channel.finish());
System.out.println(channel.lastInboundBuffer().size());
BinaryWebSocketFrame frame = (BinaryWebSocketFrame) channel.readInbound();
Assert.assertTrue(frame.isFinalFragment());
Assert.assertEquals(1, frame.rsv());

View File

@ -52,8 +52,8 @@ public class EmbeddedChannel extends AbstractChannel {
private final ChannelConfig config = new DefaultChannelConfig(this);
private final SocketAddress localAddress = new EmbeddedSocketAddress();
private final SocketAddress remoteAddress = new EmbeddedSocketAddress();
private final Queue<Object> lastInboundBuffer = new ArrayDeque<Object>();
private final Queue<Object> lastOutboundBuffer = new ArrayDeque<Object>();
private final Queue<Object> inboundMessages = new ArrayDeque<Object>();
private final Queue<Object> outboundMessages = new ArrayDeque<Object>();
private Throwable lastException;
private int state; // 0 = OPEN, 1 = ACTIVE, 2 = CLOSED
@ -108,31 +108,47 @@ public class EmbeddedChannel extends AbstractChannel {
}
/**
* Returns the buffer which holds all the {@link Object}s that were received by this {@link Channel}.
* Returns the {@link Queue} which holds all the {@link Object}s that were received by this {@link Channel}.
*/
public Queue<Object> lastInboundBuffer() {
return lastInboundBuffer;
public Queue<Object> inboundMessages() {
return inboundMessages;
}
/**
* Returns the buffer which holds all the {@link Object}s that were written by this {@link Channel}.
* @deprecated use {@link #inboundMessages()}
*/
@Deprecated
public Queue<Object> lastInboundBuffer() {
return inboundMessages();
}
/**
* Returns the {@link Queue} which holds all the {@link Object}s that were written by this {@link Channel}.
*/
public Queue<Object> outboundMessages() {
return outboundMessages;
}
/**
* @deprecated use {@link #outboundMessages()}
*/
@Deprecated
public Queue<Object> lastOutboundBuffer() {
return lastOutboundBuffer;
return outboundMessages();
}
/**
* Return received data from this {@link Channel}
*/
public Object readInbound() {
return lastInboundBuffer.poll();
return inboundMessages.poll();
}
/**
* Read data froum the outbound. This may return {@code null} if nothing is readable.
*/
public Object readOutbound() {
return lastOutboundBuffer.poll();
return outboundMessages.poll();
}
/**
@ -145,7 +161,7 @@ public class EmbeddedChannel extends AbstractChannel {
public boolean writeInbound(Object... msgs) {
ensureOpen();
if (msgs.length == 0) {
return !lastInboundBuffer.isEmpty();
return !inboundMessages.isEmpty();
}
ChannelPipeline p = pipeline();
@ -155,7 +171,7 @@ public class EmbeddedChannel extends AbstractChannel {
p.fireChannelReadComplete();
runPendingTasks();
checkException();
return !lastInboundBuffer.isEmpty();
return !inboundMessages.isEmpty();
}
/**
@ -167,7 +183,7 @@ public class EmbeddedChannel extends AbstractChannel {
public boolean writeOutbound(Object... msgs) {
ensureOpen();
if (msgs.length == 0) {
return !lastOutboundBuffer.isEmpty();
return !outboundMessages.isEmpty();
}
RecyclableArrayList futures = RecyclableArrayList.newInstance(msgs.length);
@ -191,7 +207,7 @@ public class EmbeddedChannel extends AbstractChannel {
runPendingTasks();
checkException();
return !lastOutboundBuffer.isEmpty();
return !outboundMessages.isEmpty();
} finally {
futures.recycle();
}
@ -207,7 +223,7 @@ public class EmbeddedChannel extends AbstractChannel {
close();
runPendingTasks();
checkException();
return !lastInboundBuffer.isEmpty() || !lastOutboundBuffer.isEmpty();
return !inboundMessages.isEmpty() || !outboundMessages.isEmpty();
}
/**
@ -309,7 +325,7 @@ public class EmbeddedChannel extends AbstractChannel {
}
ReferenceCountUtil.retain(msg);
lastOutboundBuffer.add(msg);
outboundMessages.add(msg);
in.remove();
}
}
@ -324,7 +340,7 @@ public class EmbeddedChannel extends AbstractChannel {
private final class LastInboundHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
lastInboundBuffer.add(msg);
inboundMessages.add(msg);
}
@Override