public class ExecutorEventDispatcher extends Object implements EventDispatcher
| Modifier and Type | Field and Description |
|---|---|
private static ExecutorService |
EXECUTOR |
private List<EventHandler> |
genericHandlers |
private Map<Integer,List<EventHandler>> |
handlersByEventType |
private boolean |
isShuttingDown |
| Constructor and Description |
|---|
ExecutorEventDispatcher() |
ExecutorEventDispatcher(Map<Integer,List<EventHandler>> handlersByEventType,
List<EventHandler> genericHandlers) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHandler(EventHandler eventHandler)
Adds event handler to the dispatcher.
|
void |
clear()
Clears all handles associated with this dispatcher.
|
void |
close()
Called by the session during disconnect, the dispatcher will no longer
accept any events, it will also detach the existing listeners.
|
void |
fireEvent(Event event)
Fires event in asynchronous mode
|
List<EventHandler> |
getHandlers(int eventType)
Returns the list of
EventHandlers associated with a particular
event type. |
void |
removeHandler(EventHandler eventHandler)
Removes an event handler from the dispatcher
|
void |
removeHandlersForEvent(int eventType)
Removes all event listeners associated with the event type.
|
boolean |
removeHandlersForSession(Session session)
Removes all the handlers for a session.
|
private static final ExecutorService EXECUTOR
private Map<Integer,List<EventHandler>> handlersByEventType
private List<EventHandler> genericHandlers
private boolean isShuttingDown
public ExecutorEventDispatcher()
public ExecutorEventDispatcher(Map<Integer,List<EventHandler>> handlersByEventType, List<EventHandler> genericHandlers)
public void addHandler(EventHandler eventHandler)
EventDispatcheraddHandler in interface EventDispatchereventHandler - The event handler to be added to the dispatcher.public List<EventHandler> getHandlers(int eventType)
EventDispatcherEventHandlers associated with a particular
event type.getHandlers in interface EventDispatchereventType - The type of event.EventHandlers associated with that event or
null.public void removeHandler(EventHandler eventHandler)
EventDispatcherremoveHandler in interface EventDispatchereventHandler - the event handler to be removed from the dispatcherpublic void removeHandlersForEvent(int eventType)
EventDispatcherremoveHandlersForEvent in interface EventDispatcherpublic boolean removeHandlersForSession(Session session)
EventDispatcherremoveHandlersForSession in interface EventDispatchersession - The session instance from which event handlers need to be
removed.public void clear()
EventDispatcherclear in interface EventDispatcherpublic void fireEvent(Event event)
EventDispatcherfireEvent in interface EventDispatcherpublic void close()
EventDispatcherclose in interface EventDispatcherCopyright © 2013. All Rights Reserved.