public class Trigger extends ScheduleBase
Once the trigger's job runs the trigger will reflect the state of the it's job. The trigger will continue to reflect it's job's state until it is reset.
Subsequent state changes in the triggering job are ignored until the trigger is reset and re-run.
If the triggering job is destroyed, because it is deleted or on a remote server the trigger will enter an exception state.
<oddjob id="this"> <job> <sequential name="Trigger Example"> <jobs> <scheduling:trigger name="Alert Trigger" on="${important}" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling"> <job> <echo name="Alert">Important job has completed!</echo> </job> </scheduling:trigger> <folder name="A Folder of Jobs"> <jobs> <echo id="important" name="Run Me">I'm important</echo> </jobs> </folder> </jobs> </sequential> </job> </oddjob>
<oddjob xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling" xmlns:state="http://rgordon.co.uk/oddjob/state"> <job> <sequential name="Trigger on Two Things"> <jobs> <scheduling:trigger id="trigger" on="${watch-both}"> <job> <echo id="notify" name="Triggered Job">You ran two things!</echo> </job> </scheduling:trigger> <state:and id="watch-both" name="Watch Two Jobs"> <jobs> <state:mirror job="${thing1}" name="Mirror Job 1"/> <state:mirror job="${thing2}" name="Mirror Job 2"/> </jobs> </state:and> <folder name="A Folder of Jobs"> <jobs> <echo id="thing1" name="Run me!">Thank you</echo> <echo id="thing2" name="Run me!">Thank you</echo> </jobs> </folder> </jobs> </sequential> </job> </oddjob>
<oddjob id="this" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling"> <job> <sequential name="Trigger Example"> <jobs> <scheduling:trigger id="trigger" name="Alert Trigger" on="${our-job}" state="FAILURE" cancelWhen="FINISHED"> <job> <echo name="Alert" id="triggered-job">That job shouldn't fail!</echo> </job> </scheduling:trigger> <folder name="A Folder of Jobs"> <jobs> <echo id="our-job" name="Run Me">I won't fail</echo> </jobs> </folder> </jobs> </sequential> </job> </oddjob>
examples/scheduling/dailyftp.xml
)
uses a trigger to send an email if one of the FTP transfers fails.begun, childHelper, childStateReflector, stateHandler, stop
Constructor and Description |
---|
Trigger() |
Modifier and Type | Method and Description |
---|---|
protected void |
begin()
Sub classes must override this to submit the first execution.
|
StateCondition |
getCancelWhen() |
Stateful |
getOn() |
StateCondition |
getState() |
protected StateOperator |
getStateOp()
Sub classes provide the state operator that is used to calculate the subclasses
completion state.
|
boolean |
isNewOnly() |
protected void |
onStop()
Subclasses can override to perform stopping operations.
|
protected void |
postStop()
Subclasses can override to perform actions once children have stopped.
|
void |
setCancelWhen(StateCondition cancelWhen) |
void |
setExecutorService(java.util.concurrent.ExecutorService executor) |
void |
setJob(java.lang.Runnable job) |
void |
setNewOnly(boolean newEventOnly) |
void |
setOn(Stateful triggerOn) |
void |
setState(StateCondition state) |
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, onDestroy, onReset, removeStructuralListener, run, softReset, stateHandler, stop
configure, getName, logger, logger, loggerName, save, setName, toString
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addStateListener, lastStateEvent, removeStateListener
@Inject public void setExecutorService(java.util.concurrent.ExecutorService executor)
protected StateOperator getStateOp()
ScheduleBase
getStateOp
in class ScheduleBase
protected void begin()
ScheduleBase
begin
in class ScheduleBase
protected void onStop()
ScheduleBase
onStop
in class ScheduleBase
protected void postStop()
ScheduleBase
postStop
in class ScheduleBase
public void setJob(java.lang.Runnable job)
Property: job
Description: The job to run when the trigger fires.
Required: Yes.
public StateCondition getState()
public void setState(StateCondition state)
public StateCondition getCancelWhen()
public void setCancelWhen(StateCondition cancelWhen)
public boolean isNewOnly()
public void setNewOnly(boolean newEventOnly)
public Stateful getOn()
public void setOn(Stateful triggerOn)