Class StructuralJob<E>

All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resettable, Stateful, Stoppable, Structural
Direct Known Subclasses:
BasicBusService, CascadeJob, EqualsState, EventJobBase, ForEachJob, IfJob, JoinJob, MultiExplorerLauncher, Oddjob, RepeatJob, Resets, RunJob, SequentialJob, SimultaneousStructural, SplitDestinations, SwitchJob

public abstract class StructuralJob<E> extends BasePrimary implements Runnable, Serializable, Stoppable, Resettable, Stateful, Forceable, Structural
An abstract implementation of a job which provides common functionality to concrete sub classes.
Author:
Rob Gordon
See Also:
  • Field Details

    • childHelper

      protected transient volatile ChildHelper<E> childHelper
      Track changes to children an notify listeners.
    • structuralState

      protected transient volatile StructuralStateHelper structuralState
      Calculate our state based on children.
    • stop

      protected transient volatile boolean stop
      Reference Property:

      Description

      Read only view of the internal stop flag. This flag is cleared with a reset.
    • destroy

      protected transient volatile boolean destroy
  • Constructor Details

    • StructuralJob

      public StructuralJob()
      Constructor.
  • Method Details

    • stateHandler

      protected ParentStateHandler stateHandler()
      Description copied from class: BaseComponent
      Subclasses must provide a StateHandler.
      Specified by:
      stateHandler in class BaseComponent
      Returns:
      A State Handler. Never null.
    • iconHelper

      protected IconHelper iconHelper()
      Description copied from class: BaseComponent
      Subclasses must provide a IconHelper.
      Specified by:
      iconHelper in class BaseComponent
      Returns:
      An Icon Helper. Never null.
    • getStateChanger

      protected final StateChanger<ParentState> getStateChanger()
    • getInitialStateOp

      protected abstract StateOperator getInitialStateOp()
      Subclasses must provide the StateOperator that will decide how to evaluate the children's state.
      Returns:
      A State Operator. Must not be null.
    • execute

      protected abstract void execute() throws Throwable
      Execute this job.
      Throws:
      Exception - If the unexpected occurs.
      Throwable
    • run

      public final void run()
      Implement the main execute method for a job. This surrounds the doExecute method of the sub class and sets state for the job.
      Specified by:
      run in interface Runnable
    • startChildStateReflector

      protected void startChildStateReflector()
      Start the child state reflector. Sub classes override this if they need to start the child state reflector at a different time.
    • stopChildStateReflector

      protected void stopChildStateReflector()
    • waitForChildrenOnStop

      protected boolean waitForChildrenOnStop()
    • stop

      public void stop() throws FailedToStopException
      Implementation for a typical stop.

      This stop implementation doesn't check that the job is executing as stop messages must cascade down the hierarchy to manually started jobs.

      Specified by:
      stop in interface Stoppable
      Throws:
      FailedToStopException
    • onStop

      protected void onStop() throws FailedToStopException
      Allow sub classes to do something on stop.
      Throws:
      FailedToStopException
    • postStop

      protected void postStop() throws FailedToStopException
      Subclasses can override to perform actions once children have stopped.
      Throws:
      FailedToStopException
    • softReset

      public boolean softReset()
      Perform a soft reset on the job.
      Specified by:
      softReset in interface Resettable
      Returns:
      true if successful.
    • hardReset

      public boolean hardReset()
      Perform a hard reset on the job.
      Specified by:
      hardReset in interface Resettable
      Returns:
      true if successful.
    • onHardReset

      protected void onHardReset()
      Allow sub classes to do something on HARD reset.
    • onSoftReset

      protected void onSoftReset()
      Allow sub classes to do something on SOFT reset.
    • onReset

      protected void onReset()
      Allow sub classes to do something on reset.
    • force

      public void force()
      Force the job to COMPLETE.
      Specified by:
      force in interface Forceable
    • addStructuralListener

      public void addStructuralListener(StructuralListener listener)
      Add a listener. The listener will immediately receive add notifications for all existing children.
      Specified by:
      addStructuralListener in interface Structural
      Parameters:
      listener - The listener.
    • removeStructuralListener

      public void removeStructuralListener(StructuralListener listener)
      Remove a listener.
      Specified by:
      removeStructuralListener in interface Structural
      Parameters:
      listener - The listener.
    • isStop

      public boolean isStop()
      Expose the internal stop flag as a read only property.
      Returns:
      the stop flag.
    • onDestroy

      protected void onDestroy()
      Description copied from class: BaseComponent
      Subclasses override this method to clear up resources. This is called by the framework before child elements have been destroyed.
      Overrides:
      onDestroy in class BaseComponent
    • fireDestroyedState

      protected void fireDestroyedState()
      Internal method to fire state.
      Specified by:
      fireDestroyedState in class BaseComponent