|
Griffon 0.9.5-rc2 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.griffon.runtime.core.EventRouter
public class EventRouter extends Object
An event handling helper.
Listeners may be of type
Some examples of eventHandler names are: onStartupStart, onMyCoolEvent. Event names must follow the camelCase naming convention.
Field Summary | |
---|---|
private static Object |
LOCK
|
private static org.slf4j.Logger |
LOG
|
private Map |
closureListeners
|
private static int |
count
|
private BlockingQueue |
deferredEvents
|
private boolean |
enabled
|
private List |
listeners
|
private Map |
scriptBindings
|
Constructor Summary | |
EventRouter()
|
Method Summary | |
---|---|
void
|
addEventListener(Object listener)
Adds an event listener. |
void
|
addEventListener(Map listener)
Adds a Map containing event listeners. |
void
|
addEventListener(String eventName, Closure listener)
Adds a Closure as an event listener. |
void
|
addEventListener(String eventName, RunnableWithArgs listener)
Adds a Runnable as an event listener. |
private Object[]
|
asArray(List list)
|
private Runnable
|
buildPublisher(String event, List params, String mode)
|
private void
|
fireEvent(Script script, String eventHandler, List params)
|
private void
|
fireEvent(Map map, String eventHandler, List params)
|
private void
|
fireEvent(Closure closure, String eventHandler, List params)
|
private void
|
fireEvent(RunnableWithArgs runnable, String eventHandler, List params)
|
private void
|
fireEvent(Object instance, String eventHandler, List params)
|
private static int
|
identifier()
|
private void
|
invokeHandler(Object handler, List params)
|
boolean
|
isEnabled()
Returns the current enabled state. |
private boolean
|
isNestedListener(Object listener, Object subject)
|
private MetaClass
|
metaClassOf(Object obj)
|
void
|
publish(String eventName)
Publishes an event with optional arguments. |
void
|
publish(String eventName, List params)
Publishes an event with optional arguments. |
void
|
publishAsync(String eventName)
Publishes an event with optional arguments. |
void
|
publishAsync(String eventName, List params)
Publishes an event with optional arguments. |
void
|
publishOutside(String eventName)
Publishes an event with optional arguments. |
void
|
publishOutside(String eventName, List params)
Publishes an event with optional arguments. |
void
|
publishOutsideUI(String eventName)
Publishes an event with optional arguments. |
void
|
publishOutsideUI(String eventName, List params)
Publishes an event with optional arguments. |
void
|
removeEventListener(Object listener)
Removes an event listener. |
void
|
removeEventListener(Map listener)
Removes a Map containing event listeners. |
void
|
removeEventListener(String eventName, Closure listener)
Removes a Closure as an event listener. |
void
|
removeEventListener(String eventName, RunnableWithArgs listener)
Removes a Runnable as an event listener. |
private void
|
removeNestedListeners(Object subject)
|
void
|
setEnabled(boolean enabled)
Sets the enabled state of this router. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
private static final Object LOCK
private static final org.slf4j.Logger LOG
private final Map closureListeners
private static int count
private final BlockingQueue deferredEvents
private boolean enabled
private final List listeners
private final Map scriptBindings
Constructor Detail |
---|
public EventRouter()
Method Detail |
---|
public void addEventListener(Object listener)
A listener may be a
Some examples of eventHandler names are: onStartupStart, onMyCoolEvent. Event names must follow the camelCase naming convention.
listener
- an event listener of type Script, Map or Object
public void addEventListener(Map listener)
An event listener may be a
Some examples of eventHandler names are: StartupStart, MyCoolEvent. Event names must follow the camelCase naming convention.
listener
- an event listener of type Script, Map or Object
public void addEventListener(String eventName, Closure listener)
Event names must follow the camelCase naming convention.
eventName
- the name of the eventlistener
- the event listener
public void addEventListener(String eventName, RunnableWithArgs listener)
Event names must follow the camelCase naming convention.
eventName
- the name of the eventlistener
- the event listener
private Object[] asArray(List list)
private Runnable buildPublisher(String event, List params, String mode)
private void fireEvent(Script script, String eventHandler, List params)
private void fireEvent(Map map, String eventHandler, List params)
private void fireEvent(Closure closure, String eventHandler, List params)
private void fireEvent(RunnableWithArgs runnable, String eventHandler, List params)
private void fireEvent(Object instance, String eventHandler, List params)
private static int identifier()
private void invokeHandler(Object handler, List params)
public boolean isEnabled()
private boolean isNestedListener(Object listener, Object subject)
private MetaClass metaClassOf(Object obj)
public void publish(String eventName)
eventName
- the name of the event
public void publish(String eventName, List params)
eventName
- the name of the eventparams
- the event's arguments
public void publishAsync(String eventName)
eventName
- the name of the event
public void publishAsync(String eventName, List params)
eventName
- the name of the eventparams
- the event's arguments
@Deprecated public void publishOutside(String eventName)
eventName
- the name of the event
@Deprecated public void publishOutside(String eventName, List params)
eventName
- the name of the eventparams
- the event's arguments
public void publishOutsideUI(String eventName)
eventName
- the name of the event
public void publishOutsideUI(String eventName, List params)
eventName
- the name of the eventparams
- the event's arguments
public void removeEventListener(Object listener)
A listener may be a
Some examples of eventHandler names are: onStartupStart, onMyCoolEvent. Event names must follow the camelCase naming convention.
listener
- an event listener of type Script, Map or Object
public void removeEventListener(Map listener)
An event listener may be a
Some examples of eventHandler names are: StartupStart, MyCoolEvent. Event names must follow the camelCase naming convention.
listener
- an event listener of type Script, Map or Object
public void removeEventListener(String eventName, Closure listener)
Event names must follow the camelCase naming convention.
eventName
- the name of the eventlistener
- the event listener
public void removeEventListener(String eventName, RunnableWithArgs listener)
Event names must follow the camelCase naming convention.
eventName
- the name of the eventlistener
- the event listener
private void removeNestedListeners(Object subject)
public void setEnabled(boolean enabled)
enabled
- the value for the enabled state
Groovy Documentation