Class FilterLayer

    • Constructor Detail

      • FilterLayer

        public FilterLayer()
    • Method Detail

      • init

        @OverrideMustInvoke
        public final void init​(@NonNull
                               ProtocolStack.Ptr ptr)
                        throws IOException
        Initializes the layer with its ProtocolStack.Ptr. All lower layers in the stack will be initialized before a call to this method. All layers in a stack will be initialized before a call to ProtocolLayer.start().
        Specified by:
        init in interface ProtocolLayer
        Parameters:
        ptr - the position of this layer in the stack.
        Throws:
        IOException - if something goes wrong.
      • start

        public void start()
                   throws IOException
        Starts this layer. All layers in the stack will be initialized before a call to this method. All lower layers in the stack will have been started before this layer is started.
        Specified by:
        start in interface ProtocolLayer
        Throws:
        IOException - if something goes wrong.
      • completed

        protected final void completed()
        The FilterLayer implementation calls this to signify that it is now a no-op layer in both directions and can be removed from the ProtocolStack
      • abort

        protected final void abort​(@NonNull
                                   IOException cause)
        The FilterLayer implementation calls this to signify that a critical error in the stack has occurred and that the stack should be torn down and closed.
        Parameters:
        cause - the root cause to report.
      • stack

        @Nullable
        protected ProtocolStack<?> stack()
        Accessor for the ProtocolStack that we are bound to.
        Returns:
        the ProtocolStack that we are bound to or null if we are not currently bound to a stack.
      • onRecv

        public abstract void onRecv​(@NonNull
                                    ByteBuffer data)
                             throws IOException
        SPI: Callback on data being received from the lower layer.
        Specified by:
        onRecv in interface ProtocolLayer.Recv
        Parameters:
        data - the data received. Any data consumed from the ByteBuffer can be assumed as processed. Any data not consumed from the ByteBuffer will be the responsibility of the caller to resubmit in subsequent calls.
        Throws:
        IOException - if there was an error during processing of the received data.
      • onRecvClosed

        @OverrideMustInvoke
        public void onRecvClosed​(IOException cause)
                          throws IOException
        Callback on the lower layer's source of data being closed.
        Specified by:
        onRecvClosed in interface ProtocolLayer.Recv
        Parameters:
        cause - the cause of the lower layer being closed or null.
        Throws:
        IOException - if there was an error during the processing of the close notification.
      • doSend

        public abstract void doSend​(@NonNull
                                    ByteBuffer data)
                             throws IOException
        SPI: Sends data to the lower layer.
        Specified by:
        doSend in interface ProtocolLayer.Send
        Parameters:
        data - the data to send. Any data consumed from the ByteBuffer can be assumed as processed. Any data not consumed from the ByteBuffer will be the responsibility of the caller to resubmit in subsequent calls.
        Throws:
        IOException - if there was an error during processing of the data.