public abstract class AbstractActivityEventHandler extends AbstractEventHandler implements ActivityEventHandler
EventHandler as well as declining
all signals sent while the handler is executing an activity. Additionally it
provides simple data structures for the session contexts of the activities
that await an event.| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.ConcurrentMap<java.lang.String,EBPInstanceReference> |
contexts
All activities that are currently registered for event handling indexed by
the source IDs.
|
protected ActivityEventManager |
eventManager
The event manager for communicating with the runtime service.
|
consuming, critical, exclusive, id, interruptible, logger| Constructor and Description |
|---|
AbstractActivityEventHandler(Registry registry,
boolean exclusive,
boolean consuming,
boolean critical,
ActivityEventManager eventManager)
Creates a new event handler having the designated ID and the designated
flags.
|
AbstractActivityEventHandler(java.lang.String id,
boolean exclusive,
boolean consuming,
boolean critical,
ActivityEventManager eventManager)
Creates a new event handler having the designated ID and the designated
flags.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
canHandle(Event event,
boolean consumed)
Gets whether the designated event can be handled by this (sub-)class.
|
boolean |
close(java.lang.String sessionID)
Instructs the activity handler to close the activity that is currently
running with the designated session ID.
|
boolean |
handleEvent(Event eve,
boolean consumed)
This method actually processes an event.
|
void |
init(java.lang.String sourceID,
SimpleSessionContext sessionContext)
Initialises the handling of an event for the activity identified by the
designated session context.
|
boolean |
kill(java.lang.String sessionID)
Instructs the activity handler to kill the activity that is currently
running with the designated session ID.
|
protected abstract boolean |
processEvent(Event event,
ActivityInstance activity,
DataContext dataContext)
Processes the designated event for the designated activity instance.
|
void |
remove(java.lang.String sourceID)
Removes a registered source from this activity event handler.
|
boolean |
reset(java.lang.String sessionID)
Instructs the activity handler to reset the activity that is currently
running with the designated session ID.
|
boolean |
signal(java.lang.String sessionID,
int signal)
Signals the designated signal to the activity that is currently running
with the designated session ID.
|
boolean |
suspend(java.lang.String sessionID)
Instructs the activity handler to suspend the activity that is currently
running with the designated session ID.
|
getID, isConsuming, isCritical, isExclusive, isInterruptibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetID, isConsuming, isExclusive, isInterruptibleprotected final java.util.concurrent.ConcurrentMap<java.lang.String,EBPInstanceReference> contexts
protected final ActivityEventManager eventManager
public AbstractActivityEventHandler(java.lang.String id,
boolean exclusive,
boolean consuming,
boolean critical,
ActivityEventManager eventManager)
id - The ID of this handler (usually the plugin ID).exclusive - Whether this handler needs to handle events exclusively.consuming - Whether this handler may consume events. If the handler is
consuming, it is also exclusive.critical - Whether this handler is critical. If the handler is
critical, it will also be exclusive.eventManager - The event manager for communicating with the runtime
service.public AbstractActivityEventHandler(Registry registry, boolean exclusive, boolean consuming, boolean critical, ActivityEventManager eventManager)
registry - The registry to get the ID of this handler (the simple name
of the plugin instance).exclusive - Whether this handler needs to handle events exclusively.consuming - Whether this handler may consume events. If the handler is
consuming, it is also exclusive.critical - Whether this handler is critical. If the handler is
critical, it will also be exclusive.eventManager - The event manager for communicating with the runtime
service.public void init(java.lang.String sourceID,
SimpleSessionContext sessionContext)
ActivityEventHandlerinit in interface ActivityEventHandlersourceID - The ID of the source that waits for an event of the
activity of the designated session context.sessionContext - The session context for the activity that is to be
executed and terminated as soon as the appropriate event is
handled.ExecutableComponent.init(de.aristaflow.adept2.model.runtimeenvironment.SessionContext)protected abstract boolean canHandle(Event event, boolean consumed)
event - The event which is about to be handled.consumed - Whether the event has been consumed by a previous event
handler.true).protected abstract boolean processEvent(Event event, ActivityInstance activity, DataContext dataContext) throws ApplicationEnvironmentException, ApplicationFailedException
event - The event to be processed.activity - The activity for which to process event. This also provides
the configuration of the activity and also the defined output
parameters.dataContext - The data context to write the values of the output
parameters to.true).ApplicationEnvironmentException - If the designated activity or the
data context do not have the values expected for processing the
event, for instance an output parameter is missing.ApplicationFailedException - If processing the event fails, an
ApplicationFailedException will be thrown.public boolean handleEvent(Event eve, boolean consumed) throws EventHandlingException
EventHandlerhandleEvent in interface EventHandlereve - The event that occurred and for which this event handler is
registered.consumed - Whether the event has been consumed by a previous event
handler.true).EventHandlingException - If there have been problems handling the
event, an EventHandlingException may be thrown. If
this is critical, the event handling for the current event will
stop. If it is non-critical, other event handlers will also get
the event for handling it. public void remove(java.lang.String sourceID)
ActivityEventHandlerActivityEventHandler.init(String, SimpleSessionContext). remove in interface ActivityEventHandlersourceID - The ID of the source for a registered activity that is to
be removed and no event for it should be handled.public boolean reset(java.lang.String sessionID)
ActivityEventHandlerExecutableComponent the activity handler does not need to reset the
activity but can react arbitrarily to this request. However, unlike
ExecutableComponent, activity event handlers need to be
synchronised appropriately since this method is called asynchronously.reset in interface ActivityEventHandlersessionID - The ID of the execution session which to close.ExecutableComponent.reset()public boolean signal(java.lang.String sessionID,
int signal)
ActivityEventHandlerExecutableComponent the activity handler does not need to signal the
activity but can react arbitrarily to this request. However, unlike
ExecutableComponent, activity event handlers need to be
synchronised appropriately since this method is called asynchronously.signal in interface ActivityEventHandlersessionID - The ID of the execution session which to signal.signal - The code that specifies the type of the signaled event.ExecutableComponent.signal(int)public boolean close(java.lang.String sessionID)
ActivityEventHandlerExecutableComponent the activity handler does not need to close the
activity but can react arbitrarily to this request. However, unlike
ExecutableComponent, activity event handlers need to be
synchronised appropriately since this method is called asynchronously.close in interface ActivityEventHandlersessionID - The ID of the execution session which to close.ExecutableComponent.close()public boolean suspend(java.lang.String sessionID)
ActivityEventHandlerExecutableComponent the activity handler does not need to suspend the
activity but can react arbitrarily to this request. However, unlike
ExecutableComponent, activity event handlers need to be
synchronised appropriately since this method is called asynchronously.suspend in interface ActivityEventHandlersessionID - The ID of the execution session which to close.ExecutableComponent.suspend()public boolean kill(java.lang.String sessionID)
ActivityEventHandlerExecutableComponent the activity handler does not need to kill the
activity but can react arbitrarily to this request. However, unlike
ExecutableComponent, activity event handlers need to be
synchronised appropriately since this method is called asynchronously.kill in interface ActivityEventHandlersessionID - The ID of the execution session which to close.ExecutableComponent.kill()