|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IEventListener
A listener processes notifications from IEventSource
instances. The
notifications are encapsulated in IEvent
instances and are received
via the update(IEvent)
method.
A listener is required to supply the class of the IEvent
instances it
can process. Before an event is passed into the update(IEvent)
method, the class of the event is checked against those returned from
getEventTypeFilter()
. If the event class is assignment
compatible with any contained in getEventTypeFilter()
then the
update(IEvent)
method is called with the event.
If a listener is registered against multiple IEventSource
instances,
the notifications may be executed by different EventProcessor
instances (different thread contexts) and so the update(IEvent)
method would need to be thread aware.
The listener also receives a notification when it has been added to and
removed from an IEventSource
.
Method Summary | |
---|---|
void |
addedAsListenerFor(IEventSource source)
The listener receives this when it has been added as a listener to an event source via IEventSource.addListener(IEventListener) . |
Class<? extends IEvent>[] |
getEventTypeFilter()
Get the classes of IEvent instances this listener can process. |
void |
removedAsListenerFrom(IEventSource source)
The listener receives this when it has been removed as a listener from an event source via IEventSource.removeListener(IEventListener) . |
void |
update(IEvent event)
An update has occurred that this listener is interested in. |
Method Detail |
---|
void update(IEvent event)
IEventSource
instances are bound to EventProcessor
instances so the same thread will execute this method for events
originating from the same event source. This does not mean that this
method is thread safe; this method may be run by multiple
EventProcessor
instances and so should be thread aware as
appropriate.
This method can throw any Exception
and processing will not be
interrupted. The EventProcessor
will handle the exception.
event
- the event encapsulating the update.void addedAsListenerFor(IEventSource source)
IEventSource.addListener(IEventListener)
.
source
- the source that this listener will receive events from.void removedAsListenerFrom(IEventSource source)
IEventSource.removeListener(IEventListener)
.
source
- the source that this listener will no longer receive events
from.Class<? extends IEvent>[] getEventTypeFilter()
IEvent
instances this listener can process.
The update(IEvent)
method will only be called with
IEvent
instances whose Class
is assignment
compatible with any contained in this array.
This is an event filtering mechanism. An IEventSource
may
generate many types of IEvent
instances but a listener may only
be interested in one type. By specifying the types of events the listener
is interested in using this method, the listener effectively filters out
unwanted events.
If the filter is dynamic then this method must be thread aware.
Class
objects that determine the types of
IEvent
instances this listener can process
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |