public class DefaultListenerManager extends Object implements ListenerManager
| Constructor and Description |
|---|
DefaultListenerManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Class<?> listenerType,
String method,
Closure listenerClosure)
Added a listener implemented via a Groovy closure.
|
void |
addListener(Object listener)
Added a listener.
|
<T> ListenerBroadcast<T> |
createAnonymousBroadcaster(Class<T> listenerClass)
Returns a broadcaster for the given listenerClass.
|
ListenerManager |
createChild()
Creates a child
ListenerManager. |
<T> T |
getBroadcaster(Class<T> listenerClass)
Returns a broadcaster for the given listenerClass.
|
void |
removeListener(Object listener)
Removes a listener.
|
void |
useLogger(Object logger)
Uses the given object as a logger.
|
public void addListener(Object listener)
ListenerManager(listener instanceof T) returns true.addListener in interface ListenerManagerlistener - the listener to add.public void addListener(Class<?> listenerType, String method, Closure listenerClosure)
ListenerManageraddListener in interface ListenerManagerlistenerType - The class of the listener type for which the closure is a method implementation.method - The name of the method in the listenerType class for which the closure is an implementation.listenerClosure - The closure containing the implementation of the listener method.public void removeListener(Object listener)
ListenerManager(listener instanceof T) returns true.removeListener in interface ListenerManagerlistener - the listener to remove.public void useLogger(Object logger)
ListenerManageruseLogger in interface ListenerManagerlogger - The new logger to use.public <T> T getBroadcaster(Class<T> listenerClass)
ListenerManagerListenerManager.addListener(Object) and ListenerManager.removeListener(Object) after they have been returned. Broadcasters are also cached, so that repeatedly calling
this method with the same listenerClass returns the same broadcaster object.getBroadcaster in interface ListenerManagerlistenerClass - The type of listener for which to return a broadcaster.public <T> ListenerBroadcast<T> createAnonymousBroadcaster(Class<T> listenerClass)
ListenerManagerListenerManager.getBroadcaster(Class) for the given listener type. However, it can also have
listeners assigned/removed directly to/from it. This allows these "anonymous" broadcasters to specialize what
listeners receive messages. Each call creates a new broadcaster, so that client code can create as many "facets"
of the listener as they need. The client code must provide some way for its users to register listeners on the
specialized broadcasters.createAnonymousBroadcaster in interface ListenerManagerlistenerClass - The type of listener for which to create a broadcaster.public ListenerManager createChild()
ListenerManagerListenerManager. All events broadcast in the child will be received by the listeners
registered in the parent. However, the reverse is not true: events broadcast in the parent are not received
by the listeners in the children. The child inherits the loggers of its parent, though these can be replaced.createChild in interface ListenerManagerCopyright © 2013. All rights reserved