|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.common.events.EventProvider<ListenerType>
ListenerType - type of the listener.public class EventProvider<ListenerType extends IEventListener>
Helper class which provide the generic observer functionality.
Holds the list of event listeners. Supports calling the listener synchronously or asynchronously using
ExecutorService worker.
| Constructor Summary | |
|---|---|
EventProvider(ExecutorService worker)
Creates an instance of the class using the specified executor. |
|
EventProvider(String name)
Creates an instance of the class using single thread executor created by Executors.newSingleThreadExecutor() method. |
|
| Method Summary | |
|---|---|
void |
addListener(ListenerType listener)
Adds the specified event listener. |
void |
callListenersAsync(IEventCaller<ListenerType> caller)
Asynchronously calls for all registered listener the specified IEventCaller.callFor(IEventListener)
method. |
void |
callListenersSync(IEventCaller<ListenerType> caller)
Synchronously calls for all registered listener the specified IEventCaller.callFor(IEventListener)
method. |
void |
clearListeners()
Removes all listeners. |
void |
dispose()
Shuts down the worker. |
boolean |
hasListeners()
Indicates whether the event provider has still listeners that must be notified. |
void |
removeListener(ListenerType listener)
Removes the specified listener. |
void |
setEventWorker(ExecutorService worker)
Sets the executor which will be used to call asynchronous events. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EventProvider(String name)
Executors.newSingleThreadExecutor() method.
name - name of the event providerpublic EventProvider(ExecutorService worker)
worker - executor which will be used to call asynchronous events.
Can be null. In this case it will not be possible to call asynchronous events. Executor
can be set later by using setEventWorker(ExecutorService) method.
| Method Detail |
|---|
public void dispose()
public void clearListeners()
public void setEventWorker(ExecutorService worker)
If there are events that are currently being executed, they will be executed and only then the new executor will be set.
worker - the executor which will be used to call asynchronous events.
Can be null. In this case it will not be possible to call asynchronous events.
public void addListener(ListenerType listener)
listener - the listener for the events.
IllegalArgumentException - if listener is null or the same listener is already registeredpublic void removeListener(ListenerType listener)
listener - listener to removepublic void callListenersAsync(IEventCaller<ListenerType> caller)
IEventCaller.callFor(IEventListener)
method.
caller - reference to a class implementing IEventCaller interface.public void callListenersSync(IEventCaller<ListenerType> caller)
IEventCaller.callFor(IEventListener)
method.
caller - reference to a class implementing IEventCaller interface.public boolean hasListeners()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||