Class SimpleJob

All Implemented Interfaces:
Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resettable, Stateful
Direct Known Subclasses:
ArchiveBrowserJob, BuildOddball, DependsJob, ResetJob, RMIRegistryJob, SerializableJob, ServicesJob, SetJob, StateExpressionJob, VariablesJob, WaitJob

public abstract class SimpleJob extends BasePrimary implements Runnable, Resettable, Stateful, Forceable
An abstract implementation of a job which provides common functionality to concrete sub classes.
Author:
Rob Gordon
  • Field Details

    • stop

      protected transient volatile boolean stop
      Reference Property:

      Description

      This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops.
      Required:
      Read Only.
  • Constructor Details

    • SimpleJob

      protected SimpleJob()
  • Method Details

    • stateHandler

      protected JobStateHandler 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 StateChanger<JobState> getStateChanger()
    • execute

      protected abstract int execute() throws Throwable
      Execute this job.
      Returns:
      0 if the job is complete, anything else otherwise.
      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
    • sleep

      protected void sleep(long waitTime)
      Utility method to sleep a certain time.
      Parameters:
      waitTime - Milliseconds to sleep for.
    • stop

      public final void stop() throws FailedToStopException
      Allow subclasses to indicate they are stopping. The subclass must still implement Stoppable.
      Throws:
      FailedToStopException
    • onStop

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

      public boolean isStop()
      Getter for stop flag.
      Returns:
    • 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.
    • 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
    • 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