|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfulmine.event.listener.AbstractEventHandler<T>
T - the IEvent type for this handler.public abstract class AbstractEventHandler<T extends IEvent>
Base class for an object that handles a specific type of IEvent. This
is generally used by an IEventListener to delegate processing of a
specific event. Handlers are not designed to maintain state so do not
implement the life-cycle interface.
This class and sub-classes are thread safe if the event generic parameter is
a system event (system events are bound to a single EventProcessor).
MultiEventListener| Constructor Summary | |
|---|---|
AbstractEventHandler()
|
|
| 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). |
static Map<Class<? extends IEvent>,IEventListener> |
getEventHandlerMappings(AbstractEventHandler<? extends IEvent>... handlers)
Given a group of AbstractEventHandler instances, this method
returns a map of the handlers indexed by the IEvent class each
one handles. |
Class<? extends IEvent>[] |
getEventTypeFilter()
Get the classes of IEvent instances this listener can process. |
protected abstract AsyncLog |
getLog()
Get the log to use |
abstract void |
handle(T event)
Handle the event. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractEventHandler()
| Method Detail |
|---|
public static Map<Class<? extends IEvent>,IEventListener> getEventHandlerMappings(AbstractEventHandler<? extends IEvent>... handlers)
AbstractEventHandler instances, this method
returns a map of the handlers indexed by the IEvent class each
one handles. The event for each handler is determined from the generic
type argument of the handler implementation.
handlers - the handlers to build an IEvent indexed map of
Map of the handlers, indexed by the IEvent each
one handlespublic final void update(IEvent event)
IEventListenerIEventSource 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.
update in interface IEventListenerevent - the event encapsulating the update.public void addedAsListenerFor(IEventSource source)
IEventListenerIEventSource.addListener(IEventListener).
addedAsListenerFor in interface IEventListenersource - the source that this listener will receive events from.public void removedAsListenerFrom(IEventSource source)
IEventListenerIEventSource.removeListener(IEventListener).
removedAsListenerFrom in interface IEventListenersource - the source that this listener will no longer receive events
from.public final Class<? extends IEvent>[] getEventTypeFilter()
IEventListenerIEvent instances this listener can process.
The IEventListener.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.
getEventTypeFilter in interface IEventListenerClass objects that determine the types of
IEvent instances this listener can processpublic abstract void handle(T event)
EventProcessor instance that is bound to the event's source.
event - the eventIEventManager.queueEvent(IEvent)protected abstract AsyncLog getLog()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||