public interface ListenerManager
| 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.
|
void addListener(Object listener)
(listener instanceof T) returns true.listener - the listener to add.void addListener(Class<?> listenerType, String method, Closure listenerClosure)
listenerType - 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.void removeListener(Object listener)
(listener instanceof T) returns true.listener - the listener to remove.<T> T getBroadcaster(Class<T> listenerClass)
addListener(Object) and 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.listenerClass - The type of listener for which to return a broadcaster.<T> ListenerBroadcast<T> createAnonymousBroadcaster(Class<T> listenerClass)
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.listenerClass - The type of listener for which to create a broadcaster.void useLogger(Object logger)
logger - The new logger to use.ListenerManager createChild()
ListenerManager. 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.Copyright © 2013. All rights reserved