public abstract static class ProtocolNegotiators.AbstractBufferingHandler extends ChannelDuplexHandler
writeBufferedAndRemove(ChannelHandlerContext) or
fail(ChannelHandlerContext, Throwable) is called. This handler allows us to
write to a Channel before we are allowed to write to it officially
i.e. before it's active or the TLS Handshake is complete.ChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBufferingHandler(ChannelHandler... handlers) |
| Modifier and Type | Method and Description |
|---|---|
void |
channelInactive(ChannelHandlerContext ctx)
If this channel becomes inactive, then notify all buffered writes that we failed.
|
void |
channelRegistered(ChannelHandlerContext ctx)
When this channel is registered, we will add all the ChannelHandlers passed into our
constructor to the pipeline.
|
void |
close(ChannelHandlerContext ctx,
ChannelPromise future)
If we are still performing protocol negotiation, then this will propagate failures to all
buffered writes.
|
void |
connect(ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
ChannelPromise promise)
Do not rely on channel handlers to propagate exceptions to us.
|
void |
exceptionCaught(ChannelHandlerContext ctx,
Throwable cause)
If we encounter an exception, then notify all buffered writes that we failed.
|
protected void |
fail(ChannelHandlerContext ctx,
Throwable cause)
Propagate failures to all buffered writes.
|
void |
flush(ChannelHandlerContext ctx)
Calls to this method will not trigger an immediate flush.
|
void |
write(ChannelHandlerContext ctx,
Object msg,
ChannelPromise promise)
Buffers the write until either
writeBufferedAndRemove(ChannelHandlerContext) is
called, or we have somehow failed. |
protected void |
writeBufferedAndRemove(ChannelHandlerContext ctx) |
bind, deregister, disconnect, readchannelActive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedprotected AbstractBufferingHandler(ChannelHandler... handlers)
handlers - the ChannelHandlers are added to the pipeline on channelRegistered and
before this handler.public void channelRegistered(ChannelHandlerContext ctx) throws Exception
channelRegistered in interface ChannelInboundHandlerchannelRegistered in class ChannelInboundHandlerAdapterExceptionpublic void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception
NettyClientHandler is an example of a class that does not propagate exceptions.
Add a listener to the connect future directly and do appropriate error handling.connect in interface ChannelOutboundHandlerconnect in class ChannelDuplexHandlerExceptionpublic void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught in interface ChannelHandlerexceptionCaught in interface ChannelInboundHandlerexceptionCaught in class ChannelInboundHandlerAdapterExceptionpublic void channelInactive(ChannelHandlerContext ctx) throws Exception
channelInactive in interface ChannelInboundHandlerchannelInactive in class ChannelInboundHandlerAdapterExceptionpublic void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
writeBufferedAndRemove(ChannelHandlerContext) is
called, or we have somehow failed. If we have already failed in the past, then the write
will fail immediately.write in interface ChannelOutboundHandlerwrite in class ChannelDuplexHandlerExceptionpublic void flush(ChannelHandlerContext ctx)
writeBufferedAndRemove(ChannelHandlerContext).flush in interface ChannelOutboundHandlerflush in class ChannelDuplexHandlerpublic void close(ChannelHandlerContext ctx, ChannelPromise future) throws Exception
close in interface ChannelOutboundHandlerclose in class ChannelDuplexHandlerExceptionprotected final void fail(ChannelHandlerContext ctx, Throwable cause)
protected final void writeBufferedAndRemove(ChannelHandlerContext ctx)