Class SequentialDirector

    • Field Detail

      • m_FinalOutput

        protected transient List<Token> m_FinalOutput
        for storing the token that the last actor generated.
      • m_Finished

        protected boolean m_Finished
        whether execution has finished.
      • m_Executed

        protected boolean m_Executed
        whether the director was executed at all.
    • Constructor Detail

      • SequentialDirector

        public SequentialDirector()
    • Method Detail

      • isFinalOutputRecorded

        protected boolean isFinalOutputRecorded()
        Returns whether the final output of actors is recorded.

        Default implementation returns false.
        Returns:
        true if final output is to be recorded
      • getFinalOutput

        protected List<Token> getFinalOutput()
        Returns the vector for storing final outputs. Gets instantiated if necessary.
        Returns:
        the vector for storing the tokens
        See Also:
        m_FinalOutput
      • checkActorHasStopped

        protected String checkActorHasStopped​(Actor actor)
        Checks whether the actor has already stopped. If so, outputs a message on the commandline and returns the error message.
        Parameters:
        actor - the actor to check
        Returns:
        null if actor not stopped, otherwise the error message
      • handleException

        protected String handleException​(Actor actor,
                                         String msg,
                                         Throwable t)
        Handles the error message, by outputting the exception on stderr and generating/returning a combined error string.
        Parameters:
        actor - the actor that generated the exception
        msg - the error message
        t - the exception
        Returns:
        the combined error string
      • handleError

        protected String handleError​(Actor actor,
                                     String action,
                                     String msg)
        Handles the given error message, calling the actor's error handler, if defined.
        Parameters:
        actor - the actor to let the error handle
        action - the action when the error occurred
        msg - the error message, skips handling if null
        Returns:
        the (potentially) updated error message
      • doInput

        protected String doInput​(Actor actor,
                                 Token input)
        Presents the specified token to the actor.
        Parameters:
        actor - the actor to use (InputConsumer)
        input - the input token
        Returns:
        the error message, null if everything OK
      • doExecute

        protected String doExecute​(Actor actor)
        Calls the execute() method of the actor.
        Parameters:
        actor - the actor to use
        Returns:
        a potential error message
      • doHasOutput

        protected boolean doHasOutput​(Actor actor)
        Checks whether the actor has pending output.
        Parameters:
        actor - the actor to use (OutputProducer)
        Returns:
        the token that was retrieved from the actor, null in case of an error and not 'stopping on errors'
        See Also:
        AbstractActor.getStopFlowOnError()
      • doOutput

        protected Token doOutput​(Actor actor)
        Retrieves the token from the actor.
        Parameters:
        actor - the actor to use
        Returns:
        the token that was retrieved from the actor, null in case of an error and not 'stopping on errors'
        See Also:
        AbstractActor.getStopFlowOnError()
      • activeIndices

        protected int[] activeIndices()
        Returns the indices of the active (= non-skipped) actors.
        Returns:
        the indices of active actors
      • activeIndices

        protected int[] activeIndices​(int from,
                                      int to)
        Returns the indices of the active (= non-skipped) actors in the given range.
        Parameters:
        from - the first actor (incl)
        to - the last actor (incl)
        Returns:
        the indices of active actors
      • doExecuteStandalones

        protected Actor doExecuteStandalones()
        Executes all the standalone actors. Returns the first non-standalone actor.
        Returns:
        the first non-standalone actor or null if non present
      • doExecuteActors

        protected String doExecuteActors​(Actor startActor)
        Peforms the execution of the actors.
        Parameters:
        startActor - the actor to start with
        Returns:
        null if everything ok, otherwise the error message
      • execute

        public String execute()
        Executes the group of actors.
        Specified by:
        execute in class AbstractDirector
        Returns:
        null if everything went smooth
      • isFinished

        public boolean isFinished()
        Checks whether the director has finished.
        Overrides:
        isFinished in class AbstractDirector
        Returns:
        true if execution finished (or stopped)
      • flushExecution

        public void flushExecution()
        Stops the processing of tokens without stopping the flow.
        Overrides:
        flushExecution in class AbstractDirector