Package org.oddjob.state.expr
Class StateExpressionType
java.lang.Object
org.oddjob.state.expr.StateExpressionType
- All Implemented Interfaces:
ArooaSessionAware,EventSource<InstantEvent<Boolean>>,InstantEventSource<Boolean>
public class StateExpressionType
extends Object
implements InstantEventSource<Boolean>, ArooaSessionAware
- Author:
- rob
Description
Evaluate a state expression that becomes an event source for triggering other jobs. used withTrigger and When.
Expressions are of the form:
[NOT] job-id IS job-condition
And can be chained with AND and OR and nested with parenthesis. Examples are:
job1 is success not job1 is success job1 is success or ( job2 is success and job3 is success)
Example
Runs a job when two other jobs complete, but only if one of the jobs hasn't been run.
<oddjob>
<job>
<sequential>
<jobs>
<events:when id="when" xmlns:events="oddjob:events">
<jobs>
<events:watch name="Watch Jobs 1 and 2">
<eventSource>
<state:watch xmlns:state="http://rgordon.co.uk/oddjob/state">
job1 is COMPLETE
AND
job2 is COMPLETE
</state:watch>
</eventSource>
</events:watch>
<state:if xmlns:state="http://rgordon.co.uk/oddjob/state">
<jobs>
<sequential>
<jobs>
<state:evaluate id="check-job3" name="Is Job 3 Complete">
job3 is complete
</state:evaluate>
<check gt="${check-job3.evaluation.time}" value="${when.trigger.time}"/>
</jobs>
</sequential>
<state:flag/>
<run job="${job3}" name="Run Job 3"/>
</jobs>
</state:if>
</jobs>
</events:when>
<folder>
<jobs>
<echo id="job1" name="Job 1">
Hello
</echo>
<echo id="job2" name="Job 2">
World
</echo>
<echo id="job3" name="Job 3">
It's Done!
</echo>
</jobs>
</folder>
</jobs>
</sequential>
</job>
</oddjob>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetArooaSession(ArooaSession session) Accept the current Arooa Session.voidsetExpression(String expression) subscribe(Consumer<? super InstantEvent<Boolean>> consumer) Start listening for events.toString()
-
Constructor Details
-
StateExpressionType
public StateExpressionType()
-
-
Method Details
-
setArooaSession
Description copied from interface:ArooaSessionAwareAccept the current Arooa Session.- Specified by:
setArooaSessionin interfaceArooaSessionAware- Parameters:
session- The Arooa Session. Never null.
-
subscribe
Description copied from interface:InstantEventSourceStart listening for events.- Specified by:
subscribein interfaceEventSource<InstantEvent<Boolean>>- Specified by:
subscribein interfaceInstantEventSource<Boolean>- Parameters:
consumer- The consumer to receive events on.- Returns:
- Something that will stop events being sent and free any resources that were used to send the events.
-
getExpression
-
setExpression
-
toString
-