Interface ActivityEventHandler

All Superinterfaces:
EventHandler
All Known Implementing Classes:
AbstractActivityEventHandler, FileEventActivityHandler, MailEventActivityHandler

public interface ActivityEventHandler extends EventHandler
An ActivityEventHandler extends an event handler by the means to combine event handling and activity execution. That is, an activity waits for a specific event. As soon as the event occurs, arbitrary data from the event is provided to the data context of the activity and the activity terminates and thus the corresponding process instance continues.
Each activity waiting for an event is registered at an activity event handler. Afterwards the activity is usually suspended or reset so that it is not active any more. Registration is done via the SimpleSessionContext of an activity. The activity handler fetches all information from the session context it needs. This incorporates the mapping of the corresponding event to the activity (the handler usually waits for several events for different activities). Additionally, the activity usually has some output parameters that have to be taken over from the event. How to map data of the event to the output parameters is usually provided by the configuration of an activity.
As soon as an event arrives, an activity event handler checks for whether there is an activity registered for it. If there is one, the handler resumes or starts the activity, writes the output parameters depending on the event (or any other action that the activity requires as event handler) and terminates the activity. Since this behaviour is very similar to ExecutableComponent an activity handler has a very similar interface. Besides the registration of an activity (init(String, SimpleSessionContext)), an activity handler has the signalling interface that allows to control the activity execution from the outside. However, since event handling is usually rather fast, most activity event handler do not need to react on signals.
Author:
Ulrich Kreher
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    close(String sessionID)
    Instructs the activity handler to close the activity that is currently running with the designated session ID.
    void
    init(String sourceID, SimpleSessionContext sessionContext)
    Initialises the handling of an event for the activity identified by the designated session context.
    boolean
    kill(String sessionID)
    Instructs the activity handler to kill the activity that is currently running with the designated session ID.
    void
    remove(String sourceID)
    Removes a registered source from this activity event handler.
    boolean
    reset(String sessionID)
    Instructs the activity handler to reset the activity that is currently running with the designated session ID.
    boolean
    signal(String sessionID, int signal)
    Signals the designated signal to the activity that is currently running with the designated session ID.
    boolean
    suspend(String sessionID)
    Instructs the activity handler to suspend the activity that is currently running with the designated session ID.

    Methods inherited from interface de.aristaflow.adept2.model.events.handler.EventHandler

    getID, handleEvent, isConsuming, isExclusive, isInterruptible
  • Method Details

    • init

      void init(String sourceID, SimpleSessionContext sessionContext)
      Initialises the handling of an event for the activity identified by the designated session context. The activity handler thus prepares itself for handling the corresponding event. When handling the event, the handler relates the event to the appropriate activity and provides the required information from the event to the activity. After handling has completed, the handler may expect the activity to be terminated and therefore drop its session context.
      This method needs to be synchronised appropriately since this method is called asynchronously.
      Parameters:
      sourceID - 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.
      See Also:
    • remove

      void remove(String sourceID)
      Removes a registered source from this activity event handler. This is used in case the activity is for some reason discarded. The source ID is that of the registered session context used in init(String, SimpleSessionContext).
      This method will only be called for exceptional cases. Implementations have to take care of removal after a successful event handling themselves.
      Parameters:
      sourceID - The ID of the source for a registered activity that is to be removed and no event for it should be handled.
    • close

      boolean close(String sessionID)
      Instructs the activity handler to close the activity that is currently running with the designated session ID. The session ID is that of the current execution session and usually not the one the activity has been registered with.
      Like an ExecutableComponent 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.
      Parameters:
      sessionID - The ID of the execution session which to close.
      Returns:
      Whether the activity handler is about to react to this close request.
      See Also:
    • reset

      boolean reset(String sessionID)
      Instructs the activity handler to reset the activity that is currently running with the designated session ID. The session ID is that of the current execution session and usually not the one the activity has been registered with.
      Like an ExecutableComponent 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.
      Parameters:
      sessionID - The ID of the execution session which to close.
      Returns:
      Whether the activity handler is about to react to this reset request.
      See Also:
    • signal

      boolean signal(String sessionID, int signal)
      Signals the designated signal to the activity that is currently running with the designated session ID. The session ID is that of the current execution session and usually not the one the activity has been registered with.
      Like an ExecutableComponent 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.
      Parameters:
      sessionID - The ID of the execution session which to signal.
      signal - The code that specifies the type of the signaled event.
      Returns:
      Whether the activity handler is about to react to this signal request.
      See Also:
    • suspend

      boolean suspend(String sessionID)
      Instructs the activity handler to suspend the activity that is currently running with the designated session ID. The session ID is that of the current execution session and usually not the one the activity has been registered with.
      Like an ExecutableComponent 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.
      Parameters:
      sessionID - The ID of the execution session which to close.
      Returns:
      Whether the activity handler is about to react to this suspend request.
      See Also:
    • kill

      boolean kill(String sessionID)
      Instructs the activity handler to kill the activity that is currently running with the designated session ID. The session ID is that of the current execution session and usually not the one the activity has been registered with.
      Like an ExecutableComponent 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.
      Parameters:
      sessionID - The ID of the execution session which to close.
      Returns:
      Whether the activity handler is about to react to this kill request.
      See Also: