abstract class AbstractChannelHandlerContext extends DefaultAttributeMap implements ChannelHandlerContext, ResourceLeakHint
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AbstractChannelHandlerContext.AbstractWriteTask |
(package private) static class |
AbstractChannelHandlerContext.WriteAndFlushTask |
(package private) static class |
AbstractChannelHandlerContext.WriteTask |
Modifier and Type | Field and Description |
---|---|
private static int |
ADD_COMPLETE
|
private static int |
ADD_PENDING
ChannelHandler.handlerAdded(ChannelHandlerContext) is about to be called. |
(package private) EventExecutor |
executor |
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractChannelHandlerContext> |
HANDLER_STATE_UPDATER |
private int |
handlerState |
private boolean |
inbound |
private static int |
INIT
|
private java.lang.Runnable |
invokeChannelReadCompleteTask |
private java.lang.Runnable |
invokeChannelWritableStateChangedTask |
private java.lang.Runnable |
invokeFlushTask |
private java.lang.Runnable |
invokeReadTask |
private static InternalLogger |
logger |
private java.lang.String |
name |
(package private) AbstractChannelHandlerContext |
next |
private boolean |
ordered |
private boolean |
outbound |
private DefaultChannelPipeline |
pipeline |
(package private) AbstractChannelHandlerContext |
prev |
private static int |
REMOVE_COMPLETE
|
private ChannelFuture |
succeededFuture |
Constructor and Description |
---|
AbstractChannelHandlerContext(DefaultChannelPipeline pipeline,
EventExecutor executor,
java.lang.String name,
boolean inbound,
boolean outbound) |
Modifier and Type | Method and Description |
---|---|
ByteBufAllocator |
alloc()
Return the assigned
ByteBufAllocator which will be used to allocate ByteBuf s. |
<T> Attribute<T> |
attr(AttributeKey<T> key)
Get the
Attribute for the given AttributeKey . |
ChannelFuture |
bind(java.net.SocketAddress localAddress)
Request to bind to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
bind(java.net.SocketAddress localAddress,
ChannelPromise promise)
Request to bind to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
Channel |
channel()
Return the
Channel which is bound to the ChannelHandlerContext . |
ChannelFuture |
close()
Request to close the
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 the
Channel and notify the ChannelFuture once the operation completes,
either because the operation was successful or because of
an error. |
ChannelFuture |
connect(java.net.SocketAddress remoteAddress)
Request to connect to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
connect(java.net.SocketAddress remoteAddress,
ChannelPromise promise)
Request to connect to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
connect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
Request to connect to the given
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
connect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
ChannelPromise promise)
Request to connect to the given
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
deregister()
Request to deregister from the previous assigned
EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
deregister(ChannelPromise promise)
Request to deregister from the previous assigned
EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
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. |
EventExecutor |
executor()
Returns the
EventExecutor which is used to execute an arbitrary task. |
private AbstractChannelHandlerContext |
findContextInbound() |
private AbstractChannelHandlerContext |
findContextOutbound() |
ChannelHandlerContext |
fireChannelActive()
A
Channel is active now, which means it is connected. |
ChannelHandlerContext |
fireChannelInactive()
A
Channel is inactive now, which means it is closed. |
ChannelHandlerContext |
fireChannelRead(java.lang.Object msg)
A
Channel received a message. |
ChannelHandlerContext |
fireChannelReadComplete()
Triggers an
ChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event to the next ChannelInboundHandler in the ChannelPipeline . |
ChannelHandlerContext |
fireChannelRegistered()
|
ChannelHandlerContext |
fireChannelUnregistered()
|
ChannelHandlerContext |
fireChannelWritabilityChanged()
Triggers an
ChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the next ChannelInboundHandler in the ChannelPipeline . |
ChannelHandlerContext |
fireExceptionCaught(java.lang.Throwable cause)
A
Channel received an Throwable in one of its inbound operations. |
ChannelHandlerContext |
fireUserEventTriggered(java.lang.Object event)
A
Channel received an user defined event. |
ChannelHandlerContext |
flush()
Request to flush all pending messages via this ChannelOutboundInvoker.
|
<T> boolean |
hasAttr(AttributeKey<T> key)
Returns true if and only if the given
Attribute exists in this AttributeMap . |
private static boolean |
inExceptionCaught(java.lang.Throwable cause) |
private void |
invokeBind(java.net.SocketAddress localAddress,
ChannelPromise promise) |
private void |
invokeChannelActive() |
(package private) static void |
invokeChannelActive(AbstractChannelHandlerContext next) |
private void |
invokeChannelInactive() |
(package private) static void |
invokeChannelInactive(AbstractChannelHandlerContext next) |
(package private) static void |
invokeChannelRead(AbstractChannelHandlerContext next,
java.lang.Object msg) |
private void |
invokeChannelRead(java.lang.Object msg) |
private void |
invokeChannelReadComplete() |
(package private) static void |
invokeChannelReadComplete(AbstractChannelHandlerContext next) |
private void |
invokeChannelRegistered() |
(package private) static void |
invokeChannelRegistered(AbstractChannelHandlerContext next) |
private void |
invokeChannelUnregistered() |
(package private) static void |
invokeChannelUnregistered(AbstractChannelHandlerContext next) |
private void |
invokeChannelWritabilityChanged() |
(package private) static void |
invokeChannelWritabilityChanged(AbstractChannelHandlerContext next) |
private void |
invokeClose(ChannelPromise promise) |
private void |
invokeConnect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
ChannelPromise promise) |
private void |
invokeDeregister(ChannelPromise promise) |
private void |
invokeDisconnect(ChannelPromise promise) |
(package private) static void |
invokeExceptionCaught(AbstractChannelHandlerContext next,
java.lang.Throwable cause) |
private void |
invokeExceptionCaught(java.lang.Throwable cause) |
private void |
invokeFlush() |
private void |
invokeFlush0() |
private boolean |
invokeHandler()
Makes best possible effort to detect if
ChannelHandler.handlerAdded(ChannelHandlerContext) was called
yet. |
private void |
invokeRead() |
(package private) static void |
invokeUserEventTriggered(AbstractChannelHandlerContext next,
java.lang.Object event) |
private void |
invokeUserEventTriggered(java.lang.Object event) |
private void |
invokeWrite(java.lang.Object msg,
ChannelPromise promise) |
private void |
invokeWrite0(java.lang.Object msg,
ChannelPromise promise) |
private void |
invokeWriteAndFlush(java.lang.Object msg,
ChannelPromise promise) |
private boolean |
isNotValidPromise(ChannelPromise promise,
boolean allowVoidPromise) |
boolean |
isRemoved()
Return
true if the ChannelHandler which belongs to this context was removed
from the ChannelPipeline . |
java.lang.String |
name()
The unique name of the
ChannelHandlerContext .The name was used when then ChannelHandler
was added to the ChannelPipeline . |
ChannelFuture |
newFailedFuture(java.lang.Throwable cause)
Create a new
ChannelFuture which is marked as failed already. |
ChannelProgressivePromise |
newProgressivePromise()
Return an new
ChannelProgressivePromise |
ChannelPromise |
newPromise()
Return a new
ChannelPromise . |
ChannelFuture |
newSucceededFuture()
Create a new
ChannelFuture which is marked as succeeded already. |
private void |
notifyHandlerException(java.lang.Throwable cause) |
private static void |
notifyOutboundHandlerException(java.lang.Throwable cause,
ChannelPromise promise) |
ChannelPipeline |
pipeline()
Return the assigned
ChannelPipeline |
ChannelHandlerContext |
read()
Request to Read data from the
Channel into the first inbound buffer, triggers an
ChannelInboundHandler.channelRead(ChannelHandlerContext, Object) event if data was
read, and triggers a
channelReadComplete event so the
handler can decide to continue reading. |
private static void |
safeExecute(EventExecutor executor,
java.lang.Runnable runnable,
ChannelPromise promise,
java.lang.Object msg) |
(package private) void |
setAddComplete() |
(package private) void |
setAddPending() |
(package private) void |
setRemoved() |
java.lang.String |
toHintString()
Returns a human-readable message that potentially enables easier resource leak tracking.
|
java.lang.String |
toString() |
ChannelPromise |
voidPromise()
Return a special ChannelPromise which can be reused for different operations.
|
ChannelFuture |
write(java.lang.Object msg)
Request to write a message via this
ChannelHandlerContext through the ChannelPipeline . |
private void |
write(java.lang.Object msg,
boolean flush,
ChannelPromise promise) |
ChannelFuture |
write(java.lang.Object msg,
ChannelPromise promise)
Request to write a message via this
ChannelHandlerContext through the ChannelPipeline . |
ChannelFuture |
writeAndFlush(java.lang.Object msg)
Shortcut for call
ChannelOutboundInvoker.write(Object) and ChannelOutboundInvoker.flush() . |
ChannelFuture |
writeAndFlush(java.lang.Object msg,
ChannelPromise promise)
Shortcut for call
ChannelOutboundInvoker.write(Object, ChannelPromise) and ChannelOutboundInvoker.flush() . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
handler
private static final InternalLogger logger
volatile AbstractChannelHandlerContext next
volatile AbstractChannelHandlerContext prev
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractChannelHandlerContext> HANDLER_STATE_UPDATER
private static final int ADD_PENDING
ChannelHandler.handlerAdded(ChannelHandlerContext)
is about to be called.private static final int ADD_COMPLETE
private static final int REMOVE_COMPLETE
private static final int INIT
ChannelHandler.handlerAdded(ChannelHandlerContext)
nor ChannelHandler.handlerRemoved(ChannelHandlerContext)
was called.private final boolean inbound
private final boolean outbound
private final DefaultChannelPipeline pipeline
private final java.lang.String name
private final boolean ordered
final EventExecutor executor
private ChannelFuture succeededFuture
private java.lang.Runnable invokeChannelReadCompleteTask
private java.lang.Runnable invokeReadTask
private java.lang.Runnable invokeChannelWritableStateChangedTask
private java.lang.Runnable invokeFlushTask
private volatile int handlerState
AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutor executor, java.lang.String name, boolean inbound, boolean outbound)
public Channel channel()
ChannelHandlerContext
Channel
which is bound to the ChannelHandlerContext
.channel
in interface ChannelHandlerContext
public ChannelPipeline pipeline()
ChannelHandlerContext
ChannelPipeline
pipeline
in interface ChannelHandlerContext
public ByteBufAllocator alloc()
ChannelHandlerContext
ByteBufAllocator
which will be used to allocate ByteBuf
s.alloc
in interface ChannelHandlerContext
public EventExecutor executor()
ChannelHandlerContext
EventExecutor
which is used to execute an arbitrary task.executor
in interface ChannelHandlerContext
public java.lang.String name()
ChannelHandlerContext
ChannelHandlerContext
.The name was used when then ChannelHandler
was added to the ChannelPipeline
. This name can also be used to access the registered
ChannelHandler
from the ChannelPipeline
.name
in interface ChannelHandlerContext
public ChannelHandlerContext fireChannelRegistered()
ChannelInboundInvoker
Channel
was registered to its EventLoop
.
This will result in having the ChannelInboundHandler.channelRegistered(ChannelHandlerContext)
method
called of the next ChannelInboundHandler
contained in the ChannelPipeline
of the
Channel
.fireChannelRegistered
in interface ChannelHandlerContext
fireChannelRegistered
in interface ChannelInboundInvoker
static void invokeChannelRegistered(AbstractChannelHandlerContext next)
private void invokeChannelRegistered()
public ChannelHandlerContext fireChannelUnregistered()
ChannelInboundInvoker
Channel
was unregistered from its EventLoop
.
This will result in having the ChannelInboundHandler.channelUnregistered(ChannelHandlerContext)
method
called of the next ChannelInboundHandler
contained in the ChannelPipeline
of the
Channel
.fireChannelUnregistered
in interface ChannelHandlerContext
fireChannelUnregistered
in interface ChannelInboundInvoker
static void invokeChannelUnregistered(AbstractChannelHandlerContext next)
private void invokeChannelUnregistered()
public ChannelHandlerContext fireChannelActive()
ChannelInboundInvoker
Channel
is active now, which means it is connected.
This will result in having the ChannelInboundHandler.channelActive(ChannelHandlerContext)
method
called of the next ChannelInboundHandler
contained in the ChannelPipeline
of the
Channel
.fireChannelActive
in interface ChannelHandlerContext
fireChannelActive
in interface ChannelInboundInvoker
static void invokeChannelActive(AbstractChannelHandlerContext next)
private void invokeChannelActive()
public ChannelHandlerContext fireChannelInactive()
ChannelInboundInvoker
Channel
is inactive now, which means it is closed.
This will result in having the ChannelInboundHandler.channelInactive(ChannelHandlerContext)
method
called of the next ChannelInboundHandler
contained in the ChannelPipeline
of the
Channel
.fireChannelInactive
in interface ChannelHandlerContext
fireChannelInactive
in interface ChannelInboundInvoker
static void invokeChannelInactive(AbstractChannelHandlerContext next)
private void invokeChannelInactive()
public ChannelHandlerContext fireExceptionCaught(java.lang.Throwable cause)
ChannelInboundInvoker
Channel
received an Throwable
in one of its inbound operations.
This will result in having the ChannelInboundHandler.exceptionCaught(ChannelHandlerContext, Throwable)
method called of the next ChannelInboundHandler
contained in the ChannelPipeline
of the
Channel
.fireExceptionCaught
in interface ChannelHandlerContext
fireExceptionCaught
in interface ChannelInboundInvoker
static void invokeExceptionCaught(AbstractChannelHandlerContext next, java.lang.Throwable cause)
private void invokeExceptionCaught(java.lang.Throwable cause)
public ChannelHandlerContext fireUserEventTriggered(java.lang.Object event)
ChannelInboundInvoker
Channel
received an user defined event.
This will result in having the ChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)
method called of the next ChannelInboundHandler
contained in the ChannelPipeline
of the
Channel
.fireUserEventTriggered
in interface ChannelHandlerContext
fireUserEventTriggered
in interface ChannelInboundInvoker
static void invokeUserEventTriggered(AbstractChannelHandlerContext next, java.lang.Object event)
private void invokeUserEventTriggered(java.lang.Object event)
public ChannelHandlerContext fireChannelRead(java.lang.Object msg)
ChannelInboundInvoker
Channel
received a message.
This will result in having the ChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
method called of the next ChannelInboundHandler
contained in the ChannelPipeline
of the
Channel
.fireChannelRead
in interface ChannelHandlerContext
fireChannelRead
in interface ChannelInboundInvoker
static void invokeChannelRead(AbstractChannelHandlerContext next, java.lang.Object msg)
private void invokeChannelRead(java.lang.Object msg)
public ChannelHandlerContext fireChannelReadComplete()
ChannelInboundInvoker
ChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event to the next ChannelInboundHandler
in the ChannelPipeline
.fireChannelReadComplete
in interface ChannelHandlerContext
fireChannelReadComplete
in interface ChannelInboundInvoker
static void invokeChannelReadComplete(AbstractChannelHandlerContext next)
private void invokeChannelReadComplete()
public ChannelHandlerContext fireChannelWritabilityChanged()
ChannelInboundInvoker
ChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the next ChannelInboundHandler
in the ChannelPipeline
.fireChannelWritabilityChanged
in interface ChannelHandlerContext
fireChannelWritabilityChanged
in interface ChannelInboundInvoker
static void invokeChannelWritabilityChanged(AbstractChannelHandlerContext next)
private void invokeChannelWritabilityChanged()
public ChannelFuture bind(java.net.SocketAddress localAddress)
ChannelOutboundInvoker
SocketAddress
and notify the ChannelFuture
once the operation
completes, either because the operation was successful or because of an error.
This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise)
method
called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
bind
in interface ChannelOutboundInvoker
public ChannelFuture connect(java.net.SocketAddress remoteAddress)
ChannelOutboundInvoker
SocketAddress
and notify the ChannelFuture
once the operation
completes, either because the operation was successful or because of an error.
If the connection fails because of a connection timeout, the ChannelFuture
will get failed with
a ConnectTimeoutException
. If it fails because of connection refused a ConnectException
will be used.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
connect
in interface ChannelOutboundInvoker
public ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
ChannelOutboundInvoker
SocketAddress
while bind to the localAddress and notify the
ChannelFuture
once the operation completes, either because the operation was successful or because of
an error.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
connect
in interface ChannelOutboundInvoker
public ChannelFuture disconnect()
ChannelOutboundInvoker
ChannelFuture
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 ChannelOutboundInvoker
public ChannelFuture close()
ChannelOutboundInvoker
Channel
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 ChannelOutboundInvoker
public ChannelFuture deregister()
ChannelOutboundInvoker
EventExecutor
and notify the
ChannelFuture
once the operation completes, either because the operation was successful or because of
an error.
This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
deregister
in interface ChannelOutboundInvoker
public ChannelFuture bind(java.net.SocketAddress localAddress, ChannelPromise promise)
ChannelOutboundInvoker
SocketAddress
and notify the ChannelFuture
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.bind(ChannelHandlerContext, SocketAddress, ChannelPromise)
method
called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
bind
in interface ChannelOutboundInvoker
private void invokeBind(java.net.SocketAddress localAddress, ChannelPromise promise)
public ChannelFuture connect(java.net.SocketAddress remoteAddress, ChannelPromise promise)
ChannelOutboundInvoker
SocketAddress
and notify the ChannelFuture
once the operation
completes, either because the operation was successful or because of an error.
The given ChannelFuture
will be notified.
If the connection fails because of a connection timeout, the ChannelFuture
will get failed with
a ConnectTimeoutException
. If it fails because of connection refused a ConnectException
will be used.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
connect
in interface ChannelOutboundInvoker
public ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
ChannelOutboundInvoker
SocketAddress
while bind to the localAddress and notify the
ChannelFuture
once the operation completes, either because the operation was successful or because of
an error.
The given ChannelPromise
will be notified and also returned.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
connect
in interface ChannelOutboundInvoker
private void invokeConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
public ChannelFuture disconnect(ChannelPromise promise)
ChannelOutboundInvoker
ChannelFuture
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 ChannelOutboundInvoker
private void invokeDisconnect(ChannelPromise promise)
public ChannelFuture close(ChannelPromise promise)
ChannelOutboundInvoker
Channel
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 ChannelOutboundInvoker
private void invokeClose(ChannelPromise promise)
public ChannelFuture deregister(ChannelPromise promise)
ChannelOutboundInvoker
EventExecutor
and notify the
ChannelFuture
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.deregister(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
deregister
in interface ChannelOutboundInvoker
private void invokeDeregister(ChannelPromise promise)
public ChannelHandlerContext read()
ChannelOutboundInvoker
Channel
into the first inbound buffer, triggers an
ChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
event if data was
read, and triggers a
channelReadComplete
event so the
handler can decide to continue reading. If there's a pending read operation already, this method does nothing.
This will result in having the
ChannelOutboundHandler.read(ChannelHandlerContext)
method called of the next ChannelOutboundHandler
contained in the ChannelPipeline
of the
Channel
.
read
in interface ChannelHandlerContext
read
in interface ChannelOutboundInvoker
private void invokeRead()
public ChannelFuture write(java.lang.Object msg)
ChannelOutboundInvoker
ChannelHandlerContext
through the ChannelPipeline
.
This method will not request to actual flush, so be sure to call ChannelOutboundInvoker.flush()
once you want to request to flush all pending data to the actual transport.write
in interface ChannelOutboundInvoker
public ChannelFuture write(java.lang.Object msg, ChannelPromise promise)
ChannelOutboundInvoker
ChannelHandlerContext
through the ChannelPipeline
.
This method will not request to actual flush, so be sure to call ChannelOutboundInvoker.flush()
once you want to request to flush all pending data to the actual transport.write
in interface ChannelOutboundInvoker
private void invokeWrite(java.lang.Object msg, ChannelPromise promise)
private void invokeWrite0(java.lang.Object msg, ChannelPromise promise)
public ChannelHandlerContext flush()
ChannelOutboundInvoker
flush
in interface ChannelHandlerContext
flush
in interface ChannelOutboundInvoker
private void invokeFlush()
private void invokeFlush0()
public ChannelFuture writeAndFlush(java.lang.Object msg, ChannelPromise promise)
ChannelOutboundInvoker
ChannelOutboundInvoker.write(Object, ChannelPromise)
and ChannelOutboundInvoker.flush()
.writeAndFlush
in interface ChannelOutboundInvoker
private void invokeWriteAndFlush(java.lang.Object msg, ChannelPromise promise)
private void write(java.lang.Object msg, boolean flush, ChannelPromise promise)
public ChannelFuture writeAndFlush(java.lang.Object msg)
ChannelOutboundInvoker
ChannelOutboundInvoker.write(Object)
and ChannelOutboundInvoker.flush()
.writeAndFlush
in interface ChannelOutboundInvoker
private static void notifyOutboundHandlerException(java.lang.Throwable cause, ChannelPromise promise)
private void notifyHandlerException(java.lang.Throwable cause)
private static boolean inExceptionCaught(java.lang.Throwable cause)
public ChannelPromise newPromise()
ChannelOutboundInvoker
ChannelPromise
.newPromise
in interface ChannelOutboundInvoker
public ChannelProgressivePromise newProgressivePromise()
ChannelOutboundInvoker
ChannelProgressivePromise
newProgressivePromise
in interface ChannelOutboundInvoker
public ChannelFuture newSucceededFuture()
ChannelOutboundInvoker
ChannelFuture
which is marked as succeeded already. So Future.isSuccess()
will return true
. All FutureListener
added to it will be notified directly. Also
every call of blocking methods will just return without blocking.newSucceededFuture
in interface ChannelOutboundInvoker
public ChannelFuture newFailedFuture(java.lang.Throwable cause)
ChannelOutboundInvoker
ChannelFuture
which is marked as failed already. So Future.isSuccess()
will return false
. All FutureListener
added to it will be notified directly. Also
every call of blocking methods will just return without blocking.newFailedFuture
in interface ChannelOutboundInvoker
private boolean isNotValidPromise(ChannelPromise promise, boolean allowVoidPromise)
private AbstractChannelHandlerContext findContextInbound()
private AbstractChannelHandlerContext findContextOutbound()
public ChannelPromise voidPromise()
ChannelOutboundInvoker
It's only supported to use
it for ChannelOutboundInvoker.write(Object, ChannelPromise)
.
Be aware that the returned ChannelPromise
will not support most operations and should only be used
if you want to save an object allocation for every write operation. You will not be able to detect if the
operation was complete, only if it failed as the implementation will call
ChannelPipeline.fireExceptionCaught(Throwable)
in this case.
voidPromise
in interface ChannelOutboundInvoker
final void setRemoved()
final void setAddComplete()
final void setAddPending()
private boolean invokeHandler()
ChannelHandler.handlerAdded(ChannelHandlerContext)
was called
yet. If not return false
and if called or could not detect return true
.
If this method returns false
we will not invoke the ChannelHandler
but just forward the event.
This is needed as DefaultChannelPipeline
may already put the ChannelHandler
in the linked-list
but not called ChannelHandler.handlerAdded(ChannelHandlerContext)
.public boolean isRemoved()
ChannelHandlerContext
true
if the ChannelHandler
which belongs to this context was removed
from the ChannelPipeline
. Note that this method is only meant to be called from with in the
EventLoop
.isRemoved
in interface ChannelHandlerContext
public <T> Attribute<T> attr(AttributeKey<T> key)
AttributeMap
Attribute
for the given AttributeKey
. This method will never return null, but may return
an Attribute
which does not have a value set yet.attr
in interface ChannelHandlerContext
attr
in interface AttributeMap
attr
in class DefaultAttributeMap
public <T> boolean hasAttr(AttributeKey<T> key)
AttributeMap
Attribute
exists in this AttributeMap
.hasAttr
in interface ChannelHandlerContext
hasAttr
in interface AttributeMap
hasAttr
in class DefaultAttributeMap
private static void safeExecute(EventExecutor executor, java.lang.Runnable runnable, ChannelPromise promise, java.lang.Object msg)
public java.lang.String toHintString()
ResourceLeakHint
toHintString
in interface ResourceLeakHint
public java.lang.String toString()
toString
in class java.lang.Object