Class Execution

  • Direct Known Subclasses:
    ExecutionWithResponse

    public class Execution
    extends java.lang.Object
    An execution of a chain. This keeps tracks of the progress of the execution and is called by the processors (using process(com.yahoo.processing.Request) to move the execution to the next one.
    Author:
    bratseth
    • Constructor Detail

      • Execution

        public Execution​(Processor processor,
                         Execution execution)
        Creates an execution of a single processor
        Parameters:
        processor - the processor to execute in this
        execution - the parent execution of this
      • Execution

        public Execution​(Chain<? extends Processor> chain,
                         Execution execution)
        Creates an execution of a chain
        Parameters:
        chain - the chain to execute in this, starting from the first processor
        execution - the parent execution of this
      • Execution

        public Execution​(Execution startPoint)
        Creates an execution from another. This execution will start at the next processor of the given execution. The given execution can continue independently of this.
      • Execution

        protected Execution​(Chain<? extends Processor> chain,
                            int startIndex,
                            Execution.Trace trace,
                            Execution.Environment<? extends Processor> environment)
        Creates a new execution by setting the internal state directly.
        Parameters:
        chain - the chain to execute
        startIndex - the start index into that chain
        trace - the context of this. If this is created from an existing execution/context, be sure to do new Context<COMPONENT>(startPoint.context) first!
        environment - the static execution environment to use
    • Method Detail

      • createRoot

        public static Execution createRoot​(Processor processor,
                                           int traceLevel,
                                           Execution.Environment<? extends Processor> environment)
        Creates an execution of a single processor which is not in the context of an existing execution
      • createRoot

        public static Execution createRoot​(Chain<? extends Processor> chain,
                                           int traceLevel,
                                           Execution.Environment<? extends Processor> environment)
        Creates an execution which is not in the context of an existing execution
        Parameters:
        chain - the chain to execute
        traceLevel - the level to emit trace at
        environment - the execution environment to use
      • process

        public Response process​(Request request)
        Calls process on the next processor in this chain. If there is no next, an empty response is returned.
      • nextIndex

        protected int nextIndex()
        Returns the index into the chain of processors which is currently next
      • onInvoking

        protected void onInvoking​(Request request,
                                  Processor next)
        A hook called when a processor is to be invoked. Overriding methods must call super.onInvoking
      • onReturning

        protected void onReturning​(Request request,
                                   Processor processor,
                                   Response response)
        A hook called when a processor returns, either normally or by throwing. Overriding methods must call super.onReturning
        Parameters:
        request - the processing request
        processor - the processor which returned
        response - the response returned, or null if the processor returned by throwing
      • previousProcessor

        protected void previousProcessor()
        Move this execution to the previous processor
      • nextProcessor

        protected void nextProcessor()
        Move this execution to the next processor
      • next

        protected Processor next()
        Returns the next searcher to be invoked in this chain, or null if we are at the last
      • chain

        public Chain<? extends Processor> chain()
        Returns the chain this executes
      • defaultResponse

        protected Response defaultResponse​(Request request)
        Creates the default response to return from this kind of execution when there are no further processors. If this is overridden, make sure to propagate any freezeListener from this to the returned response top-level DataList.
      • toString

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