fulmine.event.listener
Interface IEventListener

All Known Subinterfaces:
ILifeCycleEventListener, IPriorityEventListener, IPriorityLifeCycleEventListener, ISubscriptionListener, ISystemEventListener
All Known Implementing Classes:
AbstractEventHandler, ActiveEventListener, ChannelTransmissionListener, MultiEventListener, MultiSystemEventListener, PriorityMultiEventListener, RecordTable, RecordViewer, Subscriber

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.

Author:
Ramon Servadei

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

update

void update(IEvent event)
An update has occurred that this listener is interested in. 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.

Parameters:
event - the event encapsulating the update.

addedAsListenerFor

void addedAsListenerFor(IEventSource source)
The listener receives this when it has been added as a listener to an event source via IEventSource.addListener(IEventListener).

Parameters:
source - the source that this listener will receive events from.

removedAsListenerFrom

void removedAsListenerFrom(IEventSource source)
The listener receives this when it has been removed as a listener from an event source via IEventSource.removeListener(IEventListener).

Parameters:
source - the source that this listener will no longer receive events from.

getEventTypeFilter

Class<? extends IEvent>[] getEventTypeFilter()
Get the classes of 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.

Returns:
an array of Class objects that determine the types of IEvent instances this listener can process


Copyright © 2007-2009. All Rights Reserved.