Class TimerBase

All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resettable, Stateful, Stoppable, Structural
Direct Known Subclasses:
Retry, Timer

public abstract class TimerBase extends ScheduleBase
Common functionality for Timers.
Author:
rob
See Also:
  • Field Details

    • contextData

      protected final Map<Object,Object> contextData
      Provided to the schedule.
  • Constructor Details

    • TimerBase

      public TimerBase()
  • Method Details

    • setScheduleExecutorService

      @Inject public void setScheduleExecutorService(ScheduledExecutorService scheduler)
    • begin

      protected void begin() throws ComponentPersistException
      Description copied from class: ScheduleBase
      Sub classes must override this to submit the first execution.
      Specified by:
      begin in class ScheduleBase
      Throws:
      ComponentPersistException - If the scheduled time can't be saved.
    • onStop

      protected void onStop()
      Description copied from class: ScheduleBase
      Subclasses can override to perform stopping operations.
      Overrides:
      onStop in class ScheduleBase
    • postStop

      protected void postStop()
      Description copied from class: ScheduleBase
      Subclasses can override to perform actions once children have stopped.
      Overrides:
      postStop in class ScheduleBase
    • onReset

      protected void onReset()
      Description copied from class: ScheduleBase
      Override by subclasses to reset state.
      Overrides:
      onReset in class ScheduleBase
    • getTimeZone

      public String getTimeZone()
      Get the time zone id to use in this schedule.
      Returns:
      The time zone id being used.
    • setTimeZone

      public void setTimeZone(String timeZoneId)
      Set the time zone.
      Parameters:
      timeZoneId - the timeZoneId.
    • setSchedule

      public void setSchedule(Schedule schedule)
      Set the schedule.
      Parameters:
      schedule - The schedule.
    • getSchedule

      public Schedule getSchedule()
    • setReschedule

      public void setReschedule(Date reSchedule) throws OddjobLockedException
      Throws:
      OddjobLockedException
      Reference Property:
      reschedule

      Description

      Reschedule from the given date/time.
      Required:
      Only available once the timer has started.
    • CancelAndStopChild

      protected void CancelAndStopChild() throws FailedToStopException
      Cancel and child jobs that are submitted and stop any that are running. This should only be run while locked because it temporarily sets the stop flag to fool the state listener into not rescheduling.
      Throws:
      FailedToStopException
    • scheduleFrom

      protected boolean scheduleFrom(Date date) throws ComponentPersistException
      Schedule a job from a given date.
      Parameters:
      date - The date to schedule the job from.
      Returns:
      true if the job is scheduled again, false if it is not to be scheduled again.
      Throws:
      ComponentPersistException
    • getClock

      public Clock getClock()
      Get the current clock.
      Returns:
      The clock
    • setClock

      public void setClock(Clock clock)
      Set the clock. Only useful for testing.
      Parameters:
      clock - The clock.
    • setNextDue

      public void setNextDue(Date nextDue) throws OddjobLockedException
      Manually set the Next Due Date.
      Parameters:
      nextDue - The Next Due Date. May be null.
      Throws:
      OddjobLockedException
    • getNextDue

      public Date getNextDue()
      Get the next due date.
      Returns:
      The next due date
    • internalSetNextDue

      protected boolean internalSetNextDue(Date nextDue) throws ComponentPersistException
      Set the next due date.
      Parameters:
      nextDue - The date schedule is next due. If null the job won't be scheduled and the child state reflector will be called to reflect the state of the child job.
      Returns:
      true if the job was scheduled. False it wasn't.
      Throws:
      ComponentPersistException
    • getCurrent

      public ScheduleResult getCurrent()
      Get the current/next interval.
      Returns:
      The interval, null if not due again.
    • getLastDue

      public Date getLastDue()
      Get the last due date.
      Returns:
      The last due date, null when a timer starts for the first time.
    • setJob

      public void setJob(Runnable job)
      Reference Property:
      job

      Description

      The job to run when it's due.
      Required:
      Yes.
    • getLimits

      protected abstract Interval getLimits()
      Implementation provided by sub classes so limits are available in scheduleFrom(Date).
      Returns:
      The limits, or null. Retry has limits, timer doesn't.
    • reschedule

      protected boolean reschedule() throws ComponentPersistException
      Reschedule a job.
      Returns:
      True if it was schedule, false if it wasn't.
      Throws:
      ComponentPersistException
    • reset

      protected void reset(Resettable job)
      Implementation provided by sub classes to decide what kind of reset to send to the child. Timer sends a hard reset, Retry sends a soft reset.
      Parameters:
      job - The child job that will be reset.
    • handleChildState

      protected void handleChildState(StateEvent event, StateListener listener) throws ComponentPersistException
      Throws:
      ComponentPersistException
    • changeStateLocked

      protected boolean changeStateLocked(TimerState required)
    • getHaltOn

      public StateCondition getHaltOn()
    • setHaltOn

      public void setHaltOn(StateCondition haltOn)
    • getDefaultHaltOn

      protected abstract StateCondition getDefaultHaltOn()
    • isSkipMissedRuns

      protected abstract boolean isSkipMissedRuns()
    • getReset

      public ResetAction getReset()
    • setReset

      public void setReset(ResetAction reset)
    • getDefaultReset

      protected abstract ResetAction getDefaultReset()