|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--calypso.util.ListenerList
ListenersList is a thread-safe, reentrant class which contains a list of EventListeners and enforce some policy on event dispatching.
This class guarantees that events delivering is correctly accomplished even if listeners are removed from or added to the list during event dispatching. Added listeners, though, will not receive the current event.
Event listeners are returned LIFO.
User of this class must enclose event dispatching between startDelivering()/stopDelivering() calls and pass the state object to the nextListener call.
ListenerListState state = eventListeners.startDelivering(); SomeEventListener el = (SomeEventListener)eventListeners.nextListener(state); while (null != el) { el.someEvent(); el = (SomeEventListener)eventListeners.nextListener(state); } eventListeners.stopDelivering(state);
Constructor Summary | |
ListenerList()
Construct an array of listeners with the specifed size. |
|
ListenerList(int aSize)
Construct an array of listeners with the specifed size. |
Method Summary | |
void |
addListener(java.util.EventListener aListener)
Set a new event listener for the class of events this ListenersList is mantaining. |
java.util.EventListener |
nextListener(ListenerListState aState)
Return the next EventListener in the array. |
void |
removeListener(java.util.EventListener aListener)
Remove a listener from the list of listeners this ListenersList is mantaining. Existing and valid state object are updated to reflect this change. |
ListenerListState |
startDelivering()
A user of this class is starting event delivery. |
void |
stopDelivering(ListenerListState aState)
A user completed or aborted event delivering. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ListenerList(int aSize)
The array size is doubled every time an element is added to a full array.
aSize
- the required sizepublic ListenerList()
The array size is doubled every time an element is added to a full array.
Method Detail |
public void addListener(java.util.EventListener aListener)
aListener
- a listener for the specific set of eventspublic void removeListener(java.util.EventListener aListener)
Existing and valid state object are updated to reflect this change.
aListener
- a listener for the specific set of eventspublic ListenerListState startDelivering()
The state object represents the state of the list for that user and has to be passed in every nextListener call.
aListener
- a listener for the specific set of eventspublic void stopDelivering(ListenerListState aState)
public java.util.EventListener nextListener(ListenerListState aState)
Listeners are returned with a last-in/first-out (LIFO) policy.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |