public class DefaultEventDispatcher extends Object implements EventDispatcher
EventHandler
.Modifier and Type | Field and Description |
---|---|
private List<EventHandler> |
genericHandlers |
private Map<Integer,List<EventHandler>> |
handlersByEventType |
private boolean |
isShuttingDown |
Constructor and Description |
---|
DefaultEventDispatcher() |
DefaultEventDispatcher(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 and returns the number
of handlers cleared.
|
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
EventHandler s 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 Map<Integer,List<EventHandler>> handlersByEventType
private List<EventHandler> genericHandlers
private boolean isShuttingDown
public DefaultEventDispatcher()
public DefaultEventDispatcher(Map<Integer,List<EventHandler>> handlersByEventType, List<EventHandler> genericHandlers)
public void addHandler(EventHandler eventHandler)
EventDispatcher
addHandler
in interface EventDispatcher
eventHandler
- The event handler to be added to the dispatcher.public List<EventHandler> getHandlers(int eventType)
EventDispatcher
EventHandler
s associated with a particular
event type.getHandlers
in interface EventDispatcher
eventType
- The type of event.EventHandler
s associated with that event or
null.public void removeHandler(EventHandler eventHandler)
EventDispatcher
removeHandler
in interface EventDispatcher
eventHandler
- the event handler to be removed from the dispatcherpublic void removeHandlersForEvent(int eventType)
EventDispatcher
removeHandlersForEvent
in interface EventDispatcher
public boolean removeHandlersForSession(Session session)
EventDispatcher
removeHandlersForSession
in interface EventDispatcher
public void clear()
EventDispatcher
clear
in interface EventDispatcher
public void fireEvent(Event event)
EventDispatcher
fireEvent
in interface EventDispatcher
public void close()
EventDispatcher
close
in interface EventDispatcher
Copyright © 2012. All Rights Reserved.