Class AbstractChannelHandlerContext
- java.lang.Object
-
- io.netty.channel.AbstractChannelHandlerContext
-
- All Implemented Interfaces:
ChannelHandlerContext
,ChannelInboundInvoker
,ChannelOutboundInvoker
,AttributeMap
,ResourceLeakHint
- Direct Known Subclasses:
DefaultChannelHandlerContext
,DefaultChannelPipeline.HeadContext
,DefaultChannelPipeline.TailContext
abstract class AbstractChannelHandlerContext extends java.lang.Object implements ChannelHandlerContext, ResourceLeakHint
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AbstractChannelHandlerContext.Tasks
(package private) static class
AbstractChannelHandlerContext.WriteTask
-
Field Summary
Fields Modifier and Type Field Description private static int
ADD_COMPLETE
private static int
ADD_PENDING
ChannelHandler.handlerAdded(ChannelHandlerContext)
is about to be called.private int
executionMask
(package private) EventExecutor
executor
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractChannelHandlerContext>
HANDLER_STATE_UPDATER
private int
handlerState
private static int
INIT
private AbstractChannelHandlerContext.Tasks
invokeTasks
private static InternalLogger
logger
private java.lang.String
name
(package private) AbstractChannelHandlerContext
next
private boolean
ordered
private DefaultChannelPipeline
pipeline
(package private) AbstractChannelHandlerContext
prev
private static int
REMOVE_COMPLETE
private ChannelFuture
succeededFuture
-
Constructor Summary
Constructors Constructor Description AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutor executor, java.lang.String name, java.lang.Class<? extends ChannelHandler> handlerClass)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufAllocator
alloc()
Return the assignedByteBufAllocator
which will be used to allocateByteBuf
s.<T> Attribute<T>
attr(AttributeKey<T> key)
Get theAttribute
for the givenAttributeKey
.ChannelFuture
bind(java.net.SocketAddress localAddress)
Request to bind to the givenSocketAddress
and notify theChannelFuture
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 givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.(package private) void
callHandlerAdded()
(package private) void
callHandlerRemoved()
Channel
channel()
Return theChannel
which is bound to theChannelHandlerContext
.ChannelFuture
close()
Request to close theChannel
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.ChannelFuture
close(ChannelPromise promise)
Request to close theChannel
and notify theChannelFuture
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 givenSocketAddress
and notify theChannelFuture
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 givenSocketAddress
and notify theChannelFuture
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 givenSocketAddress
while bind to the localAddress and notify theChannelFuture
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 givenSocketAddress
while bind to the localAddress and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.ChannelFuture
deregister()
Request to deregister from the previous assignedEventExecutor
and notify theChannelFuture
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 assignedEventExecutor
and notify theChannelFuture
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 theChannelFuture
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 theChannelFuture
once the operation completes, either because the operation was successful or because of an error.EventExecutor
executor()
Returns theEventExecutor
which is used to execute an arbitrary task.private AbstractChannelHandlerContext
findContextInbound(int mask)
private AbstractChannelHandlerContext
findContextOutbound(int mask)
ChannelHandlerContext
fireChannelActive()
AChannel
is active now, which means it is connected.ChannelHandlerContext
fireChannelInactive()
AChannel
is inactive now, which means it is closed.ChannelHandlerContext
fireChannelRead(java.lang.Object msg)
AChannel
received a message.ChannelHandlerContext
fireChannelReadComplete()
Triggers anChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.ChannelHandlerContext
fireChannelRegistered()
ChannelHandlerContext
fireChannelUnregistered()
ChannelHandlerContext
fireChannelWritabilityChanged()
Triggers anChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.ChannelHandlerContext
fireExceptionCaught(java.lang.Throwable cause)
AChannel
received anThrowable
in one of its inbound operations.ChannelHandlerContext
fireUserEventTriggered(java.lang.Object event)
AChannel
received an user defined event.ChannelHandlerContext
flush()
Request to flush all pending messages via this ChannelOutboundInvoker.<T> boolean
hasAttr(AttributeKey<T> key)
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 ifChannelHandler.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)
(package private) void
invokeWrite(java.lang.Object msg, ChannelPromise promise)
private void
invokeWrite0(java.lang.Object msg, ChannelPromise promise)
(package private) void
invokeWriteAndFlush(java.lang.Object msg, ChannelPromise promise)
private boolean
isNotValidPromise(ChannelPromise promise, boolean allowVoidPromise)
boolean
isRemoved()
Returntrue
if theChannelHandler
which belongs to this context was removed from theChannelPipeline
.java.lang.String
name()
The unique name of theChannelHandlerContext
.The name was used when thenChannelHandler
was added to theChannelPipeline
.ChannelFuture
newFailedFuture(java.lang.Throwable cause)
Create a newChannelFuture
which is marked as failed already.ChannelProgressivePromise
newProgressivePromise()
Return an newChannelProgressivePromise
ChannelPromise
newPromise()
Return a newChannelPromise
.ChannelFuture
newSucceededFuture()
Create a newChannelFuture
which is marked as succeeded already.private static void
notifyOutboundHandlerException(java.lang.Throwable cause, ChannelPromise promise)
ChannelPipeline
pipeline()
Return the assignedChannelPipeline
ChannelHandlerContext
read()
Request to Read data from theChannel
into the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
event if data was read, and triggers achannelReadComplete
event so the handler can decide to continue reading.private static boolean
safeExecute(EventExecutor executor, java.lang.Runnable runnable, ChannelPromise promise, java.lang.Object msg, boolean lazy)
(package private) boolean
setAddComplete()
(package private) void
setAddPending()
(package private) void
setRemoved()
private static boolean
skipContext(AbstractChannelHandlerContext ctx, EventExecutor currentExecutor, int mask, int onlyMask)
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 thisChannelHandlerContext
through theChannelPipeline
.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 thisChannelHandlerContext
through theChannelPipeline
.ChannelFuture
writeAndFlush(java.lang.Object msg)
Shortcut for callChannelOutboundInvoker.write(Object)
andChannelOutboundInvoker.flush()
.ChannelFuture
writeAndFlush(java.lang.Object msg, ChannelPromise promise)
Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)
andChannelOutboundInvoker.flush()
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandlerContext
handler
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
next
volatile AbstractChannelHandlerContext next
-
prev
volatile AbstractChannelHandlerContext prev
-
HANDLER_STATE_UPDATER
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractChannelHandlerContext> HANDLER_STATE_UPDATER
-
ADD_PENDING
private static final int ADD_PENDING
ChannelHandler.handlerAdded(ChannelHandlerContext)
is about to be called.- See Also:
- Constant Field Values
-
ADD_COMPLETE
private static final int ADD_COMPLETE
- See Also:
- Constant Field Values
-
REMOVE_COMPLETE
private static final int REMOVE_COMPLETE
- See Also:
- Constant Field Values
-
INIT
private static final int INIT
NeitherChannelHandler.handlerAdded(ChannelHandlerContext)
norChannelHandler.handlerRemoved(ChannelHandlerContext)
was called.- See Also:
- Constant Field Values
-
pipeline
private final DefaultChannelPipeline pipeline
-
name
private final java.lang.String name
-
ordered
private final boolean ordered
-
executionMask
private final int executionMask
-
executor
final EventExecutor executor
-
succeededFuture
private ChannelFuture succeededFuture
-
invokeTasks
private AbstractChannelHandlerContext.Tasks invokeTasks
-
handlerState
private volatile int handlerState
-
-
Constructor Detail
-
AbstractChannelHandlerContext
AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutor executor, java.lang.String name, java.lang.Class<? extends ChannelHandler> handlerClass)
-
-
Method Detail
-
channel
public Channel channel()
Description copied from interface:ChannelHandlerContext
Return theChannel
which is bound to theChannelHandlerContext
.- Specified by:
channel
in interfaceChannelHandlerContext
-
pipeline
public ChannelPipeline pipeline()
Description copied from interface:ChannelHandlerContext
Return the assignedChannelPipeline
- Specified by:
pipeline
in interfaceChannelHandlerContext
-
alloc
public ByteBufAllocator alloc()
Description copied from interface:ChannelHandlerContext
Return the assignedByteBufAllocator
which will be used to allocateByteBuf
s.- Specified by:
alloc
in interfaceChannelHandlerContext
-
executor
public EventExecutor executor()
Description copied from interface:ChannelHandlerContext
Returns theEventExecutor
which is used to execute an arbitrary task.- Specified by:
executor
in interfaceChannelHandlerContext
-
name
public java.lang.String name()
Description copied from interface:ChannelHandlerContext
The unique name of theChannelHandlerContext
.The name was used when thenChannelHandler
was added to theChannelPipeline
. This name can also be used to access the registeredChannelHandler
from theChannelPipeline
.- Specified by:
name
in interfaceChannelHandlerContext
-
fireChannelRegistered
public ChannelHandlerContext fireChannelRegistered()
Description copied from interface:ChannelInboundInvoker
AChannel
was registered to itsEventLoop
. This will result in having theChannelInboundHandler.channelRegistered(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelRegistered
in interfaceChannelHandlerContext
- Specified by:
fireChannelRegistered
in interfaceChannelInboundInvoker
-
invokeChannelRegistered
static void invokeChannelRegistered(AbstractChannelHandlerContext next)
-
invokeChannelRegistered
private void invokeChannelRegistered()
-
fireChannelUnregistered
public ChannelHandlerContext fireChannelUnregistered()
Description copied from interface:ChannelInboundInvoker
AChannel
was unregistered from itsEventLoop
. This will result in having theChannelInboundHandler.channelUnregistered(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelUnregistered
in interfaceChannelHandlerContext
- Specified by:
fireChannelUnregistered
in interfaceChannelInboundInvoker
-
invokeChannelUnregistered
static void invokeChannelUnregistered(AbstractChannelHandlerContext next)
-
invokeChannelUnregistered
private void invokeChannelUnregistered()
-
fireChannelActive
public ChannelHandlerContext fireChannelActive()
Description copied from interface:ChannelInboundInvoker
AChannel
is active now, which means it is connected. This will result in having theChannelInboundHandler.channelActive(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelActive
in interfaceChannelHandlerContext
- Specified by:
fireChannelActive
in interfaceChannelInboundInvoker
-
invokeChannelActive
static void invokeChannelActive(AbstractChannelHandlerContext next)
-
invokeChannelActive
private void invokeChannelActive()
-
fireChannelInactive
public ChannelHandlerContext fireChannelInactive()
Description copied from interface:ChannelInboundInvoker
AChannel
is inactive now, which means it is closed. This will result in having theChannelInboundHandler.channelInactive(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelInactive
in interfaceChannelHandlerContext
- Specified by:
fireChannelInactive
in interfaceChannelInboundInvoker
-
invokeChannelInactive
static void invokeChannelInactive(AbstractChannelHandlerContext next)
-
invokeChannelInactive
private void invokeChannelInactive()
-
fireExceptionCaught
public ChannelHandlerContext fireExceptionCaught(java.lang.Throwable cause)
Description copied from interface:ChannelInboundInvoker
AChannel
received anThrowable
in one of its inbound operations. This will result in having theChannelInboundHandler.exceptionCaught(ChannelHandlerContext, Throwable)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireExceptionCaught
in interfaceChannelHandlerContext
- Specified by:
fireExceptionCaught
in interfaceChannelInboundInvoker
-
invokeExceptionCaught
static void invokeExceptionCaught(AbstractChannelHandlerContext next, java.lang.Throwable cause)
-
invokeExceptionCaught
private void invokeExceptionCaught(java.lang.Throwable cause)
-
fireUserEventTriggered
public ChannelHandlerContext fireUserEventTriggered(java.lang.Object event)
Description copied from interface:ChannelInboundInvoker
AChannel
received an user defined event. This will result in having theChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireUserEventTriggered
in interfaceChannelHandlerContext
- Specified by:
fireUserEventTriggered
in interfaceChannelInboundInvoker
-
invokeUserEventTriggered
static void invokeUserEventTriggered(AbstractChannelHandlerContext next, java.lang.Object event)
-
invokeUserEventTriggered
private void invokeUserEventTriggered(java.lang.Object event)
-
fireChannelRead
public ChannelHandlerContext fireChannelRead(java.lang.Object msg)
Description copied from interface:ChannelInboundInvoker
AChannel
received a message. This will result in having theChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelRead
in interfaceChannelHandlerContext
- Specified by:
fireChannelRead
in interfaceChannelInboundInvoker
-
invokeChannelRead
static void invokeChannelRead(AbstractChannelHandlerContext next, java.lang.Object msg)
-
invokeChannelRead
private void invokeChannelRead(java.lang.Object msg)
-
fireChannelReadComplete
public ChannelHandlerContext fireChannelReadComplete()
Description copied from interface:ChannelInboundInvoker
Triggers anChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.- Specified by:
fireChannelReadComplete
in interfaceChannelHandlerContext
- Specified by:
fireChannelReadComplete
in interfaceChannelInboundInvoker
-
invokeChannelReadComplete
static void invokeChannelReadComplete(AbstractChannelHandlerContext next)
-
invokeChannelReadComplete
private void invokeChannelReadComplete()
-
fireChannelWritabilityChanged
public ChannelHandlerContext fireChannelWritabilityChanged()
Description copied from interface:ChannelInboundInvoker
Triggers anChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.- Specified by:
fireChannelWritabilityChanged
in interfaceChannelHandlerContext
- Specified by:
fireChannelWritabilityChanged
in interfaceChannelInboundInvoker
-
invokeChannelWritabilityChanged
static void invokeChannelWritabilityChanged(AbstractChannelHandlerContext next)
-
invokeChannelWritabilityChanged
private void invokeChannelWritabilityChanged()
-
bind
public ChannelFuture bind(java.net.SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvoker
Request to bind to the givenSocketAddress
and notify theChannelFuture
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 nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
bind
in interfaceChannelOutboundInvoker
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress)
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
and notify theChannelFuture
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 aConnectTimeoutException
. If it fails because of connection refused aConnectException
will be used.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
while bind to the localAddress and notify theChannelFuture
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 nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
disconnect
public ChannelFuture disconnect()
Description copied from interface:ChannelOutboundInvoker
Request to disconnect from the remote peer and notify theChannelFuture
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 nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
disconnect
in interfaceChannelOutboundInvoker
-
close
public ChannelFuture close()
Description copied from interface:ChannelOutboundInvoker
Request to close theChannel
and notify theChannelFuture
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 nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
close
in interfaceChannelOutboundInvoker
-
deregister
public ChannelFuture deregister()
Description copied from interface:ChannelOutboundInvoker
Request to deregister from the previous assignedEventExecutor
and notify theChannelFuture
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 nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
deregister
in interfaceChannelOutboundInvoker
-
bind
public ChannelFuture bind(java.net.SocketAddress localAddress, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Request to bind to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
bind
in interfaceChannelOutboundInvoker
-
invokeBind
private void invokeBind(java.net.SocketAddress localAddress, ChannelPromise promise)
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelFuture
will be notified.If the connection fails because of a connection timeout, the
ChannelFuture
will get failed with aConnectTimeoutException
. If it fails because of connection refused aConnectException
will be used.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
while bind to the localAddress and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified and also returned.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
invokeConnect
private void invokeConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
-
disconnect
public ChannelFuture disconnect(ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Request to disconnect from the remote peer and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
disconnect
in interfaceChannelOutboundInvoker
-
invokeDisconnect
private void invokeDisconnect(ChannelPromise promise)
-
close
public ChannelFuture close(ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Request to close theChannel
and notify theChannelFuture
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 givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
close
in interfaceChannelOutboundInvoker
-
invokeClose
private void invokeClose(ChannelPromise promise)
-
deregister
public ChannelFuture deregister(ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Request to deregister from the previous assignedEventExecutor
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
deregister
in interfaceChannelOutboundInvoker
-
invokeDeregister
private void invokeDeregister(ChannelPromise promise)
-
read
public ChannelHandlerContext read()
Description copied from interface:ChannelOutboundInvoker
Request to Read data from theChannel
into the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
event if data was read, and triggers achannelReadComplete
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 nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
read
in interfaceChannelHandlerContext
- Specified by:
read
in interfaceChannelOutboundInvoker
-
invokeRead
private void invokeRead()
-
write
public ChannelFuture write(java.lang.Object msg)
Description copied from interface:ChannelOutboundInvoker
Request to write a message via thisChannelHandlerContext
through theChannelPipeline
. This method will not request to actual flush, so be sure to callChannelOutboundInvoker.flush()
once you want to request to flush all pending data to the actual transport.- Specified by:
write
in interfaceChannelOutboundInvoker
-
write
public ChannelFuture write(java.lang.Object msg, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Request to write a message via thisChannelHandlerContext
through theChannelPipeline
. This method will not request to actual flush, so be sure to callChannelOutboundInvoker.flush()
once you want to request to flush all pending data to the actual transport.- Specified by:
write
in interfaceChannelOutboundInvoker
-
invokeWrite
void invokeWrite(java.lang.Object msg, ChannelPromise promise)
-
invokeWrite0
private void invokeWrite0(java.lang.Object msg, ChannelPromise promise)
-
flush
public ChannelHandlerContext flush()
Description copied from interface:ChannelOutboundInvoker
Request to flush all pending messages via this ChannelOutboundInvoker.- Specified by:
flush
in interfaceChannelHandlerContext
- Specified by:
flush
in interfaceChannelOutboundInvoker
-
invokeFlush
private void invokeFlush()
-
invokeFlush0
private void invokeFlush0()
-
writeAndFlush
public ChannelFuture writeAndFlush(java.lang.Object msg, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvoker
Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)
andChannelOutboundInvoker.flush()
.- Specified by:
writeAndFlush
in interfaceChannelOutboundInvoker
-
invokeWriteAndFlush
void invokeWriteAndFlush(java.lang.Object msg, ChannelPromise promise)
-
write
private void write(java.lang.Object msg, boolean flush, ChannelPromise promise)
-
writeAndFlush
public ChannelFuture writeAndFlush(java.lang.Object msg)
Description copied from interface:ChannelOutboundInvoker
Shortcut for callChannelOutboundInvoker.write(Object)
andChannelOutboundInvoker.flush()
.- Specified by:
writeAndFlush
in interfaceChannelOutboundInvoker
-
notifyOutboundHandlerException
private static void notifyOutboundHandlerException(java.lang.Throwable cause, ChannelPromise promise)
-
newPromise
public ChannelPromise newPromise()
Description copied from interface:ChannelOutboundInvoker
Return a newChannelPromise
.- Specified by:
newPromise
in interfaceChannelOutboundInvoker
-
newProgressivePromise
public ChannelProgressivePromise newProgressivePromise()
Description copied from interface:ChannelOutboundInvoker
Return an newChannelProgressivePromise
- Specified by:
newProgressivePromise
in interfaceChannelOutboundInvoker
-
newSucceededFuture
public ChannelFuture newSucceededFuture()
Description copied from interface:ChannelOutboundInvoker
Create a newChannelFuture
which is marked as succeeded already. SoFuture.isSuccess()
will returntrue
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuture
in interfaceChannelOutboundInvoker
-
newFailedFuture
public ChannelFuture newFailedFuture(java.lang.Throwable cause)
Description copied from interface:ChannelOutboundInvoker
Create a newChannelFuture
which is marked as failed already. SoFuture.isSuccess()
will returnfalse
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newFailedFuture
in interfaceChannelOutboundInvoker
-
isNotValidPromise
private boolean isNotValidPromise(ChannelPromise promise, boolean allowVoidPromise)
-
findContextInbound
private AbstractChannelHandlerContext findContextInbound(int mask)
-
findContextOutbound
private AbstractChannelHandlerContext findContextOutbound(int mask)
-
skipContext
private static boolean skipContext(AbstractChannelHandlerContext ctx, EventExecutor currentExecutor, int mask, int onlyMask)
-
voidPromise
public ChannelPromise voidPromise()
Description copied from interface:ChannelOutboundInvoker
Return a special ChannelPromise which can be reused for different operations.It's only supported to use it for
ChannelOutboundInvoker.write(Object, ChannelPromise)
.Be aware that the returned
Be aware this is an expert feature and should be used with care!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 callChannelPipeline.fireExceptionCaught(Throwable)
in this case.- Specified by:
voidPromise
in interfaceChannelOutboundInvoker
-
setRemoved
final void setRemoved()
-
setAddComplete
final boolean setAddComplete()
-
setAddPending
final void setAddPending()
-
callHandlerAdded
final void callHandlerAdded() throws java.lang.Exception
- Throws:
java.lang.Exception
-
callHandlerRemoved
final void callHandlerRemoved() throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeHandler
private boolean invokeHandler()
Makes best possible effort to detect ifChannelHandler.handlerAdded(ChannelHandlerContext)
was called yet. If not returnfalse
and if called or could not detect returntrue
. If this method returnsfalse
we will not invoke theChannelHandler
but just forward the event. This is needed asDefaultChannelPipeline
may already put theChannelHandler
in the linked-list but not calledChannelHandler.handlerAdded(ChannelHandlerContext)
.
-
isRemoved
public boolean isRemoved()
Description copied from interface:ChannelHandlerContext
Returntrue
if theChannelHandler
which belongs to this context was removed from theChannelPipeline
. Note that this method is only meant to be called from with in theEventLoop
.- Specified by:
isRemoved
in interfaceChannelHandlerContext
-
attr
public <T> Attribute<T> attr(AttributeKey<T> key)
Description copied from interface:AttributeMap
Get theAttribute
for the givenAttributeKey
. This method will never return null, but may return anAttribute
which does not have a value set yet.- Specified by:
attr
in interfaceAttributeMap
- Specified by:
attr
in interfaceChannelHandlerContext
-
hasAttr
public <T> boolean hasAttr(AttributeKey<T> key)
Description copied from interface:AttributeMap
- Specified by:
hasAttr
in interfaceAttributeMap
- Specified by:
hasAttr
in interfaceChannelHandlerContext
-
safeExecute
private static boolean safeExecute(EventExecutor executor, java.lang.Runnable runnable, ChannelPromise promise, java.lang.Object msg, boolean lazy)
-
toHintString
public java.lang.String toHintString()
Description copied from interface:ResourceLeakHint
Returns a human-readable message that potentially enables easier resource leak tracking.- Specified by:
toHintString
in interfaceResourceLeakHint
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-