public class EmbeddedChannel extends AbstractChannel
Channel
implementations that are used in an embedded fashion.AbstractChannel.AbstractUnsafe
Channel.Unsafe
Constructor and Description |
---|
EmbeddedChannel()
Create a new instance with an empty pipeline.
|
EmbeddedChannel(ChannelHandler... handlers)
Create a new instance with the pipeline initialized with the specified handlers.
|
Modifier and Type | Method and Description |
---|---|
void |
checkException()
Check if there was any
Throwable received and if so rethrow it. |
ChannelConfig |
config()
Returns the configuration of this channel.
|
protected void |
doBeginRead()
Schedule a read operation.
|
protected void |
doBind(SocketAddress localAddress)
Bind the
Channel to the SocketAddress |
protected void |
doClose()
Close the
Channel |
protected void |
doDisconnect()
Disconnect this
Channel from its remote peer |
protected void |
doRegister()
|
protected void |
doWrite(ChannelOutboundBuffer in)
Flush the content of the given buffer to the remote peer.
|
protected void |
ensureOpen()
Ensure the
Channel is open and of not throw an exception. |
boolean |
finish()
Mark this
Channel as finished. |
Queue<Object> |
inboundMessages()
|
boolean |
isActive()
Return
true if the Channel is active and so connected. |
protected boolean |
isCompatible(EventLoop loop)
Return
true if the given EventLoop is compatible with this instance. |
boolean |
isOpen()
Returns
true if the Channel is open an may get active later |
Queue<Object> |
lastInboundBuffer()
Deprecated.
|
Queue<Object> |
lastOutboundBuffer()
Deprecated.
|
protected SocketAddress |
localAddress0()
Returns the
SocketAddress which is bound locally. |
ChannelMetadata |
metadata()
|
protected AbstractChannel.AbstractUnsafe |
newUnsafe()
Create a new
AbstractChannel.AbstractUnsafe instance which will be used for the life-time of the Channel |
Queue<Object> |
outboundMessages()
|
<T> T |
readInbound()
Return received data from this
Channel |
<T> T |
readOutbound()
Read data froum the outbound.
|
protected SocketAddress |
remoteAddress0()
Return the
SocketAddress which the Channel is connected to. |
void |
runPendingTasks()
|
long |
runScheduledPendingTasks()
|
boolean |
writeInbound(Object... msgs)
Write messages to the inbound of this
Channel . |
boolean |
writeOutbound(Object... msgs)
Write messages to the outbound of this
Channel . |
alloc, bind, bind, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doDeregister, equals, eventLoop, filterOutboundMessage, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, toString, unsafe, voidPromise, write, write, writeAndFlush, writeAndFlush
attr, hasAttr
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
attr, hasAttr
public EmbeddedChannel()
public EmbeddedChannel(ChannelHandler... handlers)
handlers
- the @link ChannelHandler}s which will be add in the ChannelPipeline
public ChannelMetadata metadata()
Channel
public ChannelConfig config()
Channel
public boolean isOpen()
Channel
true
if the Channel
is open an may get active laterpublic boolean isActive()
Channel
true
if the Channel
is active and so connected.@Deprecated public Queue<Object> lastInboundBuffer()
inboundMessages()
@Deprecated public Queue<Object> lastOutboundBuffer()
outboundMessages()
public <T> T readInbound()
Channel
public <T> T readOutbound()
null
if nothing is readable.public boolean writeInbound(Object... msgs)
Channel
.msgs
- the messages to be writtentrue
if the write operation did add something to the inbound bufferpublic boolean writeOutbound(Object... msgs)
Channel
.msgs
- the messages to be writtentrue
if the write operation did add something to the outbound bufferpublic boolean finish()
Channel
as finished. Any futher try to write data to it will fail.true
if any of the used buffers has something left to readpublic void runPendingTasks()
public long runScheduledPendingTasks()
public void checkException()
Throwable
received and if so rethrow it.protected final void ensureOpen()
Channel
is open and of not throw an exception.protected boolean isCompatible(EventLoop loop)
AbstractChannel
true
if the given EventLoop
is compatible with this instance.isCompatible
in class AbstractChannel
protected SocketAddress localAddress0()
AbstractChannel
SocketAddress
which is bound locally.localAddress0
in class AbstractChannel
protected SocketAddress remoteAddress0()
AbstractChannel
SocketAddress
which the Channel
is connected to.remoteAddress0
in class AbstractChannel
protected void doRegister() throws Exception
AbstractChannel
Channel
is registered with its EventLoop
as part of the register process.
Sub-classes may override this methoddoRegister
in class AbstractChannel
Exception
protected void doBind(SocketAddress localAddress) throws Exception
AbstractChannel
Channel
to the SocketAddress
doBind
in class AbstractChannel
Exception
protected void doDisconnect() throws Exception
AbstractChannel
Channel
from its remote peerdoDisconnect
in class AbstractChannel
Exception
protected void doClose() throws Exception
AbstractChannel
Channel
doClose
in class AbstractChannel
Exception
protected void doBeginRead() throws Exception
AbstractChannel
doBeginRead
in class AbstractChannel
Exception
protected AbstractChannel.AbstractUnsafe newUnsafe()
AbstractChannel
AbstractChannel.AbstractUnsafe
instance which will be used for the life-time of the Channel
newUnsafe
in class AbstractChannel
protected void doWrite(ChannelOutboundBuffer in) throws Exception
AbstractChannel
doWrite
in class AbstractChannel
Exception
Copyright © 2008–2015 The Netty Project. All rights reserved.