public abstract class EmbeddedChannelHandlerContext extends java.lang.Object implements ChannelHandlerContext
| 限定符 | 构造器和说明 |
|---|---|
protected |
EmbeddedChannelHandlerContext(ByteBufAllocator alloc,
ChannelHandler handler,
EmbeddedChannel channel) |
| 限定符和类型 | 方法和说明 |
|---|---|
ByteBufAllocator |
alloc()
Return the assigned
ByteBufAllocator which will be used to allocate ByteBufs. |
<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. |
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.
|
protected abstract void |
handleException(java.lang.Throwable t) |
ChannelHandler |
handler()
The
ChannelHandler that is bound this ChannelHandlerContext. |
<T> boolean |
hasAttr(AttributeKey<T> key)
|
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. |
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. |
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. |
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(). |
protected EmbeddedChannelHandlerContext(ByteBufAllocator alloc, ChannelHandler handler, EmbeddedChannel channel)
protected abstract void handleException(java.lang.Throwable t)
public final <T> Attribute<T> attr(AttributeKey<T> key)
AttributeMapAttribute for the given AttributeKey. This method will never return null, but may return
an Attribute which does not have a value set yet.attr 在接口中 ChannelHandlerContextattr 在接口中 AttributeMappublic final <T> boolean hasAttr(AttributeKey<T> key)
AttributeMaphasAttr 在接口中 ChannelHandlerContexthasAttr 在接口中 AttributeMappublic final Channel channel()
ChannelHandlerContextChannel which is bound to the ChannelHandlerContext.channel 在接口中 ChannelHandlerContextpublic final EventExecutor executor()
ChannelHandlerContextEventExecutor which is used to execute an arbitrary task.executor 在接口中 ChannelHandlerContextpublic final java.lang.String name()
ChannelHandlerContextChannelHandlerContext.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 在接口中 ChannelHandlerContextpublic final ChannelHandler handler()
ChannelHandlerContextChannelHandler that is bound this ChannelHandlerContext.handler 在接口中 ChannelHandlerContextpublic final boolean isRemoved()
ChannelHandlerContexttrue 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 在接口中 ChannelHandlerContextpublic final ChannelHandlerContext fireChannelRegistered()
ChannelInboundInvokerChannel 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 在接口中 ChannelHandlerContextfireChannelRegistered 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireChannelUnregistered()
ChannelInboundInvokerChannel 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 在接口中 ChannelHandlerContextfireChannelUnregistered 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireChannelActive()
ChannelInboundInvokerChannel 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 在接口中 ChannelHandlerContextfireChannelActive 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireChannelInactive()
ChannelInboundInvokerChannel 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 在接口中 ChannelHandlerContextfireChannelInactive 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireExceptionCaught(java.lang.Throwable cause)
ChannelInboundInvokerChannel 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 在接口中 ChannelHandlerContextfireExceptionCaught 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireUserEventTriggered(java.lang.Object event)
ChannelInboundInvokerChannel 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 在接口中 ChannelHandlerContextfireUserEventTriggered 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireChannelRead(java.lang.Object msg)
ChannelInboundInvokerChannel 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 在接口中 ChannelHandlerContextfireChannelRead 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireChannelReadComplete()
ChannelInboundInvokerChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event to the next ChannelInboundHandler in the ChannelPipeline.fireChannelReadComplete 在接口中 ChannelHandlerContextfireChannelReadComplete 在接口中 ChannelInboundInvokerpublic final ChannelHandlerContext fireChannelWritabilityChanged()
ChannelInboundInvokerChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the next ChannelInboundHandler in the ChannelPipeline.public final ChannelFuture bind(java.net.SocketAddress localAddress)
ChannelOutboundInvokerSocketAddress 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture connect(java.net.SocketAddress remoteAddress)
ChannelOutboundInvokerSocketAddress 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
ChannelOutboundInvokerSocketAddress 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture disconnect()
ChannelOutboundInvokerChannelFuture 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture close()
ChannelOutboundInvokerChannel 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture deregister()
ChannelOutboundInvokerEventExecutor 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture bind(java.net.SocketAddress localAddress, ChannelPromise promise)
ChannelOutboundInvokerSocketAddress 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture connect(java.net.SocketAddress remoteAddress, ChannelPromise promise)
ChannelOutboundInvokerSocketAddress 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
ChannelOutboundInvokerSocketAddress 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture disconnect(ChannelPromise promise)
ChannelOutboundInvokerChannelFuture 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture close(ChannelPromise promise)
ChannelOutboundInvokerChannel 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture deregister(ChannelPromise promise)
ChannelOutboundInvokerEventExecutor 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 在接口中 ChannelOutboundInvokerpublic final ChannelHandlerContext read()
ChannelOutboundInvokerChannel 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 在接口中 ChannelHandlerContextread 在接口中 ChannelOutboundInvokerpublic ChannelFuture write(java.lang.Object msg)
ChannelOutboundInvokerChannelHandlerContext 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 在接口中 ChannelOutboundInvokerpublic ChannelFuture write(java.lang.Object msg, ChannelPromise promise)
ChannelOutboundInvokerChannelHandlerContext 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 在接口中 ChannelOutboundInvokerpublic final ChannelHandlerContext flush()
ChannelOutboundInvokerflush 在接口中 ChannelHandlerContextflush 在接口中 ChannelOutboundInvokerpublic ChannelFuture writeAndFlush(java.lang.Object msg, ChannelPromise promise)
ChannelOutboundInvokerChannelOutboundInvoker.write(Object, ChannelPromise) and ChannelOutboundInvoker.flush().writeAndFlush 在接口中 ChannelOutboundInvokerpublic ChannelFuture writeAndFlush(java.lang.Object msg)
ChannelOutboundInvokerChannelOutboundInvoker.write(Object) and ChannelOutboundInvoker.flush().writeAndFlush 在接口中 ChannelOutboundInvokerpublic final ChannelPipeline pipeline()
ChannelHandlerContextChannelPipelinepipeline 在接口中 ChannelHandlerContextpublic final ByteBufAllocator alloc()
ChannelHandlerContextByteBufAllocator which will be used to allocate ByteBufs.alloc 在接口中 ChannelHandlerContextpublic final ChannelPromise newPromise()
ChannelOutboundInvokerChannelPromise.newPromise 在接口中 ChannelOutboundInvokerpublic final ChannelProgressivePromise newProgressivePromise()
ChannelOutboundInvokerChannelProgressivePromisenewProgressivePromise 在接口中 ChannelOutboundInvokerpublic final ChannelFuture newSucceededFuture()
ChannelOutboundInvokerChannelFuture 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 在接口中 ChannelOutboundInvokerpublic final ChannelFuture newFailedFuture(java.lang.Throwable cause)
ChannelOutboundInvokerChannelFuture 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 在接口中 ChannelOutboundInvokerpublic final 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 在接口中 ChannelOutboundInvoker