Class AbstractEventManager

All Implemented Interfaces:
ADEPT2Service, LogService, ServiceThreadHandling, ActivityEventManager, EventManager, InstanceStartEventManager
Direct Known Subclasses:
DefaultEventManager

@ConfigurationDescription(properties={@Property(name="LibDirectory",defaultValue="${arflow:arflow.libdir}",description="The name of the directory providing the JDBC libraries. This is actually the directory containing a directory named \'jdbc4\' which in turn contains the JDBC drivers."),,,,,,,,,,,,,,,,,}) public class AbstractEventManager extends AbstractNonPrivilegedService implements ActivityEventManager, InstanceStartEventManager
The event manager creates event handler and event sources. Polling event sources are regularly (depending on their configuration) executed. Event handlers may be preregistered for specific event sources in the configuration of this event manager. This allows for generic event handling without knowing the sources. Additionally, event sources can be started together with this event manager. Together with an appropriate event handler this can be used, for instance to start process instances as soon as the corresponding event occurs.

This event service also listens at the worklist for activities that need to wait for an event. These activities will be started activities to retrieve their configuration and the data context. Afterwards the corresponding event source will be created and the activity will be suspended or reset. Resuming or starting of the activity is then up to the corresponding event handler.

Besides simple polling sources, this event manager also supports shared event sources that poll for several sharing event sources. Occurred events are distributed among the registered sharing event sources. For instance, in case of an SQL database a sharing event sources may wait for specific using an SQL statement. Event sources having SQL statements that differ only in some values may be combined using one SQL statement. The result of the SQL statements, that are the rows of the result set, are distributed appropriately among the sharing event sources so that every event source gets the results it waits for.

  • Field Details

    • PREREGISTERED_EVENT_HANDLER

      public static final String PREREGISTERED_EVENT_HANDLER
      The configuration key for the pre-registered event handler per source.
      See Also:
    • CONF_LIB_DIRECTORY

      public static final String CONF_LIB_DIRECTORY
      Configuration key for the name of the directory providing the JDBC libraries (actually one level above the directory 'jdbc4' containing the drivers).
      See Also:
    • libDirectory

      protected final String libDirectory
      The name of the directory providing the JDBC libraries (actually one level above the directory 'jdbc4' containing the drivers).
    • CONF_SERVICE_TYPES_FOR_EVENTS

      public static final String CONF_SERVICE_TYPES_FOR_EVENTS
      Configuration key for the names of service types that are required for event sources and/or event handlers.
      See Also:
    • CONF_ADD_EVENT_SOURCE_RETRY_COUNT

      public static final String CONF_ADD_EVENT_SOURCE_RETRY_COUNT
      Configuration key: The number of retries for adding an event source.
      See Also:
    • addEventSourceRetryCount

      protected final int addEventSourceRetryCount
      The number of retries for adding an event source.
    • CONF_ADD_EVENT_SOURCE_RETRY_DELAY

      public static final String CONF_ADD_EVENT_SOURCE_RETRY_DELAY
      Configuration key: The time in milliseconds to wait before retrying to add an event source.
      See Also:
    • addEventSourceRetryDelay

      protected final long addEventSourceRetryDelay
      The time in milliseconds to wait before retrying to add an event source.
    • CONF_MIN_POOL_SIZE

      public static final String CONF_MIN_POOL_SIZE
      Configuration key: The minimal number of executor threads for polling events.
      See Also:
    • minPoolSize

      protected final int minPoolSize
      Minimal number of executor threads for polling events. These are at least 2.
    • CONF_QUEUE_LIMIT_POOL_STATISTICS

      protected static final String CONF_QUEUE_LIMIT_POOL_STATISTICS
      Configuration key: The total amount of tasks being the threshold for logging pool statistics.
      See Also:
    • queueLimitPoolStatistics

      protected final int queueLimitPoolStatistics
      The total amount of tasks being the threshold for logging pool statistics.
    • CONF_MIN_LOG_LEVEL_POOL_STATISTICS

      public static final String CONF_MIN_LOG_LEVEL_POOL_STATISTICS
      Configuration key: The log level which need to be reached for logging pool statistics. Pool statistics logs with a lower log level will be ignored.
      See Also:
    • minLogLevelPoolStatistics

      protected final Level minLogLevelPoolStatistics
      The log level which need to be reached for logging pool statistics. Pool statistics logs with a lower log level will be ignored.
    • pingWLMInterval

      protected final long pingWLMInterval
      The time interval in milliseconds which to regularly check whether the worklist manager is still available or available again.
    • reconnectWLMInterval

      protected final long reconnectWLMInterval
      The time interval in milliseconds which to regularly reconnect to the worklist manager if no push update was received yet.
    • reconnectLogLevel

      protected final Level reconnectLogLevel
      The log level that will be used to log that no push update was received yet.
    • CONF_CREATE_WORKLIST_SILENT_COUNT

      public static final String CONF_CREATE_WORKLIST_SILENT_COUNT
      Configuration key: The number of retries for creating (retrieving) a client worklist before logging the exception as critical.
      See Also:
    • createWorklistSilentCount

      protected final int createWorklistSilentCount
      The number of retries for creating (retrieving) a client worklist before logging the exception as critical.
    • CONF_CREATE_WORKLIST_RETRY_DELAY

      public static final String CONF_CREATE_WORKLIST_RETRY_DELAY
      Configuration key: The time in milliseconds to wait before retrying to create (retrieve) a client worklist.
      See Also:
    • createWorklistRetryDelay

      protected final long createWorklistRetryDelay
      The time in milliseconds to wait before retrying to create (retrieve) a client worklist.
    • CONF_POLLER_PRIORITY

      public static final String CONF_POLLER_PRIORITY
      Configuration key: The priority of the polling threads.
      See Also:
    • pollerPriority

      protected final int pollerPriority
      The priority of the polling threads.
    • CONF_HANDLER_MIN_POOL_SIZE

      public static final String CONF_HANDLER_MIN_POOL_SIZE
      Configuration key: The minimal number of executor threads for handling events by various sources.
      See Also:
    • handlerMinPoolSize

      protected final int handlerMinPoolSize
      Minimal number of executor threads for handling events.
    • CONF_HANDLER_PRIORITY

      public static final String CONF_HANDLER_PRIORITY
      Configuration key: The priority of the event handling threads used by various sources.
      See Also:
    • handlerPriority

      protected final int handlerPriority
      The priority of the event handling threads used by various sources.
    • CONF_HANDLER_QUEUE_LIMIT

      public static final String CONF_HANDLER_QUEUE_LIMIT
      Configuration key: The number of tasks in the executor queue that are allowed before warnings will be logged.
      See Also:
    • handlerQueueLimit

      protected final int handlerQueueLimit
      The number of tasks in the executor queue that are allowed before executor warnings will be logged.
    • resumeOnly

      protected final boolean resumeOnly
      Flag to indicate whether to resume items and not to start new ones.
    • updateInterval

      protected final long updateInterval
      Interval (in ms) for pushed updates.
    • MINIMAL_DELAY

      protected static final long MINIMAL_DELAY
      The minimal delay for the first poll of polling sources. Polling should not start earlier to allow for the corresponding handlers to be registered appropriately at the new source.
      See Also:
    • exmFactory

      protected ExecutionFactory exmFactory
      The factory for creating the execution context for starting instances.
    • filterFactory

      protected FilterFactory filterFactory
      The filter factory required for retrieving the "latest" template of a specific process type.
    • runtimeService

      protected RuntimeService runtimeService
      The runtime service for starting and terminating activities that wait for an event.
    • pm

      protected ProcessManager pm
      The process manager for retrieving templates to be started.
    • instanceControl

      protected InstanceControl instanceControl
      The control interface for starting instances.
    • activitySelecting

      protected ActivityStarting activitySelecting
      The interface for selecting an activity.
    • omm

      protected OrgModelManager omm
      The org model manager for checking the starter rule.
    • pollService

      protected LoggingScheduledThreadPoolExecutor pollService
      The service that executes the pollers that cause the events.
    • addService

      The executor that adds event sources.
    • handlerService

      protected ExecutorService handlerService
      The service that is shared among sources for asynchronous event handling.
    • worklistHandler

      protected de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandler worklistHandler
      The worklist handler creating event sources depending on the contents of the worklist.
    • dataLock

      protected final ReadWriteLock dataLock
      The lock protecting the data structures containing the handler and sources.
    • sources

      protected final Map<Pair<String,String>,Map<String,EventSource<?>>> sources
      All existing event sources indexed by event type and source type mapped to source ID and source.
    • sourceCount

      protected final ObjectCounting<Triple<String,String,String>> sourceCount
      The amount of sources per source ID. In case a source has been added several times it must not be removed until the last adder removes it again.
    • futures

      protected final Map<PollingSource<?>,ScheduledFuture<?>> futures
      /** All the event sources mapped to the corresponding futures from the poll service. This allows to terminate an event source.
    • sharedSources

      protected final Collection<SharedPollingSource<?>> sharedSources
      All shared polling sources. These need to be tracked separately so that they can be reused when adding a sharing event source.
    • handler

      protected final Map<Pair<String,String>,List<EventHandler>> handler
      All known event handler indexed by the event and source type they are registered for.
    • handlerSource

      protected final Map<EventHandler,Collection<EventSource<?>>> handlerSource
      All handler and the sources they are registered for.
    • supportedEventTypes

      protected Map<String,Class<? extends Event>> supportedEventTypes
      All event types that are supported by this event manager.
  • Constructor Details

    • AbstractEventManager

      protected AbstractEventManager(Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices) throws ConfigurationException
      Creates an event manager creating event sources and combining them with the appropriate event handlers. It also provides the means for starting instances or activities.
      Parameters:
      conf - The configuration of this service.
      registry - The registry for retrieving the services required by this service.
      startupRequiredServices - The services required by subclasses for starting and shutting down the event manager. This must neither be null nor contain null values.
      runtimeRequiredServices - The services required at runtime of the event manager. This must neither be null nor contain null values.
      Throws:
      ConfigurationException - If the password for this authenticated service cannot be parsed from the configuration, a ConfigurationException will be thrown.
    • AbstractEventManager

      @Deprecated(since="14.4.0", forRemoval=true) protected AbstractEventManager(Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices, Map<String,Class<? extends Event>> supportedEvents) throws ConfigurationException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates an event manager creating event sources and combining them with the appropriate event handlers. It also provides the means for starting instances or activities.
      Parameters:
      conf - The configuration of this service.
      registry - The registry for retrieving the services required by this service.
      startupRequiredServices - The services required by subclasses for starting and shutting down the event manager. This must neither be null nor contain null values.
      runtimeRequiredServices - The services required at runtime of the event manager. This must neither be null nor contain null values.
      supportedEvents - The events supported by subclasses. This may be null. This keys of this map will be used to preregister event sources and handlers. This is no longer required since the supported event types are determined via the event sources declared as plugins for this event manager.
      Throws:
      ConfigurationException - If the password for this authenticated service cannot be parsed from the configuration, a ConfigurationException will be thrown.
  • Method Details

    • mergeEventRequiredServices

      protected static String[] mergeEventRequiredServices(Configuration conf, String[] startupRequiredServices)
    • init

      public void init(URI[] localExportedUris, URI[] globalExportedUris) throws AbortServiceException
      Description copied from class: AbstractNonPrivilegedService
      Copies the designated URI array and stores it internally and authenticates to the system and sets the session factory.
      This method can be called any time in overriding init-methods.
      Specified by:
      init in interface ADEPT2Service
      Overrides:
      init in class AbstractNonPrivilegedService
      Parameters:
      localExportedUris - The URIs with which this service is exported locally or a local URI or an empty array for internal services.
      globalExportedUris - The URIs with which this service is published globally or null in case the service is not published.
      Throws:
      AbortServiceException - If authenticating at the security manager fails, an AbortServiceException will be thrown.
    • start

      public void start() throws AbortServiceException
      Description copied from class: AbstractADEPT2Service
      Method setting the status to the current time. Subclasses have to call this method!
      Specified by:
      start in interface ADEPT2Service
      Overrides:
      start in class AbstractADEPT2Service
      Throws:
      AbortServiceException - If this service cannot be started due to a severe problem, an AbortServiceException will be thrown. ADEPT2Service.shutdown(boolean) will not be called when aborting; the service has to shut down itself/clean up before throwing the exception.
    • shutdown

      public void shutdown(boolean emergency)
      Description copied from class: AbstractNonPrivilegedService
      Awaits the termination of the active sessions and nulls the session factory.
      Specified by:
      shutdown in interface ADEPT2Service
      Overrides:
      shutdown in class AbstractNonPrivilegedService
      Parameters:
      emergency - Whether the shutdown will be an emergency shutdown.
    • getSupportedEventTypes

      protected Map<String,Class<? extends Event>> getSupportedEventTypes(SessionToken session, ServiceAccess sa)
      Gets all event types declared via plugin types for this event manager. This retrieves all declared event source types and retrieves the corresponding event types from the corresponding classes.
      Parameters:
      session - The session which is used to check for access rights on plugin types retrieval.
      sa - The service access from which to retrieve the plugin types.
      Returns:
      A map containing the type names of all event sources declared as plugins for this event manager mapped to the class of the corresponding Event.
    • addPreregistered

      protected void addPreregistered(Configuration conf) throws ServiceNotKnownException, ConfigurationException
      Reads the event handler and sources from the configuration based on the supported event types, registers and starts them initially and adds them afterwards.
      Parameters:
      conf - The configuration from which to retrieve the event handler and event sources to be registered when initialising/starting this event manager.
      Throws:
      ServiceNotKnownException - If there are problems with the plugin configuration or no plugin configured at all for the pre-registered event handler or event sources, a ServiceNotKnownException will be thrown.
      ConfigurationException - If there are problems with the configuration of an event source, a ConfigurationException will be thrown.
    • addPreregistered

      protected void addPreregistered(Configuration conf, Iterator<String> sourceTypes) throws ServiceNotKnownException, ConfigurationException
      Reads the event handler and sources for the designated source types from the configuration, registers and starts them initially and adds them afterwards.
      Parameters:
      conf - The configuration from which to retrieve the event handler and event sources to be registered when initialising/starting this event manager.
      sourceTypes - The source types for which to retrieve the event handler and event sources to be registered when initialising/starting this event manager.
      Throws:
      ServiceNotKnownException - If there are problems with the plugin configuration or no plugin configured at all for the pre-registered event handler or event sources, a ServiceNotKnownException will be thrown.
      ConfigurationException - If there are problems with the configuration of an event source, a ConfigurationException will be thrown.
    • createSession

      public SessionToken createSession()
      Creates a new session token using the client session factory assigned to this service.

      Overridden to make it accessible within this package.

      Overrides:
      createSession in class AbstractNonPrivilegedService
      Returns:
      A new session token using the client session factory assigned to this service.
    • getHandlerExecutorService

      public ExecutorService getHandlerExecutorService()
      Gets an executor service for event handling by arbitrary event sources. This allows them to handle events asynchronously without creating too many threads.
      Returns:
      An executor service for event handling by arbitrary event sources allowing them to handle events asynchronously without creating too many threads.
    • removeAllSources

      protected void removeAllSources()
      Removes all currently active data sources and stops their polling.
    • getSupportedEventTypes

      public Map<String,Class<? extends Event>> getSupportedEventTypes(SessionToken session)
      Description copied from interface: EventManager
      Gets all the event types this event manager supports, that is, it can create event sources for these event types.
      Specified by:
      getSupportedEventTypes in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      Returns:
      All event types that are supported by this event manager and for which this event manager can create event sources. They are indexed by the event type name (which equals the plugin type name for event sources).
    • getEventSources

      public Collection<String> getEventSources(SessionToken session, String eventType, String sourceType)
      Description copied from interface: EventManager
      Gets the event sources that exist for the designated event type and source type.
      Specified by:
      getEventSources in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The event type for which to get the event sources.
      sourceType - The source type for which to get the event sources.
      Returns:
      The event sources registered for the designated event type and source type. In case no source exists for this event type and source type, the empty collection will be returned.
    • addEventSource

      public EventSource<?> addEventSource(SessionToken session, String eventType, String sourceType, String sourceID, Configuration conf) throws ConfigurationException, ServiceNotKnownException
      Description copied from interface: EventManager
      Adds an event source having the designated ID to the designated event type and event source. The designated configuration will complement the plugin configuration of the source. If there is already a source of the designated ID for the designated event type and source type, it will be returned. Event handler registered for the designated event type and source type will be registered at the new source.
      Specified by:
      addEventSource in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The type of which the source creates events.
      sourceType - The type of the source to add.
      sourceID - The unique (with respect to the event type and source type) ID of the source to add.
      conf - The configuration of the source which complements the plugin configuration.
      Returns:
      The newly created or the existing event source.
      Throws:
      ConfigurationException - If there are problems with the designated configuration, a ConfigurationException will be thrown.
      ServiceNotKnownException - If there are problems with the plugin configuration or no plugin configured at all for the designated source a ServiceNotKnownException will be thrown.
    • removeEventSource

      public EventSource<?> removeEventSource(SessionToken session, String eventType, String sourceType, String sourceID)
      Description copied from interface: EventManager
      Removes the event source having the designated event type, event source and ID. The removed event source will be returned. If no event source is found, null will be returned. All handler will be removed from the designated event source.
      Specified by:
      removeEventSource in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The event type of which to remove a source.
      sourceType - The type of which to remove a source.
      sourceID - The ID of the source to remove.
      Returns:
      The removed event source or null in case there is already an event source of the designated source ID.
    • getEventHandler

      public List<String> getEventHandler(SessionToken session, String eventType, String sourceType)
      Description copied from interface: EventManager
      Gets the event handler that are registered for the designated event type and source type.
      Specified by:
      getEventHandler in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The event type for which to get the event handler.
      sourceType - The source type for which to get the event handler.
      Returns:
      The event handler registered for the designated event type and source type in the order they are notified about the corresponding events. In case no handler is registered, the empty list will be returned.
    • addEventHandler

      public EventHandler addEventHandler(SessionToken session, String eventType, String sourceType, String handlerID, int index) throws ServiceNotKnownException
      Description copied from interface: EventManager
      Adds an event handler having the designated ID to the designated event type and event source at the designated position. If there is already an event handler of the designated ID for the designated event type and source type, it will be returned. An existing handler may change its position according to the provided one. The event handler will be registered at all existing sources of the designated event type and source type.
      Specified by:
      addEventHandler in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The event type for which to register the event handler.
      sourceType - The source type for which to register the event handler.
      handlerID - The unique (with respect to the event type and source type) ID of the handler to add.
      index - The (0-based) position in the handler list for the designated event type and source type.
      Returns:
      The newly created or the existing event handler.
      Throws:
      ServiceNotKnownException - If there are problems with the plugin configuration or no plugin configured at all for the designated source a ServiceNotKnownException will be thrown.
    • addEventHandler

      public EventHandler addEventHandler(SessionToken session, String eventType, String sourceType, EventHandler current, int index)
      Description copied from interface: EventManager
      Adds the designated event handler to the designated event type and event source at the designated position. If there is already an event handler of the designated ID for the designated event type and source type, it will be returned and the designated handler will be ignored. An existing handler may change its position according to the provided one. The event handler will be registered at all existing sources of the designated event type and source type.
      This method does not retrieve the handler as plugin and therefore does not need an appropriate plugin configuration for the handler.
      Specified by:
      addEventHandler in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The event type for which to register the event handler.
      sourceType - The source type for which to register the event handler.
      current - The handler which to add.
      index - The (0-based) position in the handler list for the designated event type and source type.
      Returns:
      The designated or the existing event handler.
    • addEventHandler

      protected EventHandler addEventHandler(SessionToken session, String eventType, String sourceType, String handlerID, EventHandler current, int index) throws ServiceNotKnownException
      Adds the designated event handler to the designated event type and source type. This handler will be registered at all sources providing this event type and having this source type. If only a handler ID is provided, a new handler will be created as plugin to this event manager.
      Adding as well as creating will be skipped, if a handler of the designated ID is already registered for the event type and source type. In this case the existing handler may change its position in the list (if the position differs from the handler’s current position). Additionally, the existing handler will be returned instead of the designated or the newly created one.
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The event type for which to add an event handler.
      sourceType - The source type for which to add an event handler.
      handlerID - The ID of the handler. This refers to the corresponding plugin ID. If this is null, a valid handler needs to be provided as current.
      current - The handler to add to the designated event type and source type. If this is null, a valid handler ID (the instance name of the corresponding plugin) needs to be provided.
      index - The position where to add the designated handler in the handler list of the designated event type and source type. If the handler is already part of the list, it will be moved in case the new position differs from its current position.
      Returns:
      The newly created handler or the handler object that has already been registered for the designated event type and source type (and having the same handler ID).
      Throws:
      ServiceNotKnownException - If a handler ID is provided and this does not refer to a valid plugin instance for an activity event handler, a ServiceNotKnownException will be thrown.
    • removeEventHandler

      public EventHandler removeEventHandler(SessionToken session, String eventType, String sourceType, String handlerID)
      Description copied from interface: EventManager
      Removes the event handler having the designated ID and being registered for the designated event type and event source. The removed event handler will be returned. If no event handler is found, null will be returned. The handler will be removed from the corresponding event sources.
      Specified by:
      removeEventHandler in interface EventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      eventType - The event type of which to remove an event handler.
      sourceType - The source type of which to remove an event handler.
      handlerID - The ID of the handler to remove.
      Returns:
      The removed event source or null in case there is already an event source of the designated source ID.
    • getPlugin

      public <P> P getPlugin(String pluginTypeName, Class<P> pluginType, String instanceName) throws ServiceNotKnownException
      Gets the plugin instance configured for the designated plugin type and name.
      Type Parameters:
      P - The plugin type.
      Parameters:
      pluginTypeName - The name of the plugin type.
      pluginType - The plugin type.
      instanceName - The (simple) instance name of the desired plugin; use null for the default instance.
      Returns:
      The requested plugin.
      Throws:
      ServiceNotKnownException - If the requested plugin could not be found or created, a ServiceNotNKnowException will be thrown.
    • getService

      public <S extends ADEPT2Service> S getService(String serviceTypeName, String simpleServName, Class<S> serviceType) throws ServiceNotKnownException
      Gets the service of the designated type and name (or the corresponding service configured for this event manager).
      When using this method make sure to add the designated service type to the startup or runtime required services in constructor!
      Type Parameters:
      S - The type of the requested service. This is a subtype of ADEPT2Service and either interface configured for the service type or a super type hereof.
      Parameters:
      serviceTypeName - The type of the service which to retrieve.
      simpleServName - The simple name of the service which to retrieve or null to retrieve the default service configured for usage by this event manager.
      serviceType - The type of the requested service. This is a subtype of ADEPT2Service and the interface configured for the service type or a super type hereof.
      Returns:
      The requested service (or a service stub). The object is never null.
      Throws:
      ServiceNotKnownException - If
      • the service is not configured properly,
      • the service cannot be created or started,
      • a required service is not configured properly or cannot be started,
      • the creation of a required service object fails,
      • the service does not fulfill the ADEPT2Service -interface appropriately,
      • an exception is thrown while creating or starting a required service,
      a ServiceNotKnownException will be thrown. This may encapsulate a ConfigurationException or an AbortServiceException.
      InvalidServiceStateException - If this registry failed to start or is shut down, an InvalidServiceStateException will be thrown.
      IllegalArgumentException - If the designated service type interface does not conform to the interface configured for the service type, an IllegalArgumentException will be thrown.
    • selectActivity

      Description copied from interface: ActivityEventManager
      Selects the designated activity and thus assigns it to this event manager. This prevents other users from starting the activity. The simple session context of the activity will be returned which is similar to retrieving it without selection for ProcessConstants.ExecutionMode.PRODUCTION.
      This method is used to indicate that an event source has been created or is about to be created for the activity and is waiting for the event to occur.
      Specified by:
      selectActivity in interface ActivityEventManager
      Parameters:
      activity - The activity to select for which an event source exists or is about to be created.
      Returns:
      The session context of the activity providing more information on the activity waiting for an event.
      Throws:
      InvalidActivityStateException - If the activity (process step) is not activated, an InvalidActivityStateException will be raised.
      InvalidInstanceStateException - If the instance is not running but stopped, aborted, finished or changed, an InvalidInstanceStateException will be thrown.
      WrongAgentException - If the activity can be started or selected but not by the event manager agent a WrongAgentException will be thrown.
      See Also:
    • deselectActivity

      Description copied from interface: ActivityEventManager
      Deselects the designated activity and thus makes it available for reassigning. This allows other users to start the activity. This method indicates that no event source is waiting for the event of the activity any more.
      Specified by:
      deselectActivity in interface ActivityEventManager
      Parameters:
      activity - The activity to deselect.
      Throws:
      InvalidActivityStateException - If the activity (process step) is not selected by the designated user, an InvalidActivityStateException will be raised.
      InvalidInstanceStateException - If the instance is not running but stopped, aborted, finished or changed, an InvalidInstanceStateException will be thrown.
      WrongAgentException - If the calling agent is not the same agent who selected the activity.
      See Also:
    • getSimpleSessionContext

      Description copied from interface: ActivityEventManager
      Gets an incomplete simple session context for the designated activity. This just returns the simple session context without any state changes of the activity. This method can only be called for activities that the event manager may also start or resume, for instance by having called ActivityEventManager.selectActivity(EBPInstanceReference).

      The SimpleSessionContext.getSessionID() of the returned context will be null and the flag SimpleSessionContext.isResumed() will be unset since they cannot be determined.

      Specified by:
      getSimpleSessionContext in interface ActivityEventManager
      Parameters:
      activity - The activity for which to retrieve the simple session context.
      executionMode - The execution mode which to apply, which may have consequences on the configuration.
      Returns:
      The simple session context for the designated activity as far as its attributes can be determined. This is only returned if the activity is assigned (selected, running or suspended) to this event manager.
      Throws:
      InvalidActivityStateException - If the activity (process step) is not selected, running or suspended this event manager, an InvalidActivityStateException will be raised.
      InvalidInstanceStateException - If the instance is not running but stopped, aborted, finished or changed, an InvalidInstanceStateException is thrown.
      WrongAgentException - If the activity can be started or resumed but not by the event manager agent a WrongAgentException will be thrown.
      See Also:
    • startActivity

      Description copied from interface: ActivityEventManager
      Starts the designated activity if it is appropriate for a RuntimeService and provides its process context. This activity event manager registers as ExecutionMessageListener and forwards the messages to the appropriate event handler. Since starting the activity is internally asynchronous, a timeout is required. If this timeout elapses the start will be aborted and null will be returned.
      Specified by:
      startActivity in interface ActivityEventManager
      Parameters:
      activity - The unique ID of the activity to start.
      executionMode - The execution mode in which to start the activity, for instance, a test mode.
      Returns:
      The session token which with the activity is started and the SimpleSessionContext providing the process context (e.g. the input parameter values) of the started activity.
      Throws:
      InvalidActivityStateException - If the activity (process step) is not activated or selected by the designated user, an InvalidActivityStateException will be raised.
      InvalidInstanceStateException - If the instance is not running but stopped, aborted, finished or changed, an InvalidInstanceStateException is thrown.
      WrongAgentException - If the calling agent is not the same agent who selected the activity.
      See Also:
    • getRuntimeEnvironment

      public RemoteRuntimeEnvironment getRuntimeEnvironment()
      Description copied from interface: ActivityEventManager
      Gets the interface for remotely using RuntimeEnvironment. Since we do not have an ExecutableComponent, the interaction with the RuntimeEnvironment needs to be done via a service.
      Specified by:
      getRuntimeEnvironment in interface ActivityEventManager
      Returns:
      The interface for remotely using RuntimeEnvironment clients executing activities proprietarily not using ExecutableComponent.
      See Also:
    • getProgressMonitor

      public RemoteProgressMonitor getProgressMonitor()
      Description copied from interface: ActivityEventManager
      Gets the interface for remotely using ProgressMonitor. Since we do not have an ExecutableComponent, the interaction with the ProgressMonitor needs to be done via a service.
      Specified by:
      getProgressMonitor in interface ActivityEventManager
      Returns:
      The interface for remotely using ProgressMonitor clients executing activities proprietarily not using ExecutableComponent.
      See Also:
    • getInstanceControl

      public InstanceControl getInstanceControl()
      Gets the instance control of the execution manager of this event manager for starting a new instance based on an occurred database event.
      Returns:
      The instance control of the execution manager of this event manager for starting a new instance based on an occurred database event.
    • getTemplateReference

      public TemplateReference getTemplateReference(SessionToken session, UUID templateID)
      Description copied from interface: InstanceStartEventManager
      Gets the lightweight representation of the designated process template.
      Specified by:
      getTemplateReference in interface InstanceStartEventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      templateID - The ID of the process template to retrieve the lightweight representation of.
      Returns:
      The lightweight representation of the designated process template.
      See Also:
    • getLatestTemplateReference

      public TemplateReference getLatestTemplateReference(SessionToken session, String processType, boolean checkStarterRule)
      Description copied from interface: InstanceStartEventManager
      Gets the lightweight representation of the "latest" process template of the designated process type. Note that the "latest" template need not really be the latest template of the designated process type and dynamic retrieval may cause some trouble in case the template input or output parameter have changed.
      Specified by:
      getLatestTemplateReference in interface InstanceStartEventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      processType - The name of the process type of which to get the "latest" template.
      checkStarterRule - Whether the starter rule should be checked. If true, the starter rule of the template will be resolved and it will be checked, whether the EventManager is allowed to start the process from one of its InstanceStartEventHandlers.
      Returns:
      The "latest" template of the designated process type from the designated template manager. This is the instantiable top-level template having the highest version number. If no template is found for the designated process type, null will be returned.
      See Also:
    • createInstanceDataContainer

      public InstanceDataContainer createInstanceDataContainer(SessionToken session, UUID templateID)
      Description copied from interface: InstanceStartEventManager
      Creates an instance data container for the input (and output) parameters of the designated template. The values of the input parameters can be set and provided to the start of an instance based on the designated template.
      Specified by:
      createInstanceDataContainer in interface InstanceStartEventManager
      Parameters:
      session - The session which is used to check for access rights on this method.
      templateID - The template for which to create a data container having the corresponding input and output parameters.
      Returns:
      An InstanceDataContainer having all input and output parameters of the designated template which allows to set input parameters and retrieve the values of the output parameters. The caller is responsible for closing.
      See Also:
    • startInstance

      Description copied from interface: InstanceStartEventManager
      Creates a new instance of the designated process template, starts the instance and logs the designated user as initiator of the process instance. The start node of the created instance is executed immediately internally and the values of the input parameter provided by the (appropriate) data container are set in the created instance.
      Specified by:
      startInstance in interface InstanceStartEventManager
      Parameters:
      session - The session which is used to check for access rights on this method. The starting agent and the corresponding organisational position is retrieved from the execution context!
      templId - The template which is to be instantiated. The template has to be in state INSTANTIABLE for top-level usage.
      dataContainer - The data container providing the input data and output data of the instance. This can be null in case the process does not have mandatory input parameters.
      Returns:
      The ID and the log ID of the created process instance which are both unique with respect to the process management system and the server respectively.
      Throws:
      InvalidTemplateStateException - If the process template is not instantiable for top-level usage, an InvalidTemplateStateException will be raised.
      InvalidDataContainerException - If the designated process has mandatory input or output parameters that are not incorporated in the designated data container, an InvalidDataContainerException will be raised.
      See Also:
    • stopAndAbortInstance

      public void stopAndAbortInstance(SessionToken session, UUID instanceId, String errorMessage, String errorState, long errorCode) throws InvalidInstanceStateException
      Description copied from interface: InstanceStartEventManager
      Stops the designated instance and also the running activities. In case of a subprocess instance, the super-activity fails. The instance has to be in state IE_RUNNING, IE_SUSPENDED, IE_SOFTLY_SUSPENDED, IE_SOFTLY_ABORTED or IE_ABORTED. Afterwards the instance is in state IE_ABORTED.
      Specified by:
      stopAndAbortInstance in interface InstanceStartEventManager
      Parameters:
      session - The session which is used to check for access rights on this method and to retrieve the stopping agent and the corresponding organisational position.
      instanceId - The ID of the instance to be stopped.
      errorMessage - A human readable description of the reason for the abortion.
      errorState - The state of the caller in which the error occurred that led to the abortion.
      errorCode - A code that identifies the reason why the instance should be aborted.
      Throws:
      InvalidInstanceStateException - If the process instance is not running, suspended or aborted, an InvalidInstanceStateException will be raised. This will also apply if either is locked for changes.
      See Also: