org.oddjob.scheduling
Class Retry

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.BasePrimary
          extended by org.oddjob.scheduling.ScheduleBase
              extended by org.oddjob.scheduling.TimerBase
                  extended by org.oddjob.scheduling.Retry
All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, ArooaSessionAware, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable, Structural

public class Retry
extends TimerBase

Description

This is a timer that runs it's job according to the schedule until the schedule expires or the job completes successfully.

Example

File Polling. Check every 5 seconds for a file.
<oddjob id="this">
    <job>
        <scheduling:retry name="File Polling Example" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
            <schedule>
                <schedules:interval interval="00:00:05"/>
            </schedule>
            <job>
                <sequential id="look" name="Look for files">
                    <jobs>
                        <exists file="${this.dir}/work/*.foo" id="check" name="Check File Exists"/>
                        <echo name="Echo to Console">Found ${check.exists[0]}</echo>
                    </jobs>
                </sequential>
            </job>
        </scheduling:retry>
    </job>
</oddjob>

Example

Using Retry with a Timer. A daily job retries twice.
<oddjob xmlns:schedules="http://rgordon.co.uk/oddjob/schedules" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling" xmlns:state="http://rgordon.co.uk/oddjob/state">
    <job>
        <scheduling:timer id="timer">
            <schedule>
                <schedules:daily from="08:00"/>
            </schedule>
            <job>
                <scheduling:retry id="retry">
                    <schedule>
                        <schedules:count count="2"/>
                    </schedule>
                    <job>
                        <state:flag id="flag-job" state="EXCEPTION"/>
                    </job>
                </scheduling:retry>
            </job>
        </scheduling:timer>
    </job>
</oddjob>
See Also:
Serialized Form
Author:
Rob Gordon.

Field Summary
 
Fields inherited from class org.oddjob.scheduling.TimerBase
contextData
 
Fields inherited from class org.oddjob.scheduling.ScheduleBase
begun, childHelper, childStateReflector, stateHandler, stop, structuralState
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
Retry()
           
 
Method Summary
protected  void begin()
          Sub classes must override this to submit the first execution.
 Interval getLimits()
          Implementation provided by sub classes so limits are available in TimerBase.scheduleFrom(Date).
protected  StateOperator getStateOp()
          Sub classes provide the state operator that is used to calculate the subclasses completion state.
protected  void rescheduleOn(State state)
          Implementation provided by sub classes to decide how to reschedule based on the state of the child job.
protected  void reset(Resetable job)
          Implementation provided by sub classes to decide what kind of reset to send to the child.
 void setLimits(Interval limits)
           
 
Methods inherited from class org.oddjob.scheduling.TimerBase
CancelAndStopChild, getClock, getCurrent, getLastDue, getNextDue, getSchedule, getTimeZone, internalSetNextDue, onReset, onStop, postStop, scheduleFrom, setClock, setJob, setNextDue, setReschedule, setSchedule, setScheduleExecutorService, setTimeZone
 
Methods inherited from class org.oddjob.scheduling.ScheduleBase
addStructuralListener, fireDestroyedState, getStateChanger, hardReset, onDestroy, removeStructuralListener, run, setStateStartingAndIconSleeping, softReset, stateHandler, stop
 
Methods inherited from class org.oddjob.framework.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toString
 
Methods inherited from class org.oddjob.framework.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
 

Constructor Detail

Retry

public Retry()
Method Detail

getStateOp

protected StateOperator getStateOp()
Description copied from class: ScheduleBase
Sub classes provide the state operator that is used to calculate the subclasses completion state.

Specified by:
getStateOp in class ScheduleBase
Returns:
The operator. Must not be null.

begin

protected void begin()
              throws ComponentPersistException
Description copied from class: ScheduleBase
Sub classes must override this to submit the first execution.

Overrides:
begin in class TimerBase
Throws:
ComponentPersistException

setLimits

public void setLimits(Interval limits)

getLimits

public Interval getLimits()
Description copied from class: TimerBase
Implementation provided by sub classes so limits are available in TimerBase.scheduleFrom(Date).

Specified by:
getLimits in class TimerBase
Returns:
The limits, or null. Retry has limits, timer doesn't.

rescheduleOn

protected void rescheduleOn(State state)
                     throws ComponentPersistException
Description copied from class: TimerBase
Implementation provided by sub classes to decide how to reschedule based on the state of the child job.

Specified by:
rescheduleOn in class TimerBase
Parameters:
state - The completion state of the child job.
Throws:
ComponentPersistException

reset

protected void reset(Resetable job)
Description copied from class: TimerBase
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.

Specified by:
reset in class TimerBase
Parameters:
job - The child job that will be reset.