public interface EventManager extends ADEPT2Service
ResultSet. Therefore the corresponding handler needs to be able
to process the result set appropriately.
An event manager allows for registering arbitrary event sources and event
handler (as long as it has plugins for these). Event sources are identified
by the event type (e.g. ResultSetEvent), the source type (e.g.
DBActivityEventSource, that is an event source for database
events where the event is based on the configuration of an activity) and an
arbitrary event source ID. The latter allows for fine-grained differentiation
between event sources of the same type. For instance, an activity-based event
source can an ID that identifies the corresponding activity.
The declaration of an event source (type) as plugin is as follows: The plugin
type is the event type, the plugin instance name is the source type. The
event source ID is arbitrarily and is set by the one who adds the source to
the event manager.
An event handler is identified by the event type, the source type as well as an arbitrary ID. In the configuration, the plugin type has an arbitrary name that is usually "EventHandler" but can also be specified by the event manager implementation. The plugin instance name equals the handler ID.
Both event sources and event handler can be added and removed arbitrarily (as
long as they are known as plugin by the event manager). Adding an event
handler, registers the event handler for a specific event type and source
type together with a position an a list. This list is used by event sources
to notify event handler about an occurred event in a well-defined order. If
the event manager already has one or more event sources for the types a new
event handler is added, the handler will be registered at these sources. If
new sources are registered for the event type and source type, the handler
will be implicitly added to the source. Vice versa, removing an event source
will also remove all the registered handler from this source (but not from
the event and source type), and removing an event handler removes this
handler from the event and source type as well as all existing sources of
these types.
To summarise, event sources are registered for an event type and source, as
well as event handler. Event handler reside in a list that defines the order
they handle events of the event type and source. Each source has the
registered handler for its event type and source type. Event sources are
instantiated each time they are added. Therefore they need
MULTIPLE.
Event handler are singleton with respect to an event type and source type,
that is all events from different sources of a specific event type and source
type are handled by the very same handler instance. Event handler also need
MULTIPLE.
However, they may also have
SINGLETON
which uses the very same handler instance for all sources of an event manager
independent from the event type and source type.
Note that due to event sources and event handler not being serialisable, the event manager cannot be used remotely.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PLUGIN_TYPE_EVENT_HANDLER
The plug-in type ID for event handler.
|
| Modifier and Type | Method and Description |
|---|---|
EventHandler |
addEventHandler(SessionToken session,
java.lang.String eventType,
java.lang.String sourceType,
EventHandler handler,
int index)
Adds the designated event handler to the designated event type and event
source at the designated position.
|
EventHandler |
addEventHandler(SessionToken session,
java.lang.String eventType,
java.lang.String sourceType,
java.lang.String handlerID,
int index)
Adds an event handler having the designated ID to the designated event type
and event source at the designated position.
|
EventSource<? extends Event> |
addEventSource(SessionToken session,
java.lang.String eventType,
java.lang.String sourceType,
java.lang.String sourceID,
Configuration configuration)
Adds an event source having the designated ID to the designated event type
and event source.
|
java.util.List<java.lang.String> |
getEventHandler(SessionToken session,
java.lang.String eventType,
java.lang.String sourceType)
Gets the event handler that are registered for the designated event type
and source type.
|
java.util.Collection<java.lang.String> |
getEventSources(SessionToken session,
java.lang.String eventType,
java.lang.String sourceType)
Gets the event sources that exist for the designated event type and source
type.
|
java.util.Map<java.lang.String,java.lang.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.
|
EventHandler |
removeEventHandler(SessionToken session,
java.lang.String eventType,
java.lang.String sourceType,
java.lang.String handlerID)
Removes the event handler having the designated ID and being registered for
the designated event type and event source.
|
EventSource<? extends Event> |
removeEventSource(SessionToken session,
java.lang.String eventType,
java.lang.String sourceType,
java.lang.String sourceID)
Removes the event source having the designated event type, event source and
ID.
|
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, init, ping, preShutdown, shutdown, startstatic final java.lang.String PLUGIN_TYPE_EVENT_HANDLER
java.util.Map<java.lang.String,java.lang.Class<? extends Event>> getSupportedEventTypes(SessionToken session)
session - The session which is used to check for access rights on this
method.java.util.Collection<java.lang.String> getEventSources(SessionToken session, java.lang.String eventType, java.lang.String sourceType)
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.EventSource<? extends Event> addEventSource(SessionToken session, java.lang.String eventType, java.lang.String sourceType, java.lang.String sourceID, Configuration configuration) throws ConfigurationException, ServiceNotKnownException
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.configuration - The configuration of the source which complements the
plugin configuration.ConfigurationException - If there are problems with the designated
configuration, a ConfigurationException will be
thrown.ServiceNotKnownException - If there are problems with the plugin
configuration or no plugin configured at all for the designated
source a ServiceNotKnownException will be thrown.EventSource<? extends Event> removeEventSource(SessionToken session, java.lang.String eventType, java.lang.String sourceType, java.lang.String sourceID)
null will be returned. All handler will be removed from the
designated event source.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.null in case there
is already an event source of the designated source ID.java.util.List<java.lang.String> getEventHandler(SessionToken session, java.lang.String eventType, java.lang.String sourceType)
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.EventHandler addEventHandler(SessionToken session, java.lang.String eventType, java.lang.String sourceType, java.lang.String handlerID, int index) throws ServiceNotKnownException
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.ServiceNotKnownException - If there are problems with the plugin
configuration or no plugin configured at all for the designated
source a ServiceNotKnownException will be thrown.EventHandler addEventHandler(SessionToken session, java.lang.String eventType, java.lang.String sourceType, EventHandler handler, int index)
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.handler - The handler which to add.index - The (0-based) position in the handler list for the designated
event type and source type.EventHandler removeEventHandler(SessionToken session, java.lang.String eventType, java.lang.String sourceType, java.lang.String handlerID)
null will be
returned. The handler will be removed from the corresponding event sources.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.null in case there is
already an event source of the designated source ID.