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
Direct Known Subclasses:
Trigger, When

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:
  • Constructor Details

    • EventJobBase

      public EventJobBase()
  • Method Details

    • setExecutorService

      @Inject public void setExecutorService(ExecutorService executorService)
    • getInitialStateOp

      protected StateOperator getInitialStateOp()
      Description copied from class: StructuralJob
      Subclasses must provide the StateOperator that will decide how to evaluate the children's state.
      Specified by:
      getInitialStateOp in class StructuralJob<Object>
      Returns:
      A State Operator. Must not be null.
    • startChildStateReflector

      protected void startChildStateReflector()
      Description copied from class: StructuralJob
      Start the child state reflector. Sub classes override this if they need to start the child state reflector at a different time.
      Overrides:
      startChildStateReflector in class StructuralJob<Object>
    • execute

      protected void execute() throws Throwable
      Description copied from class: StructuralJob
      Execute this job.
      Specified by:
      execute in class StructuralJob<Object>
      Throws:
      Throwable
    • onImmediateEvent

      protected abstract void onImmediateEvent(T event)
      Do something with an event received immediately before the subscribe method has returned.
      Parameters:
      event - The event.
    • onSubscriptionStarted

      protected abstract void onSubscriptionStarted(Object job, Executor executor)
      Called once the subscription has started.
      Parameters:
      job - The job to execute if any.
      executor - The executor to use to execute the job.
    • onLaterEvent

      protected abstract void onLaterEvent(T event, Object job, Executor executor)
      Called when an event is received after subscription. There is no guarantee that this will be called after the onSubscriptionStarted(Object, Executor) method, implementors are responsible for their own synchronisation if required.
      Parameters:
      event - The event.
    • stateOnChildComplete

      protected abstract StateListener 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: StructuralJob
      Allow sub classes to do something on stop.
      Overrides:
      onStop in class StructuralJob<Object>
    • postStop

      protected void postStop()
      Description copied from class: StructuralJob
      Subclasses can override to perform actions once children have stopped.
      Overrides:
      postStop in class StructuralJob<Object>
    • accept

      public void accept(T t)
      Specified by:
      accept in interface Consumer<T>
    • isBeDestination

      public boolean isBeDestination()
    • setBeDestination

      public void setBeDestination(boolean beDestination)
    • setTo

      public void setTo(Consumer<? super T> destination)
      Description copied from interface: Outbound
      Set the out bound destination.
      Specified by:
      setTo in interface Outbound<T>
      Parameters:
      destination -
    • getTo

      public Consumer<? super T> getTo()
    • setTrigger

      protected void setTrigger(T trigger)
    • getTrigger

      public T getTrigger()
    • getEventSource

      public EventSource<T> getEventSource()
    • setEventSource

      public void setEventSource(EventSource<T> eventSource)
    • setJobs

      public void setJobs(int index, Object child)
      Add a child job.
      Parameters:
      child - A child
      Reference Property:
      jobs

      Description

      The child jobs.
      Required:
      No, but pointless if missing.