T - The type of event this event source creates.public abstract class AbstractSharingActEventSource<T extends Event> extends AbstractEventSource<T> implements SharingSource<T>
DataContext).
The shared event source which distributes the events among the registered sharing event sources
via EventHandler
| Modifier and Type | Field and Description |
|---|---|
protected Configuration |
conf
The configuration containing all relevant values for this sharing event
source as retrieved from the registry and the activity.
|
protected java.lang.Class<T> |
eventClass
The event class, used for type checking.
|
protected java.lang.String |
sharedSourceType
The type of the event source.
|
eventType, handlerList, id, lock, logger, sourceType, thread, threadLock| Constructor and Description |
|---|
AbstractSharingActEventSource(Configuration conf,
Registry registry,
java.lang.Class<T> eventClass,
java.lang.String eventType,
java.lang.String sharedSourceType)
Default constructor for a plugin of the
DefaultEventManager
called by a service registry. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addedHandlerLocked(int index,
EventHandler handler)
Signals subclasses that the designated event handler has been added to this event source at the
designated index.
|
protected void |
addedHandlerLocked(java.util.List<EventHandler> handlers)
Signals subclasses that the designated event handlers have been added to this event source at
the end of the list of event handlers.
|
void |
checkForAndHandleEvent()
Checks for an event and handles it (usually by using
AbstractEventSource.forwardEvent(Event, boolean, boolean)). |
protected abstract T |
createForwardEvent(T event)
Create a copy of the given event for forwarding it, i. e. replacing the source ID with
AbstractEventSource.getID(). |
Configuration |
getConfiguration()
Gets the (final) configuration of this sharing source.
|
SerialisableDataContext |
getDataContext()
Gets the data context of this sharing source.
|
java.lang.String |
getSharedSourceEventType()
Gets the event type of the shared event source, that is the event type of
the event source used by this sharing source.
|
java.lang.String |
getSharedSourceId()
Gets the ID of the shared event source, that is the ID of the event source
used by this sharing source.
|
java.lang.String |
getSharedSourceType()
Gets the type of the shared event source, that is the type of the event
source used by this sharing source.
|
boolean |
handleEvent(Event eve,
boolean consumed)
This method actually processes an event.
|
boolean |
isConsuming()
Gets whether this event handler is consuming and therefore may change or
consume an event while processing it.
|
boolean |
isExclusive()
Gets whether this event handler is exclusive and thus no concurrent event
handling should take place while this handler is processing an event.
|
boolean |
isInterruptible()
Whether this event handler can be interrupted while handling an event.
|
protected boolean |
nextHandler(T event,
boolean consumed,
boolean concurrent)
This method is called right before an event is offered to the next handler.
|
protected void |
removingHandlerLocked(int index,
EventHandler handler)
Signals subclasses that the designated event handler is about to be removed from the designated
index of the handler list of this event source.
|
protected void |
setConfiguration(Configuration newConf,
boolean completed)
Adds the relevant values from the designated configuration in the own
configuration of this sharing event source overriding existing values. and
verifies the complete configuration if completed.
|
void |
setConfiguration(Configuration conf,
java.lang.String id)
Sets the (additional) configuration of this event source and its ID.
|
void |
setSharedSourceId(java.lang.String sourceId)
Sets the ID of the shared event source, that is the ID of the event source
used by this sharing source.
|
protected void |
takeOverConfValuesFromConfiguration(Configuration source,
Configuration target)
Takes over all relevant configuration values from the designated source to the designated
target configuration.
|
protected void |
takeOverConfValuesFromContext(SimpleSessionContext source,
Configuration target)
Takes over all relevant configuration values from the designated session context (usually from
the corresponding activity configuration but may also be based on other elemest of the session
context.
|
protected void |
verifyConfigurationValues(Configuration configuration)
Verifies that all required configuration values have been set in the designated configuration.
|
addAll, addHandler, createPattern, forwardEvent, getEventHandler, getHierarchicalSourceName, getID, getType, maskedInterrupt, maskInterrupt, removeHandler, replaceValueParams, run, unmaskInterruptclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddAll, addHandler, getEventHandler, getHierarchicalSourceName, getID, getType, removeHandlergetIDprotected final java.lang.Class<T extends Event> eventClass
protected final java.lang.String sharedSourceType
protected final Configuration conf
public AbstractSharingActEventSource(Configuration conf, Registry registry, java.lang.Class<T> eventClass, java.lang.String eventType, java.lang.String sharedSourceType) throws ConfigurationException
DefaultEventManager
called by a service registry. It validates the configuration with respect
to this class including super-classes and interfaces.
Note that this constructor calls
setConfiguration(Configuration, boolean); subclasses may not be
fully initialised at this point.
conf - The configuration as provided from the registry.registry - The registry of this plugin.eventClass - The class of the event, used for type checking during event handling.eventType - The event type, cf. Event.getEventType().sharedSourceType - The type of the shared source.ConfigurationException - If the configuration is not valid for a
ResultSetSource, a ConfigurationException
will be thrown.protected void setConfiguration(Configuration newConf, boolean completed) throws ConfigurationException
ConfigurationException will be
thrown. newConf - The configuration which to set.completed - Whether the configuration is complete after this setting
and therefore the values should be verified.ConfigurationException - If there are problems with the
configuration, for instance the configuration does not provide
required values, a ConfigurationException may be
thrown.protected void takeOverConfValuesFromConfiguration(Configuration source, Configuration target)
conf.
This implementation does nothing as default.
source - The source configuration to read relevant configuration values from.target - The target configuration in which to write relevant configuration values to.protected void takeOverConfValuesFromContext(SimpleSessionContext source, Configuration target)
conf.
This implementation does nothing as default.
source - The session context to read relevant configuration values from.target - The target configuration in which to write relevant configuration values to.protected void verifyConfigurationValues(Configuration configuration) throws ConfigurationException
ConfigurationException
will be thrown. conf.
This implementation does nothing as default.
configuration - The configuration of which to verify its values.ConfigurationException - If there are problems with the designated configuration, for
instance the configuration does not provide required values, a
ConfigurationException may be thrown.public void setConfiguration(Configuration conf, java.lang.String id) throws ConfigurationException
EventSourceRunnable.run().setConfiguration in interface EventSource<T extends Event>setConfiguration in class AbstractEventSource<T extends Event>conf - The configuration of this event source. This adheres (and
overwrites) the configuration provided by the plugin loading, if
this event source has been loaded as plugin. Whether this is
allowed to be null depends on the implementation of
the event source.id - The ID of this event source. This must not be null
nor the empty string.ConfigurationException - If there are problems with the designated
configuration (configuration is null although this
is not allowed, a required configuration value is missing, ...),
a ConfigurationException will be thrown.public java.lang.String getSharedSourceEventType()
SharingSourcegetSharedSourceEventType in interface SharingSource<T extends Event>public java.lang.String getSharedSourceType()
SharingSourceEventSource.getType()).getSharedSourceType in interface SharingSource<T extends Event>public java.lang.String getSharedSourceId()
SharingSourcenull until
explicitly set by the event
manager.getSharedSourceId in interface SharingSource<T extends Event>null in case the
ID has not been set yet.public void setSharedSourceId(java.lang.String sourceId)
SharingSourcesetSharedSourceId in interface SharingSource<T extends Event>sourceId - The ID of the shared event source, that is the ID of the
event source used by this sharing source.public Configuration getConfiguration()
SharingSourcegetConfiguration in interface SharingSource<T extends Event>public SerialisableDataContext getDataContext()
SharingSourcegetDataContext in interface SharingSource<T extends Event>protected void addedHandlerLocked(int index,
EventHandler handler)
AbstractEventSourceThis implementation does nothing as default.
addedHandlerLocked in class AbstractEventSource<T extends Event>index - The index (position in the list of all handlers) at which the designated handler
has been added to this event source.handler - The event handler which has been added to this event source.AbstractEventSource.addHandler(EventHandler, int)protected void addedHandlerLocked(java.util.List<EventHandler> handlers)
AbstractEventSourceThis implementation does nothing as default.
addedHandlerLocked in class AbstractEventSource<T extends Event>handlers - The event handlers which have been added to this event source.AbstractEventSource.addAll(List)protected void removingHandlerLocked(int index,
EventHandler handler)
AbstractEventSourceThis implementation does nothing as default.
removingHandlerLocked in class AbstractEventSource<T extends Event>index - The index (position in the list of all handlers) from which the designated handler
will be removed from this event source.handler - The event handler which is about to be removed from this event source.AbstractEventSource.removeHandler(String)protected boolean nextHandler(T event, boolean consumed, boolean concurrent)
AbstractEventSourcenextHandler in class AbstractEventSource<T extends Event>event - The event which is about to be handled by the next registered
handler.consumed - Whether the event has been consumed yet.concurrent - Whether the next event handling is concurrent and thus
the event will be offered to several event handler concurrently.false here.public boolean isExclusive()
EventHandlerisExclusive in interface EventHandlerpublic boolean isConsuming()
EventHandlerisConsuming in interface EventHandlerpublic boolean isInterruptible()
EventHandlerisInterruptible in interface EventHandlerpublic boolean handleEvent(Event eve, boolean consumed) throws EventHandlingException
EventHandlerhandleEvent in interface EventHandlereve - The event that occurred and for which this event handler is
registered.consumed - Whether the event has been consumed by a previous event
handler.true).EventHandlingException - If there have been problems handling the
event, an EventHandlingException may be thrown. If
this is critical, the event handling for the current event will
stop. If it is non-critical, other event handlers will also get
the event for handling it. public void checkForAndHandleEvent()
AbstractEventSourceAbstractEventSource.forwardEvent(Event, boolean, boolean)).checkForAndHandleEvent in class AbstractEventSource<T extends Event>protected abstract T createForwardEvent(T event)
AbstractEventSource.getID().event - The event to be copied.