Class FilterChainContext

    • Field Detail

      • operationCompletionHandler

        protected CompletionHandler<FilterChainContext> operationCompletionHandler
        CompletionHandler, which will be notified, when operation will be complete. For WRITE it means the data will be written on wire, for other operations - the last Filter has finished the processing.
      • event

        protected FilterChainEvent event
        Context associated event, if EVENT operation
    • Constructor Detail

      • FilterChainContext

        public FilterChainContext()
    • Method Detail

      • suspend

        public java.lang.Runnable suspend()
        Suspend processing of the current task
      • resume

        public void resume()
        Resume processing of the current task
      • resumeNext

        public void resumeNext()
        Resume processing of the current task starting from the Filter, which follows the Filter, which suspend the processing.
      • resume

        public void resume​(NextAction nextAction)
        Resume the current FilterChain task processing by completing the current Filter (the Filter, which suspended the processing) with the passed NextAction.
        Parameters:
        nextAction - the NextAction, based on which FilterChain will continue processing.
      • fork

        public void fork()
        This method invocation suggests the FilterChain to create a copy of this FilterChainContext and resume/fork its execution starting from the current Filter.
      • fork

        public void fork​(NextAction nextAction)
        This method invocation suggests the FilterChain to create a copy of this FilterChainContext and resume/fork its execution starting from the current Filter.

        If nextAction parameter is not null - then its value is treated as a result of the current Filter execution on the forked FilterChain processing. So during the forked FilterChain processing the current Filter will not be invoked, but the processing will be continued as if the current Filter returned nextAction as a result. For example if we call fork(ctx.getInvokeAction()); the forked FilterChain processing will start with the next Filter in chain.

      • state

        public FilterChainContext.State state()
        Get the current processing task state.
        Returns:
        the current processing task state.
      • nextFilterIdx

        public int nextFilterIdx()
      • previousFilterIdx

        public int previousFilterIdx()
      • getFilterIdx

        public int getFilterIdx()
      • setFilterIdx

        public void setFilterIdx​(int index)
      • getStartIdx

        public int getStartIdx()
      • setStartIdx

        public void setStartIdx​(int startIdx)
      • getEndIdx

        public int getEndIdx()
      • setEndIdx

        public void setEndIdx​(int endIdx)
      • getConnection

        public Connection getConnection()
        Get the Connection, associated with the current processing.
        Returns:
        Connection object, associated with the current processing.
      • getCloseable

        public Closeable getCloseable()
        Get the Closeable, associated with the current processing. The Closeable object might be used to close/terminate an entity associated with the FilterChain processing in response to an error occurred during the processing. If not customized the Closeable object represents a Connection associated with the FilterChain processing.
        Returns:
        Closeable object, associated with the current processing.
      • getMessage

        public <T> T getMessage()
        Get message object, associated with the current processing. Usually FilterChain represents sequence of parser and process Filters. Each parser can change the message representation until it will come to processor Filter.
        Returns:
        message object, associated with the current processing.
      • setMessage

        public void setMessage​(java.lang.Object message)
        Set message object, associated with the current processing. Usually FilterChain represents sequence of parser and process Filters. Each parser can change the message representation until it will come to processor Filter.
        Parameters:
        message - message object, associated with the current processing.
      • getAddressHolder

        public Holder<?> getAddressHolder()
        Get a Holder, which contains address, associated with the current IOEvent processing. When we process IOEvent.READ event - it represents sender address, or when process IOEvent.WRITE - address of receiver.
        Returns:
        Holder, which contains address, associated with the current IOEvent processing.
      • setAddressHolder

        public void setAddressHolder​(Holder<?> addressHolder)
        Set address, associated with the current IOEvent processing. When we process IOEvent.READ event - it represents sender address, or when process IOEvent.WRITE - address of receiver.
        Parameters:
        addressHolder - Holder, which contains address, associated with the current IOEvent processing.
      • getAddress

        public java.lang.Object getAddress()
        Get address, associated with the current IOEvent processing. When we process IOEvent.READ event - it represents sender address, or when process IOEvent.WRITE - address of receiver.
        Returns:
        address, associated with the current IOEvent processing.
      • setAddress

        public void setAddress​(java.lang.Object address)
        Set address, associated with the current IOEvent processing. When we process IOEvent.READ event - it represents sender address, or when process IOEvent.WRITE - address of receiver.
        Parameters:
        address - address, associated with the current IOEvent processing.
      • getRunnable

        protected final java.lang.Runnable getRunnable()
      • getInternalContext

        public final Context getInternalContext()
        Get the general Grizzly Context this filter context wraps.
        Returns:
        the general Grizzly Context this filter context wraps.
      • getInvokeAction

        public NextAction getInvokeAction​(java.lang.Object unparsedChunk)
        Get NextAction implementation, which instructs FilterChain to process next Filter in chain. Normally, after receiving this instruction from Filter, FilterChain executes next filter.
        Parameters:
        unparsedChunk - signals, that there is some unparsed data remaining in the source message, so FilterChain could be rerun.
        Returns:
        NextAction implementation, which instructs FilterChain to process next Filter in chain.
      • getInvokeAction

        public <E> NextAction getInvokeAction​(E incompleteChunk,
                                              Appender<E> appender)
        Get NextAction implementation, which instructs FilterChain to process next Filter in chain. Normally, after receiving this instruction from Filter, FilterChain executes next filter.
        Parameters:
        incompleteChunk - signals, that there is a data chunk remaining, which doesn't represent complete message. As more data becomes available but before FilterChain calls the current Filter, it will check if the Filter has any data stored after the last invocation. If a remainder is present it will append the new data to the stored one and pass the result as the FilterChainContext message.
        appender - the Appender, which knows how to append chunks of type <E>.
        Returns:
        NextAction implementation, which instructs FilterChain to process next Filter in chain.
        Throws:
        java.lang.IllegalArgumentException - if appender is null and remainder's type is not Buffer or Appendable.
      • getStopAction

        public NextAction getStopAction​(java.lang.Object incompleteChunk)
        Get NextAction implementation, which instructs FilterChain stop executing phase.
        Parameters:
        incompleteChunk - signals, that there is a data chunk remaining, which doesn't represent complete message. As more data becomes available but before FilterChain calls the current Filter, it will check if the Filter has any data stored after the last invocation. If a remainder is present it will append the new data to the stored one and pass the result as the FilterChainContext message.
        Returns:
        NextAction implementation, which instructs FilterChain to stop executing phase.
        Throws:
        java.lang.IllegalArgumentException - if remainder's type is not Buffer or Appendable.
      • getStopAction

        public <E> NextAction getStopAction​(E incompleteChunk,
                                            Appender<E> appender)
        Get NextAction implementation, which instructs FilterChain stop executing phase.
        Parameters:
        incompleteChunk - signals, that there is a data chunk remaining, which doesn't represent complete message. As more data becomes available but before FilterChain calls the current Filter, it will check if the Filter has any data stored after the last invocation. If a remainder is present it will append the new data to the stored one and pass the result as the FilterChainContext message.
        appender - the Appender, which knows how to append chunks of type <E>.
        Returns:
        NextAction implementation, which instructs FilterChain to stop executing phase.
        Throws:
        java.lang.IllegalArgumentException - if appender is null and remainder's type is not Buffer or Appendable.
      • getForkAction

        public NextAction getForkAction​(NextAction nextAction)
        Returns:
        NextAction implementation, which suggests the FilterChain to forget about the current FilterChainContext, create a copy of it and continue/fork FilterChain processing using the copied FilterChainContext starting from the current Filter.

        If nextAction parameter is not null - then its value is treated as a result of the current Filter execution on the forked FilterChain processing. So during the forked FilterChain processing the current Filter will not be invoked, but the processing will be continued as if the current Filter returned nextAction as a result. For example if we call fork(ctx.getInvokeAction()); the forked FilterChain processing will start with the next Filter in chain.

      • read

        public ReadResult read()
                        throws java.io.IOException

        Performs a blocking read.

        Returns:
        the result of the read operation.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • write

        public void write​(java.lang.Object message)
      • write

        public void write​(java.lang.Object message,
                          boolean blocking)
      • write

        public void write​(java.lang.Object address,
                          java.lang.Object message,
                          CompletionHandler<WriteResult> completionHandler,
                          boolean blocking)
      • fail

        public void fail​(java.lang.Throwable error)
      • getMemoryManager

        public final MemoryManager getMemoryManager()

        A simple alias for FilterChainContext.getConnection().getMemoryManager().

        Returns:
        the MemoryManager associated with the Connection of this FilterChainContext.
      • reset

        public void reset()
        Release the context associated resources.
      • completeAndRecycle

        public void completeAndRecycle()
      • completeAndRelease

        public void completeAndRelease()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object