Package org.oddjob.events
Class EventJobBase<T>
- Type Parameters:
T- The type of the event or trigger.
- All Implemented Interfaces:
Serializable,Runnable,Consumer<T>,ArooaContextAware,ArooaSessionAware,Outbound<T>,Forceable,PropertyChangeNotifier,Iconic,LogEnabled,Resettable,Stateful,Stoppable,Structural
public abstract class EventJobBase<T>
extends StructuralJob<Object>
implements Consumer<T>, Outbound<T>
Base class for Jobs that react to events.
- Author:
- Rob Gordon.
- See Also:
-
Field Summary
Fields inherited from class org.oddjob.framework.extend.StructuralJob
childHelper, destroy, stop, structuralState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidexecute()Execute this job.protected StateOperatorSubclasses must provide theStateOperatorthat will decide how to evaluate the children's state.getTo()booleanprotected abstract voidonImmediateEvent(T event) Do something with an event received immediately before the subscribe method has returned.protected abstract voidonLaterEvent(T event, Object job, Executor executor) Called when an event is received after subscription.protected voidonStop()Allow sub classes to do something on stop.protected abstract voidonSubscriptionStarted(Object job, Executor executor) Called once the subscription has started.protected voidpostStop()Subclasses can override to perform actions once children have stopped.voidsetBeDestination(boolean beDestination) voidsetEventSource(EventSource<T> eventSource) voidsetExecutorService(ExecutorService executorService) voidAdd a child job.voidSet the out bound destination.protected voidsetTrigger(T trigger) protected voidStart the child state reflector.protected abstract StateListenerUsed by subclasses to provide a state listener to be added to the child job.protected voidprotected voidMethods inherited from class org.oddjob.framework.extend.StructuralJob
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onReset, onSoftReset, 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
-
EventJobBase
public EventJobBase()
-
-
Method Details
-
setExecutorService
-
getInitialStateOp
Description copied from class:StructuralJobSubclasses must provide theStateOperatorthat will decide how to evaluate the children's state.- Specified by:
getInitialStateOpin classStructuralJob<Object>- Returns:
- A State Operator. Must not be null.
-
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<Object>
-
execute
Description copied from class:StructuralJobExecute this job.- Specified by:
executein classStructuralJob<Object>- Throws:
Throwable
-
onImmediateEvent
Do something with an event received immediately before the subscribe method has returned.- Parameters:
event- The event.
-
onSubscriptionStarted
Called once the subscription has started.- Parameters:
job- The job to execute if any.executor- The executor to use to execute the job.
-
onLaterEvent
Called when an event is received after subscription. There is no guarantee that this will be called after theonSubscriptionStarted(Object, Executor)method, implementors are responsible for their own synchronisation if required.- Parameters:
event- The event.
-
stateOnChildComplete
Used by subclasses to provide a state listener to be added to the child job.- Returns:
- A State Listener. Must not be null.
-
unsubscribe
protected void unsubscribe() -
switchToChildStateReflector
protected void switchToChildStateReflector() -
onStop
protected void onStop()Description copied from class:StructuralJobAllow sub classes to do something on stop.- Overrides:
onStopin classStructuralJob<Object>
-
postStop
protected void postStop()Description copied from class:StructuralJobSubclasses can override to perform actions once children have stopped.- Overrides:
postStopin classStructuralJob<Object>
-
accept
-
isBeDestination
public boolean isBeDestination() -
setBeDestination
public void setBeDestination(boolean beDestination) -
setTo
Description copied from interface:OutboundSet the out bound destination. -
getTo
-
setTrigger
-
getTrigger
-
getEventSource
-
setEventSource
-
setJobs
Add a child job.- Parameters:
child- A child- Reference Property:
- jobs
- Required:
- No, but pointless if missing.
Description
The child jobs.
-