public interface EventHandler
EventHandler listens to an event and processes it as soon as
the event occurs. Event handlers usually can only process specific events.
Therefore they are registered at specific event sources for specific event
types. There may be several event handlers registered at a event source. To
improve event processing, event handling may take place concurrently, that is
several registered event handler receive and handle the same event at once.
This requires the event handler to process appropriately and the event itself
to be concurrently accessible. An event handler can be exclusive which
prevents concurrent processing and uses sequential processing instead. Each event handler has an ID which uniquely (with respect to an event manager) identifies this handler. Usually an event handler is loaded as plugin of an event manager. In this case the handler ID should correspond to the simple instance name of the plugin.
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getID()
Gets the ID of this event handler.
|
boolean |
handleEvent(Event event,
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.
|
java.lang.String getID()
boolean isExclusive()
boolean isConsuming()
boolean isInterruptible()
boolean handleEvent(Event event, boolean consumed) throws EventHandlingException
event - 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.