public class EmbeddedChannel extends AbstractChannel
Channel implementations that are used in an embedded fashion.AbstractChannel.AbstractUnsafeChannel.Unsafe| Constructor and Description |
|---|
EmbeddedChannel(boolean register,
boolean hasDisconnect,
ChannelHandler... handlers)
Create a new instance with the pipeline initialized with the specified handlers.
|
EmbeddedChannel(boolean hasDisconnect,
ChannelConfig config,
ChannelHandler... handlers)
Create a new instance with the channel ID set to the given ID and the pipeline
initialized with the specified handlers.
|
EmbeddedChannel(boolean hasDisconnect,
ChannelHandler... handlers)
Create a new instance with the channel ID set to the given ID and the pipeline
initialized with the specified handlers.
|
EmbeddedChannel(ChannelHandler... handlers)
Create a new instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkException()
Check if there was any
Throwable received and if so rethrow it. |
ChannelFuture |
close()
Request to close this
Channel and notify the ChannelFuture once the operation completes,
either because the operation was successful or because of
an error. |
ChannelFuture |
close(ChannelPromise promise)
Request to close this
Channel and notify the ChannelFuture once the operation completes,
either because the operation was successful or because of
an error. |
ChannelConfig |
config()
Returns the configuration of this channel.
|
ChannelFuture |
disconnect()
Request to disconnect from the remote peer and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of an error. |
ChannelFuture |
disconnect(ChannelPromise promise)
Request to disconnect from the remote peer and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of an error. |
protected void |
doBeginRead()
Schedule a read operation.
|
protected void |
doBind(java.net.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 if not throw an exception. |
boolean |
finish()
Mark this
Channel as finished. |
boolean |
finishAndReleaseAll()
Mark this
Channel as finished and release all pending message in the inbound and outbound buffer. |
java.util.Queue<java.lang.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 and may get active later |
java.util.Queue<java.lang.Object> |
lastInboundBuffer()
Deprecated.
|
java.util.Queue<java.lang.Object> |
lastOutboundBuffer()
Deprecated.
|
protected java.net.SocketAddress |
localAddress0()
Returns the
SocketAddress which is bound locally. |
ChannelMetadata |
metadata()
|
protected DefaultChannelPipeline |
newChannelPipeline()
Returns a new
DefaultChannelPipeline instance. |
protected AbstractChannel.AbstractUnsafe |
newUnsafe()
Create a new
AbstractChannel.AbstractUnsafe instance which will be used for the life-time of the Channel |
java.util.Queue<java.lang.Object> |
outboundMessages()
|
java.lang.Object |
readInbound()
Return received data from this
Channel |
java.lang.Object |
readOutbound()
Read data from the outbound.
|
void |
register()
Register this
Channel on its EventLoop. |
boolean |
releaseInbound()
Release all buffered inbound messages and return
true if any were in the inbound buffer, false
otherwise. |
boolean |
releaseOutbound()
Release all buffered outbound messages and return
true if any were in the outbound buffer, false
otherwise. |
protected java.net.SocketAddress |
remoteAddress0()
Return the
SocketAddress which the Channel is connected to. |
void |
runPendingTasks()
|
long |
runScheduledPendingTasks()
|
Channel.Unsafe |
unsafe()
Returns an internal-use-only object that provides unsafe operations.
|
boolean |
writeInbound(java.lang.Object... msgs)
Write messages to the inbound of this
Channel. |
boolean |
writeOutbound(java.lang.Object... msgs)
Write messages to the outbound of this
Channel. |
alloc, bind, bind, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, doDeregister, doShutdownOutput, equals, eventLoop, filterOutboundMessage, flush, hashCode, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, toString, voidPromise, write, write, writeAndFlush, writeAndFlushattrclone, finalize, getClass, notify, notifyAll, wait, wait, waitattrpublic EmbeddedChannel(ChannelHandler... handlers)
handlers - the @link ChannelHandler}s which will be add in the ChannelPipelinepublic EmbeddedChannel(boolean hasDisconnect,
ChannelHandler... handlers)
hasDisconnect - false if this Channel will delegate disconnect()
to close(), false otherwise.handlers - the ChannelHandlers which will be add in the ChannelPipelinepublic EmbeddedChannel(boolean register,
boolean hasDisconnect,
ChannelHandler... handlers)
register - true if this Channel is registered to the EventLoop in the
constructor. If false the user will need to call register().hasDisconnect - false if this Channel will delegate disconnect()
to close(), false otherwise.handlers - the ChannelHandlers which will be add in the ChannelPipelinepublic EmbeddedChannel(boolean hasDisconnect,
ChannelConfig config,
ChannelHandler... handlers)
hasDisconnect - false if this Channel will delegate disconnect()
to close(), false otherwise.config - the ChannelConfig which will be returned by config().handlers - the ChannelHandlers which will be add in the ChannelPipelinepublic void register()
throws java.lang.Exception
Channel on its EventLoop.java.lang.Exceptionprotected final DefaultChannelPipeline newChannelPipeline()
AbstractChannelDefaultChannelPipeline instance.newChannelPipeline in class AbstractChannelpublic ChannelMetadata metadata()
Channelpublic ChannelConfig config()
Channelpublic boolean isOpen()
Channeltrue if the Channel is open and may get active laterpublic boolean isActive()
Channeltrue if the Channel is active and so connected.public java.util.Queue<java.lang.Object> inboundMessages()
@Deprecated public java.util.Queue<java.lang.Object> lastInboundBuffer()
inboundMessages()public java.util.Queue<java.lang.Object> outboundMessages()
@Deprecated public java.util.Queue<java.lang.Object> lastOutboundBuffer()
outboundMessages()public java.lang.Object readInbound()
Channelpublic java.lang.Object readOutbound()
null if nothing is readable.public boolean writeInbound(java.lang.Object... msgs)
Channel.msgs - the messages to be writtentrue if the write operation did add something to the inbound bufferpublic boolean writeOutbound(java.lang.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 boolean finishAndReleaseAll()
Channel as finished and release all pending message in the inbound and outbound buffer.
Any further try to write data to it will fail.true if any of the used buffers has something left to readpublic boolean releaseInbound()
true if any were in the inbound buffer, false
otherwise.public boolean releaseOutbound()
true if any were in the outbound buffer, false
otherwise.public final ChannelFuture close()
ChannelChannel and notify the ChannelFuture once the operation completes,
either because the operation was successful or because of
an error.
After it is closed it is not possible to reuse it again.
This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
close in interface Channelclose in class AbstractChannelpublic final ChannelFuture disconnect()
ChannelChannelFuture once the operation completes,
either because the operation was successful or because of an error.
This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
disconnect in interface Channeldisconnect in class AbstractChannelpublic final ChannelFuture close(ChannelPromise promise)
ChannelChannel and notify the ChannelFuture once the operation completes,
either because the operation was successful or because of
an error.
After it is closed it is not possible to reuse it again.
The given ChannelPromise will be notified.
This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
close in interface Channelclose in class AbstractChannelpublic final ChannelFuture disconnect(ChannelPromise promise)
ChannelChannelFuture once the operation completes,
either because the operation was successful or because of an error.
The given ChannelPromise will be notified.
This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
disconnect in interface Channeldisconnect in class AbstractChannelpublic void runPendingTasks()
public long runScheduledPendingTasks()
public void checkException()
Throwable received and if so rethrow it.protected final void ensureOpen()
Channel is open and if not throw an exception.protected boolean isCompatible(EventLoop loop)
AbstractChanneltrue if the given EventLoop is compatible with this instance.isCompatible in class AbstractChannelprotected java.net.SocketAddress localAddress0()
AbstractChannelSocketAddress which is bound locally.localAddress0 in class AbstractChannelprotected java.net.SocketAddress remoteAddress0()
AbstractChannelSocketAddress which the Channel is connected to.remoteAddress0 in class AbstractChannelprotected void doRegister()
throws java.lang.Exception
AbstractChannelChannel is registered with its EventLoop as part of the register process.
Sub-classes may override this methoddoRegister in class AbstractChanneljava.lang.Exceptionprotected void doBind(java.net.SocketAddress localAddress)
throws java.lang.Exception
AbstractChannelChannel to the SocketAddressdoBind in class AbstractChanneljava.lang.Exceptionprotected void doDisconnect()
throws java.lang.Exception
AbstractChannelChannel from its remote peerdoDisconnect in class AbstractChanneljava.lang.Exceptionprotected void doClose()
throws java.lang.Exception
AbstractChannelChanneldoClose in class AbstractChanneljava.lang.Exceptionprotected void doBeginRead()
throws java.lang.Exception
AbstractChanneldoBeginRead in class AbstractChanneljava.lang.Exceptionprotected AbstractChannel.AbstractUnsafe newUnsafe()
AbstractChannelAbstractChannel.AbstractUnsafe instance which will be used for the life-time of the ChannelnewUnsafe in class AbstractChannelpublic Channel.Unsafe unsafe()
Channelunsafe in interface Channelunsafe in class AbstractChannelprotected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
AbstractChanneldoWrite in class AbstractChanneljava.lang.ExceptionCopyright © 2008–2018 The Netty Project. All rights reserved.