Class CloseHandler


  • public abstract class CloseHandler
    extends java.lang.Object
    Contract between protocol codecs and a close handler.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CloseHandler.CloseEvent
      These events indicate an event was observed from the protocol or Channel that indicates the end of the Channel and no further requests should be attempted.
      static class  CloseHandler.CloseEventObservedException
      ClosedChannelException with additional meta-data to provide more context on what side initiated the close event.
      static class  CloseHandler.DiscardFurtherInboundEvent
      Netty UserEvent to indicate the further inbound data should be discarded.
    • Constructor Summary

      Constructors 
      Constructor Description
      CloseHandler()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static CloseHandler forNonPipelined​(boolean isClient, io.netty.channel.ChannelConfig config)
      Create a new CloseHandler instance which doesn't support pipelining, and only ever has a single outstanding request/response.
      static CloseHandler forPipelinedRequestResponse​(boolean client, io.netty.channel.ChannelConfig config)
      New CloseHandler instance.
      abstract void protocolClosingInbound​(io.netty.channel.ChannelHandlerContext ctx)
      Signal inbound close command observed, to be emitted from the EventLoop for the Channel.
      abstract void protocolClosingOutbound​(io.netty.channel.ChannelHandlerContext ctx)
      Signal outbound close command observed, to be emitted from the EventLoop for the Channel.
      abstract void protocolPayloadBeginInbound​(io.netty.channel.ChannelHandlerContext ctx)
      Signal begin of inbound payload, to be emitted from the EventLoop for the Channel.
      abstract void protocolPayloadBeginOutbound​(io.netty.channel.ChannelHandlerContext ctx)
      Signal begin of outbound payload, to be emitted from the EventLoop for the Channel.
      abstract void protocolPayloadEndInbound​(io.netty.channel.ChannelHandlerContext ctx)
      Signal end of inbound payload, to be emitted from the EventLoop for the Channel.
      abstract void protocolPayloadEndOutbound​(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
      Signal end of outbound payload, including the ChannelPromise associated with the last write.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UNSUPPORTED_PROTOCOL_CLOSE_HANDLER

        public static final CloseHandler UNSUPPORTED_PROTOCOL_CLOSE_HANDLER
    • Constructor Detail

      • CloseHandler

        public CloseHandler()
    • Method Detail

      • forPipelinedRequestResponse

        public static CloseHandler forPipelinedRequestResponse​(boolean client,
                                                               io.netty.channel.ChannelConfig config)
        New CloseHandler instance.
        Parameters:
        client - operation mode, TRUE for client or FALSE for server
        config - The ChannelConfig associated with the channel to create the CloseHandler for. This ChannelConfig maybe modified to ensure the underlying options allow for half-closure.
        Returns:
        a new connection close handler with behavior for a pipelined request/response client or server
      • forNonPipelined

        public static CloseHandler forNonPipelined​(boolean isClient,
                                                   io.netty.channel.ChannelConfig config)
        Create a new CloseHandler instance which doesn't support pipelining, and only ever has a single outstanding request/response. The CloseHandler doesn't require the channel be of any special type (e.g. DuplexChannel) nor support any special channel options (e.g. ChannelOption.ALLOW_HALF_CLOSURE).
        Parameters:
        isClient - operation mode, TRUE for client or FALSE for server.
        config - The ChannelConfig associated with the channel to create the CloseHandler for.
        Returns:
        a new CloseHandler instance which doesn't support pipelining.
      • protocolPayloadBeginInbound

        public abstract void protocolPayloadBeginInbound​(io.netty.channel.ChannelHandlerContext ctx)
        Signal begin of inbound payload, to be emitted from the EventLoop for the Channel.
        Parameters:
        ctx - ChannelHandlerContext
      • protocolPayloadEndInbound

        public abstract void protocolPayloadEndInbound​(io.netty.channel.ChannelHandlerContext ctx)
        Signal end of inbound payload, to be emitted from the EventLoop for the Channel.
        Parameters:
        ctx - ChannelHandlerContext
      • protocolPayloadBeginOutbound

        public abstract void protocolPayloadBeginOutbound​(io.netty.channel.ChannelHandlerContext ctx)
        Signal begin of outbound payload, to be emitted from the EventLoop for the Channel.
        Parameters:
        ctx - ChannelHandlerContext
      • protocolPayloadEndOutbound

        public abstract void protocolPayloadEndOutbound​(io.netty.channel.ChannelHandlerContext ctx,
                                                        io.netty.channel.ChannelPromise promise)
        Signal end of outbound payload, including the ChannelPromise associated with the last write. Must be called from the EventLoop for the Channel.
        Parameters:
        promise - The ChannelPromise associated with the last write operation.
        ctx - ChannelHandlerContext
      • protocolClosingInbound

        public abstract void protocolClosingInbound​(io.netty.channel.ChannelHandlerContext ctx)
        Signal inbound close command observed, to be emitted from the EventLoop for the Channel.
        Parameters:
        ctx - ChannelHandlerContext
      • protocolClosingOutbound

        public abstract void protocolClosingOutbound​(io.netty.channel.ChannelHandlerContext ctx)
        Signal outbound close command observed, to be emitted from the EventLoop for the Channel.
        Parameters:
        ctx - ChannelHandlerContext