public class Trigger<T> extends EventJobBase<T>
Trigger
. The intention being that it has the ability
to fire off any event, not just a state change.
The job has two children; the first being the source of the event that causes the trigger, and the second is the job that is run as the result of the trigger firing.
<oddjob> <job> <sequential name="Trigger on Two Things"> <jobs> <bean class="org.oddjob.events.Trigger" id="trigger"> <jobs> <bean class="org.oddjob.state.expr.StateExpressionType"> thing1 is success and thing2 is success and not (thing3 is success or thing4 is success) </bean> <echo id="notify" name="Triggered Job">You ran two things!</echo> </jobs> </bean> <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> <echo id="thing3" name="Don't Run me!">Uh oh!</echo> <echo id="thing4" name="Don't Run me!">Uh oh!</echo> </jobs> </folder> </jobs> </sequential> </job> </oddjob>
<oddjob> <job> <parallel> <jobs> <bus:queue id="queue" xmlns:bus="oddjob:beanbus"/> <bus:bus xmlns:bus="oddjob:beanbus"> <of> <bus:driver> <values> <value value="${queue}"/> </values> </bus:driver> <bus:filter id="filter"> <predicate> <bean class="org.oddjob.events.TriggerTest$OnlyApple"/> </predicate> </bus:filter> <events:trigger beDestination="true" id="trigger" xmlns:events="oddjob:events"> <jobs> <sequential> <jobs> <echo id="result"> Result: ${trigger.trigger} </echo> <stop job="${queue}" name="Stop Queue"/> </jobs> </sequential> </jobs> </events:trigger> </of> </bus:bus> <folder> <jobs> <set id="put1" name="Put Banana"> <values> <value key="queue.put" value="banana"/> </values> </set> <set id="put2" name="Put Apple"> <values> <value key="queue.put" value="Apple"/> </values> </set> </jobs> </folder> </jobs> </parallel> </job> </oddjob>
<oddjob> <job> <events:trigger id="trigger" xmlns:events="oddjob:events"> <jobs> <bus:driver xmlns:bus="oddjob:beanbus"> <values> <list> <values> <value value="foo"/> </values> </list> </values> </bus:driver> <echo id="echo"> ${trigger.trigger} </echo> </jobs> </events:trigger> </job> </oddjob>
childHelper, destroy, stop, structuralState
Constructor and Description |
---|
Trigger() |
Modifier and Type | Method and Description |
---|---|
protected void |
onImmediateEvent(T value)
Do something with an event received immediately before the subscribe method has returned.
|
protected void |
onLaterEvent(T value,
java.lang.Object job,
java.util.concurrent.Executor executor)
Called when an event is received after subscription.
|
protected void |
onReset()
Allow sub classes to do something on reset.
|
protected void |
onSubscriptionStarted(java.lang.Object job,
java.util.concurrent.Executor executor)
Called once the subscription has started.
|
protected StateListener |
stateOnChildComplete() |
accept, execute, getEventSource, getInitialStateOp, getTo, getTrigger, isBeDestination, onStop, postStop, setBeDestination, setEventSource, setExecutorService, setJobs, setTo, setTrigger, startChildStateReflector, switchToChildStateReflector, unsubscribe
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onSoftReset, removeStructuralListener, run, softReset, stateHandler, stop, stopChildStateReflector, waitForChildrenOnStop
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
protected void onReset()
StructuralJob
onReset
in class StructuralJob<java.lang.Object>
protected void onImmediateEvent(T value)
EventJobBase
onImmediateEvent
in class EventJobBase<T>
value
- The event.protected void onSubscriptionStarted(java.lang.Object job, java.util.concurrent.Executor executor)
EventJobBase
onSubscriptionStarted
in class EventJobBase<T>
job
- The job to execute if any.executor
- The executor to use to execute the job.protected void onLaterEvent(T value, java.lang.Object job, java.util.concurrent.Executor executor)
EventJobBase
EventJobBase.onSubscriptionStarted(Object, Executor)
method,
implementors are responsible for their own synchronisation if required.onLaterEvent
in class EventJobBase<T>
value
- The event.protected StateListener stateOnChildComplete()
stateOnChildComplete
in class EventJobBase<T>