Package org.oddjob.jobs.structural
Class RepeatJob
- All Implemented Interfaces:
Serializable,Runnable,ArooaContextAware,ArooaSessionAware,Forceable,PropertyChangeNotifier,Iconic,LogEnabled,Resettable,Stateful,Stoppable,Structural
- Author:
- Rob Gordon.
- See Also:
- Each value of a collection.
- Or a given number times.
- Or until the until property is true.
Description
This job will repeatedly run its child job. The repeat can be either for:Without either a until or a times or values the job will loop indefinitely.
Example
Repeat a job 3 times.
<oddjob>
<job>
<repeat times="3" id="repeat">
<job>
<echo>Hello ${repeat.count}</echo>
</job>
</repeat>
</job>
</oddjob>
Repeat a job 3 times with a sequence.
<oddjob>
<job>
<repeat id="each">
<values>
<sequence from="1" to="3"/>
</values>
<job>
<echo>Hello ${each.current}</echo>
</job>
</repeat>
</job>
</oddjob>
-
Field Summary
Fields inherited from class org.oddjob.framework.extend.StructuralJob
childHelper, destroy, stop, structuralState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidexecute()Execute this job.intgetCount()Getter for executor service.intgetIndex()protected StateOperatorSubclasses must provide theStateOperatorthat will decide how to evaluate the children's state.intgetTimes()Iterable<?> booleanisUntil()protected voidAllow sub classes to do something on HARD reset.protected voidonStop()Allow sub classes to do something on stop.voidsetExecutorService(ExecutorService executorService) Set theExecutorService.voidvoidsetTimes(int times) voidsetUntil(boolean until) voidprotected voidStart the child state reflector.Methods inherited from class org.oddjob.framework.extend.StructuralJob
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onReset, onSoftReset, postStop, removeStructuralListener, run, softReset, stateHandler, stop, stopChildStateReflector, waitForChildrenOnStopMethods inherited from class org.oddjob.framework.extend.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toStringMethods inherited from class org.oddjob.framework.extend.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSessionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
-
Constructor Details
-
RepeatJob
public RepeatJob()
-
-
Method Details
-
getInitialStateOp
Description copied from class:StructuralJobSubclasses must provide theStateOperatorthat will decide how to evaluate the children's state.- Specified by:
getInitialStateOpin classStructuralJob<Runnable>- Returns:
- A State Operator. Must not be null.
-
setExecutorService
Set theExecutorService.- Parameters:
executorService- The Executor Service.- Reference Property:
- executorService
- Required:
- No.
Description
The ExecutorService to use. This will be automatically set by Oddjob. -
getExecutorService
Getter for executor service.- Returns:
- The executor service or null if not set.
-
setJob
- Reference Property:
- job
- Required:
- Yes.
Description
The job who's execution to schedule. -
execute
protected void execute()Description copied from class:StructuralJobExecute this job.- Specified by:
executein classStructuralJob<Runnable>
-
onStop
Description copied from class:StructuralJobAllow sub classes to do something on stop.- Overrides:
onStopin classStructuralJob<Runnable>- Throws:
FailedToStopException
-
startChildStateReflector
protected void startChildStateReflector()Description copied from class:StructuralJobStart the child state reflector. Sub classes override this if they need to start the child state reflector at a different time.- Overrides:
startChildStateReflectorin classStructuralJob<Runnable>
-
onHardReset
protected void onHardReset()Description copied from class:StructuralJobAllow sub classes to do something on HARD reset.- Overrides:
onHardResetin classStructuralJob<Runnable>
-
setValues
-
getValues
-
isUntil
public boolean isUntil() -
setUntil
public void setUntil(boolean until) -
getTimes
public int getTimes() -
setTimes
public void setTimes(int times) -
getCount
public int getCount() -
getIndex
public int getIndex()- Returns:
- The index.
- Reference Property:
- index
Description
The same as count. Provided so configurations can be swapped between this andForEachJobjob. -
getCurrent
-