Class AbstractEventManager
- java.lang.Object
-
- de.aristaflow.adept2.base.service.AbstractADEPT2Service
-
- de.aristaflow.adept2.base.service.AbstractNonPrivilegedService
-
- de.aristaflow.adept2.core.eventmanager.common.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions
-
-
Field Summary
Fields Modifier and Type Field Description protected ActivityStarting
activitySelecting
The interface for selecting an activity.protected int
addEventSourceRetryCount
The number of retries for adding an event source.protected long
addEventSourceRetryDelay
The time in milliseconds to wait before retrying to add an event source.protected ScheduledObjectOneWorkExecutor<WorklistItem>
addService
The executor that adds event sources.static String
CONF_ADD_EVENT_SOURCE_RETRY_COUNT
Configuration key: The number of retries for adding an event source.static String
CONF_ADD_EVENT_SOURCE_RETRY_DELAY
Configuration key: The time in milliseconds to wait before retrying to add an event source.static String
CONF_CREATE_WORKLIST_RETRY_DELAY
Configuration key: The time in milliseconds to wait before retrying to create (retrieve) a client worklist.static String
CONF_CREATE_WORKLIST_SILENT_COUNT
Configuration key: The number of retries for creating (retrieving) a client worklist before logging the exception as critical.static String
CONF_HANDLER_MIN_POOL_SIZE
Configuration key: The minimal number of executor threads for handling events by various sources.static String
CONF_HANDLER_PRIORITY
Configuration key: The priority of the event handling threads used by various sources.static String
CONF_HANDLER_QUEUE_LIMIT
Configuration key: The number of tasks in the executor queue that are allowed before warnings will be logged.static 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).static String
CONF_MIN_LOG_LEVEL_POOL_STATISTICS
Configuration key: The log level which need to be reached for logging pool statistics.static String
CONF_MIN_POOL_SIZE
Configuration key: The minimal number of executor threads for polling events.static String
CONF_POLLER_PRIORITY
Configuration key: The priority of the polling threads.protected static String
CONF_QUEUE_LIMIT_POOL_STATISTICS
Configuration key: The total amount of tasks being the threshold for logging pool statistics.static String
CONF_SERVICE_TYPES_FOR_EVENTS
Configuration key for the names of service types that are required for event sources and/or event handlers.static String
CONF_USE_ONE_WORK_EXECUTOR
Configuration key: Whether to use the one-work executor which prevents duplicate worklist item handling.protected long
createWorklistRetryDelay
The time in milliseconds to wait before retrying to create (retrieve) a client worklist.protected int
createWorklistSilentCount
The number of retries for creating (retrieving) a client worklist before logging the exception as critical.protected ReadWriteLock
dataLock
The lock protecting the data structures containing the handler and sources.protected ExecutionFactory
exmFactory
The factory for creating the execution context for starting instances.protected FilterFactory
filterFactory
The filter factory required for retrieving the "latest" template of a specific process type.protected Map<PollingSource<?>,ScheduledFuture<?>>
futures
/** All the event sources mapped to the corresponding futures from the poll service.protected Map<Pair<String,String>,List<EventHandler>>
handler
All known event handler indexed by the event and source type they are registered for.protected int
handlerMinPoolSize
Minimal number of executor threads for handling events.protected int
handlerPriority
The priority of the event handling threads used by various sources.protected int
handlerQueueLimit
The number of tasks in the executor queue that are allowed before executor warnings will be logged.protected ExecutorService
handlerService
The service that is shared among sources for asynchronous event handling.protected Map<EventHandler,Collection<EventSource<?>>>
handlerSource
All handler and the sources they are registered for.protected InstanceControl
instanceControl
The control interface for starting instances.protected String
libDirectory
The name of the directory providing the JDBC libraries (actually one level above the directory 'jdbc4' containing the drivers).protected static long
MINIMAL_DELAY
The minimal delay for the first poll of polling sources.protected Level
minLogLevelPoolStatistics
The log level which need to be reached for logging pool statistics.protected int
minPoolSize
Minimal number of executor threads for polling events.protected OrgModelManager
omm
The org model manager for checking the starter rule.protected long
pingWLMInterval
The time interval in milliseconds which to regularly check whether the worklist manager is still available or available again.protected ProcessManager
pm
The process manager for retrieving templates to be started.protected int
pollerPriority
The priority of the polling threads.protected LoggingScheduledThreadPoolExecutor
pollService
The service that executes the pollers that cause the events.static String
PREREGISTERED_EVENT_HANDLER
The configuration key for the pre-registered event handler per source.protected int
queueLimitPoolStatistics
The total amount of tasks being the threshold for logging pool statistics.protected Level
reconnectLogLevel
The log level that will be used to log that no push update was received yet.protected long
reconnectWLMInterval
The time interval in milliseconds which to regularly reconnect to the worklist manager if no push update was received yet.protected boolean
resumeOnly
Flag to indicate whether to resume items and not to start new ones.protected RuntimeService
runtimeService
The runtime service for starting and terminating activities that wait for an event.protected Collection<SharedPollingSource<?>>
sharedSources
All shared polling sources.protected ObjectCounting<Triple<String,String,String>>
sourceCount
The amount of sources per source ID.protected 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.protected Map<String,Class<? extends Event>>
supportedEventTypes
All event types that are supported by this event manager.protected long
updateInterval
Interval (in ms) for pushed updates.protected boolean
useOneWorkExecutor
Whether to use the one-work executor which prevents duplicate worklist item handling.protected de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandler
worklistHandler
The 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, startupRequiredServices
-
Fields 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_HANDLER
-
Fields inherited from interface de.aristaflow.adept2.core.eventmanager.EventManager
PLUGIN_TYPE_EVENT_HANDLER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEventManager(org.apache.commons.configuration2.Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices)
Creates an event manager creating event sources and combining them with the appropriate event handlers.protected
AbstractEventManager(org.apache.commons.configuration2.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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description EventHandler
addEventHandler(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.EventHandler
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 EventHandler
addEventHandler(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, org.apache.commons.configuration2.Configuration conf)
Adds an event source having the designated ID to the designated event type and event source.protected void
addPreregistered(org.apache.commons.configuration2.Configuration conf)
Reads the event handler and sources from the configuration based on the supported event types, registers and starts them initially and adds them afterwards.protected void
addPreregistered(org.apache.commons.configuration2.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.InstanceDataContainer
createInstanceDataContainer(SessionToken session, UUID templateID)
Creates an instance data container for the input (and output) parameters of the designated template.SessionToken
createSession()
Creates a new session token using the client session factory assigned to this service.void
deselectActivity(EBPInstanceReference activity)
Deselects the designated activity and thus makes it available for reassigning.List<String>
getEventHandler(SessionToken session, String eventType, String sourceType)
Gets the event handler that are registered for the designated event type and source type.Collection<String>
getEventSources(SessionToken session, String eventType, String sourceType)
Gets the event sources that exist for the designated event type and source type.ExecutorService
getHandlerExecutorService()
Gets an executor service for event handling by arbitrary event sources.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.TemplateReference
getLatestTemplateReference(SessionToken session, String processType, boolean checkStarterRule)
Gets the lightweight representation of the "latest" process template of the designated process type.<P> P
getPlugin(String pluginTypeName, Class<P> pluginType, String instanceName)
Gets the plugin instance configured for the designated plugin type and name.RemoteProgressMonitor
getProgressMonitor()
Gets the interface for remotely usingProgressMonitor
.RemoteRuntimeEnvironment
getRuntimeEnvironment()
Gets the interface for remotely usingRuntimeEnvironment
.protected LoggingScheduledThreadPoolExecutor
getScheduledExecutorService()
Deprecated.UseOneWorkWorklistHandler
which does not require this method.<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).SimpleSessionContext
getSimpleSessionContext(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode)
Gets an incomplete simple session context for the designated activity.Map<String,Class<? extends Event>>
getSupportedEventTypes(SessionToken session)
Gets all the event types this event manager supports, that is, it can create event sources for these event types.protected Map<String,Class<? extends Event>>
getSupportedEventTypes(SessionToken session, ServiceAccess sa)
Gets all event types declared via plugin types for this event manager.TemplateReference
getTemplateReference(SessionToken session, UUID templateID)
Gets the lightweight representation of the designated process template.void
init(URI[] localExportedUris, URI[] globalExportedUris)
Copies the designated URI array and stores it internally and authenticates to the system and sets the session factory.protected static String[]
mergeEventRequiredServices(org.apache.commons.configuration2.Configuration conf, String[] startupRequiredServices)
protected void
removeAllSources()
Removes all currently active data sources and stops their polling.EventHandler
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.SimpleSessionContext
selectActivity(EBPInstanceReference activity)
Selects the designated activity and thus assigns it to this event manager.void
shutdown(boolean emergency)
Awaits the termination of the active sessions and nulls the session factory.void
start()
Method setting the status to the current time.Pair<SessionToken,SimpleSessionContext>
startActivity(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode)
Starts the designated activity if it is appropriate for aRuntimeService
and provides its process context.SerialisablePair<UUID,UUID>
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.-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractNonPrivilegedService
authenticateService, awaitActiveSessions, getSecurityManager, getSessionFactory, simpleInit
-
Methods 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, unprivilegeThread
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, ping, preShutdown
-
Methods inherited from interface de.aristaflow.adept2.core.eventmanager.InstanceStartEventManager
createAndStartInstance
-
-
-
-
Field Detail
-
PREREGISTERED_EVENT_HANDLER
public static final String PREREGISTERED_EVENT_HANDLER
The configuration key for the pre-registered event handler per source.- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
minPoolSize
protected final int minPoolSize
Minimal number of executor threads for polling events. These are at least 2.
-
CONF_USE_ONE_WORK_EXECUTOR
public static final String CONF_USE_ONE_WORK_EXECUTOR
Configuration key: Whether to use the one-work executor which prevents duplicate worklist item handling.- See Also:
- Constant Field Values
-
useOneWorkExecutor
protected final boolean useOneWorkExecutor
Whether to use the one-work executor which prevents duplicate worklist item handling.
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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
protected ScheduledObjectOneWorkExecutor<WorklistItem> 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.
-
-
Constructor Detail
-
AbstractEventManager
protected AbstractEventManager(org.apache.commons.configuration2.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 benull
nor containnull
values.runtimeRequiredServices
- The services required at runtime of the event manager. This must neither benull
nor containnull
values.- Throws:
ConfigurationException
- If the password for this authenticated service cannot be parsed from the configuration, aConfigurationException
will be thrown.
-
AbstractEventManager
@Deprecated(since="14.4.0", forRemoval=true) protected AbstractEventManager(org.apache.commons.configuration2.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 benull
nor containnull
values.runtimeRequiredServices
- The services required at runtime of the event manager. This must neither benull
nor containnull
values.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, aConfigurationException
will be thrown.
-
-
Method Detail
-
mergeEventRequiredServices
protected static String[] mergeEventRequiredServices(org.apache.commons.configuration2.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 interfaceADEPT2Service
- Overrides:
init
in 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 ornull
in case the service is not published.- Throws:
AbortServiceException
- If authenticating at the security manager fails, anAbortServiceException
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 interfaceADEPT2Service
- Overrides:
start
in classAbstractADEPT2Service
- Throws:
AbortServiceException
- If this service cannot be started due to a severe problem, anAbortServiceException
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 interfaceADEPT2Service
- Overrides:
shutdown
in 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(org.apache.commons.configuration2.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, aServiceNotKnownException
will be thrown.ConfigurationException
- If there are problems with the configuration of an event source, aConfigurationException
will be thrown.
-
addPreregistered
protected void addPreregistered(org.apache.commons.configuration2.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, aServiceNotKnownException
will be thrown.ConfigurationException
- If there are problems with the configuration of an event source, aConfigurationException
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 classAbstractNonPrivilegedService
- Returns:
- A new session token using the client session factory assigned to this service.
-
getScheduledExecutorService
@Deprecated protected LoggingScheduledThreadPoolExecutor getScheduledExecutorService()
Deprecated.UseOneWorkWorklistHandler
which does not require this method.Gets the scheduled executor service for usage by worklist handler and event source management. Use this for polling at determined times.- Returns:
- The scheduled executor service for usage by worklist handler and event source management.
-
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 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:EventManager
Gets the event sources that exist for the designated event type and source type.- Specified by:
getEventSources
in 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, org.apache.commons.configuration2.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 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, aConfigurationException
will be thrown.ServiceNotKnownException
- If there are problems with the plugin configuration or no plugin configured at all for the designated source aServiceNotKnownException
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 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
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 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: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 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 aServiceNotKnownException
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 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, aServiceNotKnownException
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 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
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; usenull
for the default instance.- Returns:
- The requested plugin.
- Throws:
ServiceNotKnownException
- If the requested plugin could not be found or created, aServiceNotNKnowException
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 ofADEPT2Service
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 ornull
to retrieve the default service configured for usage by this event manager.serviceType
- The type of the requested service. This is a subtype ofADEPT2Service
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,
ServiceNotKnownException
will be thrown. This may encapsulate aConfigurationException
or anAbortServiceException
.InvalidServiceStateException
- If this registry failed to start or is shut down, anInvalidServiceStateException
will be thrown.IllegalArgumentException
- If the designated service type interface does not conform to the interface configured for the service type, anIllegalArgumentException
will be thrown.
-
selectActivity
public SimpleSessionContext selectActivity(EBPInstanceReference activity) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException
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 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:
selectActivity
in 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, anInvalidActivityStateException
will be raised.InvalidInstanceStateException
- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateException
will be thrown.WrongAgentException
- If the activity can be started or selected but not by the event manager agent aWrongAgentException
will be thrown.- See Also:
ActivityStarting.selectActivity(SessionToken, EBPInstanceReference)
-
deselectActivity
public void deselectActivity(EBPInstanceReference activity) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException
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 interfaceActivityEventManager
- Parameters:
activity
- The activity to deselect.- Throws:
InvalidActivityStateException
- If the activity (process step) is not selected by the designated user, anInvalidActivityStateException
will be raised.InvalidInstanceStateException
- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateException
will be thrown.WrongAgentException
- If the calling agent is not the same agent who selected the activity.- See Also:
ActivityStarting.deselectActivity(SessionToken, EBPInstanceReference)
-
getSimpleSessionContext
public SimpleSessionContext getSimpleSessionContext(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException
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 calledActivityEventManager.selectActivity(EBPInstanceReference)
.The
SimpleSessionContext.getSessionID()
of the returned context will benull
and the flagSimpleSessionContext.isResumed()
will be unset since they cannot be determined.- Specified by:
getSimpleSessionContext
in 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, anInvalidActivityStateException
will be raised.InvalidInstanceStateException
- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateException
is thrown.WrongAgentException
- If the activity can be started or resumed but not by the event manager agent aWrongAgentException
will be thrown.- See Also:
ActivityStarting.getExecutionContext(SessionToken, EBPInstanceReference)
-
startActivity
public Pair<SessionToken,SimpleSessionContext> startActivity(EBPInstanceReference activity, ProcessConstants.ExecutionMode executionMode) throws InvalidActivityStateException, InvalidInstanceStateException, WrongAgentException
Description copied from interface:ActivityEventManager
Starts the designated activity if it is appropriate for aRuntimeService
and provides its process context. This activity event manager registers asExecutionMessageListener
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 andnull
will be returned.- Specified by:
startActivity
in 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
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, anInvalidActivityStateException
will be raised.InvalidInstanceStateException
- If the instance is not running but stopped, aborted, finished or changed, anInvalidInstanceStateException
is thrown.WrongAgentException
- If the calling agent is not the same agent who selected the activity.- See Also:
RemoteActivityStarting.startActivity(SessionToken, EBPInstanceReference, ExecutionMode, java.net.URI[])
-
getRuntimeEnvironment
public RemoteRuntimeEnvironment getRuntimeEnvironment()
Description copied from interface:ActivityEventManager
Gets the interface for remotely usingRuntimeEnvironment
. Since we do not have anExecutableComponent
, the interaction with theRuntimeEnvironment
needs to be done via a service.- Specified by:
getRuntimeEnvironment
in interfaceActivityEventManager
- Returns:
- The interface for remotely using
RuntimeEnvironment
clients executing activities proprietarily not usingExecutableComponent
. - See Also:
RuntimeService.getRuntimeEnvironment()
-
getProgressMonitor
public RemoteProgressMonitor getProgressMonitor()
Description copied from interface:ActivityEventManager
Gets the interface for remotely usingProgressMonitor
. Since we do not have anExecutableComponent
, the interaction with theProgressMonitor
needs to be done via a service.- Specified by:
getProgressMonitor
in interfaceActivityEventManager
- Returns:
- The interface for remotely using
ProgressMonitor
clients executing activities proprietarily not usingExecutableComponent
. - See Also:
RuntimeService.getProgressMonitor()
-
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 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:
TemplateManager.getTemplateReference(SessionToken, UUID)
-
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 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 theEventManager
is allowed to start the process from one of itsInstanceStartEventHandler
s.- 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:
ProcessManagerTools.getLatestTemplateVersion(SessionToken, String, de.aristaflow.adept2.core.processmanager.TemplateManager, de.aristaflow.adept2.model.filter.FilterFactory)
-
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 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
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:
InstanceControl.createInstanceDataContainer(SessionToken, UUID)
-
startInstance
public SerialisablePair<UUID,UUID> startInstance(SessionToken session, UUID templId, InstanceDataContainer dataContainer) throws InvalidTemplateStateException, InvalidDataContainerException
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 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 stateINSTANTIABLE
for top-level usage.dataContainer
- The data container providing the input data and output data of the instance. This can benull
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, anInvalidTemplateStateException
will be raised.InvalidDataContainerException
- If the designated process has mandatory input or output parameters that are not incorporated in the designated data container, anInvalidDataContainerException
will be raised.- See Also:
InstanceControl.startInstance(SessionToken, UUID, de.aristaflow.adept2.model.execution.ExecutionContext, java.net.URI[], java.net.URI[])
-
-