Class AbstractEventManager
- All Implemented Interfaces:
ADEPT2Service,LogService,ServiceThreadHandling,ActivityEventManager,EventManager,InstanceStartEventManager
- Direct Known Subclasses:
DefaultEventManager
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ActivityStartingThe interface for selecting an activity.protected final intThe number of retries for adding an event source.protected final longThe time in milliseconds to wait before retrying to add an event source.protected ScheduledObjectOneWorkExecutor<WorklistItem>The executor that adds event sources.static final StringConfiguration key: The number of retries for adding an event source.static final StringConfiguration key: The time in milliseconds to wait before retrying to add an event source.static final StringConfiguration key: The time in milliseconds to wait before retrying to create (retrieve) a client worklist.static final StringConfiguration key: The number of retries for creating (retrieving) a client worklist before logging the exception as critical.static final StringConfiguration key: The minimal number of executor threads for handling events by various sources.static final StringConfiguration key: The priority of the event handling threads used by various sources.static final StringConfiguration key: The number of tasks in the executor queue that are allowed before warnings will be logged.static final StringConfiguration key for the name of the directory providing the JDBC libraries (actually one level above the directory 'jdbc4' containing the drivers).static final StringConfiguration key: The log level which need to be reached for logging pool statistics.static final StringConfiguration key: The minimal number of executor threads for polling events.static final StringConfiguration key: The priority of the polling threads.protected static final StringConfiguration key: The total amount of tasks being the threshold for logging pool statistics.static final StringConfiguration key for the names of service types that are required for event sources and/or event handlers.protected final longThe time in milliseconds to wait before retrying to create (retrieve) a client worklist.protected final intThe number of retries for creating (retrieving) a client worklist before logging the exception as critical.protected final ReadWriteLockThe lock protecting the data structures containing the handler and sources.protected ExecutionFactoryThe factory for creating the execution context for starting instances.protected FilterFactoryThe filter factory required for retrieving the "latest" template of a specific process type.protected final Map<PollingSource<?>,ScheduledFuture<?>> /** All the event sources mapped to the corresponding futures from the poll service.All known event handler indexed by the event and source type they are registered for.protected final intMinimal number of executor threads for handling events.protected final intThe priority of the event handling threads used by various sources.protected final intThe number of tasks in the executor queue that are allowed before executor warnings will be logged.protected ExecutorServiceThe service that is shared among sources for asynchronous event handling.protected final Map<EventHandler,Collection<EventSource<?>>> All handler and the sources they are registered for.protected InstanceControlThe control interface for starting instances.protected final StringThe name of the directory providing the JDBC libraries (actually one level above the directory 'jdbc4' containing the drivers).protected static final longThe minimal delay for the first poll of polling sources.protected final LevelThe log level which need to be reached for logging pool statistics.protected final intMinimal number of executor threads for polling events.protected OrgModelManagerThe org model manager for checking the starter rule.protected final longThe time interval in milliseconds which to regularly check whether the worklist manager is still available or available again.protected ProcessManagerThe process manager for retrieving templates to be started.protected final intThe priority of the polling threads.protected LoggingScheduledThreadPoolExecutorThe service that executes the pollers that cause the events.static final StringThe configuration key for the pre-registered event handler per source.protected final intThe total amount of tasks being the threshold for logging pool statistics.protected final LevelThe log level that will be used to log that no push update was received yet.protected final longThe time interval in milliseconds which to regularly reconnect to the worklist manager if no push update was received yet.protected final booleanFlag to indicate whether to resume items and not to start new ones.protected RuntimeServiceThe runtime service for starting and terminating activities that wait for an event.protected final Collection<SharedPollingSource<?>>All shared polling sources.protected final ObjectCounting<Triple<String,String, String>> The amount of sources per source ID.All existing event sources indexed by event type and source type mapped to source ID and source.All event types that are supported by this event manager.protected final longInterval (in ms) for pushed updates.protected de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandlerThe worklist handler creating event sources depending on the contents of the worklist.Fields inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServicesFields inherited from interface de.aristaflow.adept2.core.eventmanager.ActivityEventManager
ACT_CONF_EVENT_TYPE, ACT_CONF_RETRY_COUNT, ACT_CONF_RETRY_DELAY, ACT_CONF_SOURCE_ID, ACT_CONF_SOURCE_TYPE, PLUGIN_TYPE_ACTIVITY_EVENT_HANDLERFields inherited from interface de.aristaflow.adept2.core.eventmanager.EventManager
PLUGIN_TYPE_EVENT_HANDLER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEventManager(Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices) Creates an event manager creating event sources and combining them with the appropriate event handlers.protectedAbstractEventManager(Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices, Map<String, Class<? extends Event>> supportedEvents) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionaddEventHandler(SessionToken session, String eventType, String sourceType, EventHandler current, int index) Adds the designated event handler to the designated event type and event source at the designated position.addEventHandler(SessionToken session, String eventType, String sourceType, String handlerID, int index) Adds an event handler having the designated ID to the designated event type and event source at the designated position.protected EventHandleraddEventHandler(SessionToken session, String eventType, String sourceType, String handlerID, EventHandler current, int index) Adds the designated event handler to the designated event type and source type.EventSource<?>addEventSource(SessionToken session, String eventType, String sourceType, String sourceID, Configuration conf) Adds an event source having the designated ID to the designated event type and event source.protected voidReads the event handler and sources from the configuration based on the supported event types, registers and starts them initially and adds them afterwards.protected voidaddPreregistered(Configuration conf, Iterator<String> sourceTypes) Reads the event handler and sources for the designated source types from the configuration, registers and starts them initially and adds them afterwards.createInstanceDataContainer(SessionToken session, UUID templateID) Creates an instance data container for the input (and output) parameters of the designated template.Creates a new session token using the client session factory assigned to this service.voiddeselectActivity(EBPInstanceReference activity) Deselects the designated activity and thus makes it available for reassigning.getEventHandler(SessionToken session, String eventType, String sourceType) Gets the event handler that are registered for the designated event type and source type.getEventSources(SessionToken session, String eventType, String sourceType) Gets the event sources that exist for the designated event type and source type.Gets an executor service for event handling by arbitrary event sources.Gets the instance control of the execution manager of this event manager for starting a new instance based on an occurred database event.getLatestTemplateReference(SessionToken session, String processType, boolean checkStarterRule) Gets the lightweight representation of the "latest" process template of the designated process type.<P> PGets the plugin instance configured for the designated plugin type and name.Gets the interface for remotely usingProgressMonitor.Gets the interface for remotely usingRuntimeEnvironment.<S extends ADEPT2Service>
SgetService(String serviceTypeName, String simpleServName, Class<S> serviceType) Gets the service of the designated type and name (or the corresponding service configured for this event manager).getSimpleSessionContext(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode) Gets an incomplete simple session context for the designated activity.getSupportedEventTypes(SessionToken session) Gets all the event types this event manager supports, that is, it can create event sources for these event types.getSupportedEventTypes(SessionToken session, ServiceAccess sa) Gets all event types declared via plugin types for this event manager.getTemplateReference(SessionToken session, UUID templateID) Gets the lightweight representation of the designated process template.voidCopies the designated URI array and stores it internally and authenticates to the system and sets the session factory.protected static String[]mergeEventRequiredServices(Configuration conf, String[] startupRequiredServices) protected voidRemoves all currently active data sources and stops their polling.removeEventHandler(SessionToken session, String eventType, String sourceType, String handlerID) Removes the event handler having the designated ID and being registered for the designated event type and event source.EventSource<?>removeEventSource(SessionToken session, String eventType, String sourceType, String sourceID) Removes the event source having the designated event type, event source and ID.selectActivity(EBPInstanceReference activity) Selects the designated activity and thus assigns it to this event manager.voidshutdown(boolean emergency) Awaits the termination of the active sessions and nulls the session factory.voidstart()Method setting the status to the current time.startActivity(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode) Starts the designated activity if it is appropriate for aRuntimeServiceand provides its process context.startInstance(SessionToken session, UUID templId, InstanceDataContainer dataContainer) Creates a new instance of the designated process template, starts the instance and logs the designated user as initiator of the process instance.voidstopAndAbortInstance(SessionToken session, UUID instanceId, String errorMessage, String errorState, long errorCode) Stops the designated instance and also the running activities.Methods inherited from class de.aristaflow.adept2.base.service.AbstractNonPrivilegedService
authenticateService, awaitActiveSessions, getSecurityManager, getSessionFactory, simpleInitMethods inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
_sessionActive, _sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, getUserCredentials, isActive, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, signalShutdown, signalStart, unprivilegeThreadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, ping, preShutdownMethods inherited from interface de.aristaflow.adept2.core.eventmanager.InstanceStartEventManager
createAndStartInstance
-
Field Details
-
PREREGISTERED_EVENT_HANDLER
The configuration key for the pre-registered event handler per source.- See Also:
-
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
The name of the directory providing the JDBC libraries (actually one level above the directory 'jdbc4' containing the drivers). -
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
Configuration key: The number of retries for adding an event source.- See Also:
-
addEventSourceRetryCount
protected final int addEventSourceRetryCountThe number of retries for adding an event source. -
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 addEventSourceRetryDelayThe time in milliseconds to wait before retrying to add an event source. -
CONF_MIN_POOL_SIZE
Configuration key: The minimal number of executor threads for polling events.- See Also:
-
minPoolSize
protected final int minPoolSizeMinimal number of executor threads for polling events. These are at least 2. -
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 queueLimitPoolStatisticsThe total amount of tasks being the threshold for logging pool statistics. -
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
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 pingWLMIntervalThe time interval in milliseconds which to regularly check whether the worklist manager is still available or available again. -
reconnectWLMInterval
protected final long reconnectWLMIntervalThe time interval in milliseconds which to regularly reconnect to the worklist manager if no push update was received yet. -
reconnectLogLevel
The log level that will be used to log that no push update was received yet. -
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 createWorklistSilentCountThe number of retries for creating (retrieving) a client worklist before logging the exception as critical. -
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 createWorklistRetryDelayThe time in milliseconds to wait before retrying to create (retrieve) a client worklist. -
CONF_POLLER_PRIORITY
Configuration key: The priority of the polling threads.- See Also:
-
pollerPriority
protected final int pollerPriorityThe priority of the polling threads. -
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 handlerMinPoolSizeMinimal number of executor threads for handling events. -
CONF_HANDLER_PRIORITY
Configuration key: The priority of the event handling threads used by various sources.- See Also:
-
handlerPriority
protected final int handlerPriorityThe priority of the event handling threads used by various sources. -
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 handlerQueueLimitThe number of tasks in the executor queue that are allowed before executor warnings will be logged. -
resumeOnly
protected final boolean resumeOnlyFlag to indicate whether to resume items and not to start new ones. -
updateInterval
protected final long updateIntervalInterval (in ms) for pushed updates. -
MINIMAL_DELAY
protected static final long MINIMAL_DELAYThe 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
The factory for creating the execution context for starting instances. -
filterFactory
The filter factory required for retrieving the "latest" template of a specific process type. -
runtimeService
The runtime service for starting and terminating activities that wait for an event. -
pm
The process manager for retrieving templates to be started. -
instanceControl
The control interface for starting instances. -
activitySelecting
The interface for selecting an activity. -
omm
The org model manager for checking the starter rule. -
pollService
The service that executes the pollers that cause the events. -
addService
The executor that adds event sources. -
handlerService
The service that is shared among sources for asynchronous event handling. -
worklistHandler
protected de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandler worklistHandlerThe worklist handler creating event sources depending on the contents of the worklist. -
dataLock
The lock protecting the data structures containing the handler and sources. -
sources
All existing event sources indexed by event type and source type mapped to source ID and source. -
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
/** All the event sources mapped to the corresponding futures from the poll service. This allows to terminate an event source. -
handler
All known event handler indexed by the event and source type they are registered for. -
handlerSource
All handler and the sources they are registered for. -
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 benullnor containnullvalues.runtimeRequiredServices- The services required at runtime of the event manager. This must neither benullnor containnullvalues.- Throws:
ConfigurationException- If the password for this authenticated service cannot be parsed from the configuration, aConfigurationExceptionwill 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 ConfigurationExceptionDeprecated, 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 benullnor containnullvalues.runtimeRequiredServices- The services required at runtime of the event manager. This must neither benullnor containnullvalues.supportedEvents- The events supported by subclasses. This may benull. 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, aConfigurationExceptionwill be thrown.
-
-
Method Details
-
mergeEventRequiredServices
protected static String[] mergeEventRequiredServices(Configuration conf, String[] startupRequiredServices) -
init
Description copied from class:AbstractNonPrivilegedServiceCopies 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:
initin interfaceADEPT2Service- Overrides:
initin classAbstractNonPrivilegedService- 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 ornullin case the service is not published.- Throws:
AbortServiceException- If authenticating at the security manager fails, anAbortServiceExceptionwill be thrown.
-
start
Description copied from class:AbstractADEPT2ServiceMethod setting the status to the current time. Subclasses have to call this method!- Specified by:
startin interfaceADEPT2Service- Overrides:
startin classAbstractADEPT2Service- Throws:
AbortServiceException- If this service cannot be started due to a severe problem, anAbortServiceExceptionwill 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:AbstractNonPrivilegedServiceAwaits the termination of the active sessions and nulls the session factory.- Specified by:
shutdownin interfaceADEPT2Service- Overrides:
shutdownin classAbstractNonPrivilegedService- 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, aServiceNotKnownExceptionwill be thrown.ConfigurationException- If there are problems with the configuration of an event source, aConfigurationExceptionwill 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, aServiceNotKnownExceptionwill be thrown.ConfigurationException- If there are problems with the configuration of an event source, aConfigurationExceptionwill be thrown.
-
createSession
Creates a new session token using the client session factory assigned to this service.Overridden to make it accessible within this package.
- Overrides:
createSessionin classAbstractNonPrivilegedService- Returns:
- A new session token using the client session factory assigned to this service.
-
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
Description copied from interface:EventManagerGets all the event types this event manager supports, that is, it can create event sources for these event types.- Specified by:
getSupportedEventTypesin interfaceEventManager- 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:EventManagerGets the event sources that exist for the designated event type and source type.- Specified by:
getEventSourcesin interfaceEventManager- 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:EventManagerAdds 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:
addEventSourcein interfaceEventManager- 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, aConfigurationExceptionwill be thrown.ServiceNotKnownException- If there are problems with the plugin configuration or no plugin configured at all for the designated source aServiceNotKnownExceptionwill be thrown.
-
removeEventSource
public EventSource<?> removeEventSource(SessionToken session, String eventType, String sourceType, String sourceID) Description copied from interface:EventManagerRemoves 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,nullwill be returned. All handler will be removed from the designated event source.- Specified by:
removeEventSourcein interfaceEventManager- 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
nullin case there is already an event source of the designated source ID.
-
getEventHandler
Description copied from interface:EventManagerGets the event handler that are registered for the designated event type and source type.- Specified by:
getEventHandlerin interfaceEventManager- 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:EventManagerAdds 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:
addEventHandlerin interfaceEventManager- 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 aServiceNotKnownExceptionwill be thrown.
-
addEventHandler
public EventHandler addEventHandler(SessionToken session, String eventType, String sourceType, EventHandler current, int index) Description copied from interface:EventManagerAdds 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:
addEventHandlerin interfaceEventManager- 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 isnull, a valid handler needs to be provided ascurrent.current- The handler to add to the designated event type and source type. If this isnull, 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, aServiceNotKnownExceptionwill be thrown.
-
removeEventHandler
public EventHandler removeEventHandler(SessionToken session, String eventType, String sourceType, String handlerID) Description copied from interface:EventManagerRemoves 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,nullwill be returned. The handler will be removed from the corresponding event sources.- Specified by:
removeEventHandlerin interfaceEventManager- 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
nullin 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; usenullfor the default instance.- Returns:
- The requested plugin.
- Throws:
ServiceNotKnownException- If the requested plugin could not be found or created, aServiceNotNKnowExceptionwill 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 ofADEPT2Serviceand 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 ornullto retrieve the default service configured for usage by this event manager.serviceType- The type of the requested service. This is a subtype ofADEPT2Serviceand 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,
ServiceNotKnownExceptionwill be thrown. This may encapsulate aConfigurationExceptionor anAbortServiceException.InvalidServiceStateException- If this registry failed to start or is shut down, anInvalidServiceStateExceptionwill be thrown.IllegalArgumentException- If the designated service type interface does not conform to the interface configured for the service type, anIllegalArgumentExceptionwill be thrown.
-
selectActivity
public SimpleSessionContext selectActivity(EBPInstanceReference activity) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException Description copied from interface:ActivityEventManagerSelects 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 forProcessConstants.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:
selectActivityin interfaceActivityEventManager- 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, anInvalidActivityStateExceptionwill be raised.InvalidInstanceStateException- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateExceptionwill be thrown.WrongAgentException- If the activity can be started or selected but not by the event manager agent aWrongAgentExceptionwill be thrown.- See Also:
-
deselectActivity
public void deselectActivity(EBPInstanceReference activity) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException Description copied from interface:ActivityEventManagerDeselects 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:
deselectActivityin interfaceActivityEventManager- Parameters:
activity- The activity to deselect.- Throws:
InvalidActivityStateException- If the activity (process step) is not selected by the designated user, anInvalidActivityStateExceptionwill be raised.InvalidInstanceStateException- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateExceptionwill be thrown.WrongAgentException- If the calling agent is not the same agent who selected the activity.- See Also:
-
getSimpleSessionContext
public SimpleSessionContext getSimpleSessionContext(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException Description copied from interface:ActivityEventManagerGets 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 calledActivityEventManager.selectActivity(EBPInstanceReference).The
SimpleSessionContext.getSessionID()of the returned context will benulland the flagSimpleSessionContext.isResumed()will be unset since they cannot be determined.- Specified by:
getSimpleSessionContextin interfaceActivityEventManager- 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, anInvalidActivityStateExceptionwill be raised.InvalidInstanceStateException- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateExceptionis thrown.WrongAgentException- If the activity can be started or resumed but not by the event manager agent aWrongAgentExceptionwill be thrown.- See Also:
-
startActivity
public Pair<SessionToken,SimpleSessionContext> startActivity(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException Description copied from interface:ActivityEventManagerStarts the designated activity if it is appropriate for aRuntimeServiceand provides its process context. This activity event manager registers asExecutionMessageListenerand 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 andnullwill be returned.- Specified by:
startActivityin interfaceActivityEventManager- 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
SimpleSessionContextproviding 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, anInvalidActivityStateExceptionwill be raised.InvalidInstanceStateException- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateExceptionis thrown.WrongAgentException- If the calling agent is not the same agent who selected the activity.- See Also:
-
getRuntimeEnvironment
Description copied from interface:ActivityEventManagerGets the interface for remotely usingRuntimeEnvironment. Since we do not have anExecutableComponent, the interaction with theRuntimeEnvironmentneeds to be done via a service.- Specified by:
getRuntimeEnvironmentin interfaceActivityEventManager- Returns:
- The interface for remotely using
RuntimeEnvironmentclients executing activities proprietarily not usingExecutableComponent. - See Also:
-
getProgressMonitor
Description copied from interface:ActivityEventManagerGets the interface for remotely usingProgressMonitor. Since we do not have anExecutableComponent, the interaction with theProgressMonitorneeds to be done via a service.- Specified by:
getProgressMonitorin interfaceActivityEventManager- Returns:
- The interface for remotely using
ProgressMonitorclients executing activities proprietarily not usingExecutableComponent. - See Also:
-
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
Description copied from interface:InstanceStartEventManagerGets the lightweight representation of the designated process template.- Specified by:
getTemplateReferencein interfaceInstanceStartEventManager- 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:InstanceStartEventManagerGets 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:
getLatestTemplateReferencein interfaceInstanceStartEventManager- 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 theEventManageris allowed to start the process from one of itsInstanceStartEventHandlers.- 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,
nullwill be returned. - See Also:
-
createInstanceDataContainer
Description copied from interface:InstanceStartEventManagerCreates 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:
createInstanceDataContainerin interfaceInstanceStartEventManager- 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
InstanceDataContainerhaving 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
public SerialisablePair<UUID,UUID> startInstance(SessionToken session, UUID templId, InstanceDataContainer dataContainer) throws InvalidTemplateStateException, InvalidDataContainerException Description copied from interface:InstanceStartEventManagerCreates 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:
startInstancein interfaceInstanceStartEventManager- 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 stateINSTANTIABLEfor top-level usage.dataContainer- The data container providing the input data and output data of the instance. This can benullin 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, anInvalidTemplateStateExceptionwill be raised.InvalidDataContainerException- If the designated process has mandatory input or output parameters that are not incorporated in the designated data container, anInvalidDataContainerExceptionwill be raised.- See Also:
-
stopAndAbortInstance
public void stopAndAbortInstance(SessionToken session, UUID instanceId, String errorMessage, String errorState, long errorCode) throws InvalidInstanceStateException Description copied from interface:InstanceStartEventManagerStops the designated instance and also the running activities. In case of a subprocess instance, the super-activity fails. The instance has to be in stateIE_RUNNING,IE_SUSPENDED,IE_SOFTLY_SUSPENDED,IE_SOFTLY_ABORTEDorIE_ABORTED. Afterwards the instance is in stateIE_ABORTED.- Specified by:
stopAndAbortInstancein interfaceInstanceStartEventManager- 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, anInvalidInstanceStateExceptionwill be raised. This will also apply if either is locked for changes.- See Also:
-
AbstractEventManager(Configuration, Registry, String[], String[])instead.