Interface EventSource<T extends Event>
-
- Type Parameters:
T
- The type of events this event source creates.
- All Superinterfaces:
Runnable
- All Known Subinterfaces:
ActivityEventSource<T>
,FilteredMailSource
,MailSource
,MemoryResultSetSource
,PollingFileSource
,PollingMailSource
,PollingSource<T>
,ResultSetSource
,SharedPollingSource<T>
,SharingSource<T>
- All Known Implementing Classes:
AbstractEventSource
,AbstractSharedEventSource
,AbstractSharingActEventSource
,DBActivityEventSource
,DBEventSource
,FileEventActivitySource
,FileEventSource
,FilteredMailEventActivitySource
,FilteredMailEventSource
,MailEventActivitySource
,MailEventSource
,ReadOnlyRSEventSource
public interface EventSource<T extends Event> extends Runnable
An event source produces events and forwards them to one or more event handler for processing the event. The type of the produced events is arbitrary and depends on the event source. An event may be produced when receiving a specific signal or specific data is available at some point in time. Since this mostly involves waiting, an event source has aRunnable.run()
-method that checks and waits for the event, creates it and calls the registered event handler.
Event sources that produce similar events have the same source type. Usually an event is loaded as plugin. In this case it is provided a plugin instance name and a configuration. The (simple) plugin instance name is used as event source type. The configuration is just the basic configuration which may be complemented and/or replaced later by setting another configuration (together with the source ID).- Author:
- Ulrich Kreher
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addAll(List<EventHandler> handler)
Adds the designated event handler in the designated order to the list of the handler that are already registered.void
addHandler(EventHandler handler, int index)
Adds the designated handler at the designated position (0-based) to the list of registered handler.List<EventHandler>
getEventHandler()
Gets the event handler that have been registered for this event source.String
getHierarchicalSourceName()
Gets the hierarchical name of this source, that is the event type, the source type and the source ID for usage in log messages and alike.String
getID()
Gets the ID of this source.String
getType()
Gets the type of this source.EventHandler
removeHandler(String handlerID)
Removes the handler with the designated ID from the list and returns it.void
setConfiguration(org.apache.commons.configuration2.Configuration conf, String id)
Sets the (additional) configuration of this event source and its ID.
-
-
-
Method Detail
-
getType
String getType()
Gets the type of this source. This is usually the simple instance name of the plugin, if the event source has been loaded as plugin.- Returns:
- The type of this source.
-
getID
String getID()
Gets the ID of this source. Until separatelyset
this ID is arbitrary and may even benull
.- Returns:
- The ID of this source.
-
getHierarchicalSourceName
String getHierarchicalSourceName()
Gets the hierarchical name of this source, that is the event type, the source type and the source ID for usage in log messages and alike.- Returns:
- The hierarchical name of this source, that is the event type, the source type and the source ID.
-
setConfiguration
void setConfiguration(org.apache.commons.configuration2.Configuration conf, String id) throws ConfigurationException
Sets the (additional) configuration of this event source and its ID. The configuration is additional with respect to the configuration provided by the plugin load mechanism, if the event source is loaded as plugin.
It is ensured that this method will be called beforeRunnable.run()
.- Parameters:
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 benull
depends on the implementation of the event source.id
- The ID of this event source. This must not benull
nor the empty string.- Throws:
ConfigurationException
- If there are problems with the designated configuration (configuration isnull
although this is not allowed, a required configuration value is missing, ...), aConfigurationException
will be thrown.
-
getEventHandler
List<EventHandler> getEventHandler()
Gets the event handler that have been registered for this event source. These handler are notified about an event in the designated order.- Returns:
- The event handler that have been registered for this event source.
-
addHandler
void addHandler(EventHandler handler, int index)
Adds the designated handler at the designated position (0-based) to the list of registered handler. It is not checked, whether the handler is already registered.- Parameters:
handler
- The handler which to add.index
- The index (0-based) at which to add the handler in the list.
-
addAll
void addAll(List<EventHandler> handler)
Adds the designated event handler in the designated order to the list of the handler that are already registered. It is not checked whether a handler is already registered (and neither whether a handler is several times in the designated list.- Parameters:
handler
- The handler to register in the designated order. They are added at the end of the list of handler that are already registered.
-
removeHandler
EventHandler removeHandler(String handlerID)
Removes the handler with the designated ID from the list and returns it. If there is no handler registered with the designated ID,null
will be returned.- Parameters:
handlerID
- The ID of the handler which to remove.- Returns:
- The removed handler or
null
in case no handler with the designated ID has been registered.
-
-