|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limitless.util.GeneralEventSource
public class GeneralEventSource
This class provides a simple way to ensure that an event source can handle all the queue management. Specifically, this handles the Observer's Subscriber aspect for Java's event model. It lets us add and remove listeners. It also allows us to discard all the listeners. To avoid ConcurrentModification exceptions, any changes to the list of listeners is queued during iterations in order and will be applied at the completion of iteration using the Command pattern.
| Nested Class Summary | |
|---|---|
static interface |
GeneralEventSource.Invoke
A listener must implement this if it wants to be invoked by this source and requires no exceptions be thrown. |
static interface |
GeneralEventSource.InvokeWithException
A listener must implement this if it wants to be invoked by this source and requires exceptions be thrown. |
private class |
GeneralEventSource.QueuedEvent
|
| Field Summary | |
|---|---|
private boolean |
isIterating
This is set true when iterating, and will cause requests to add, remove, or clear to be "queued up" and carried out after the iteration completes. |
private java.util.Collection |
listeners
The master listener collection. |
private java.util.LinkedList |
queuedEvents
This holds QueuedEvent objects so we can "replay" at the end of an iteration what was requested. |
| Constructor Summary | |
|---|---|
GeneralEventSource()
Create the basic object. |
|
| Method Summary | |
|---|---|
void |
add(java.util.EventListener newListener)
Call this to add a listener for invocations. |
void |
clear()
Discard all listeners. |
private void |
processQueuedEvents()
|
void |
remove(java.util.EventListener listenerToRemove)
Take a particular listener out of the set. |
void |
visit(GeneralEventSource.Invoke functor)
This causes an invoker to be called once per object in the set. |
void |
visit(GeneralEventSource.InvokeWithException functor)
This causes an invoker to be called once per object in the set. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.Collection listeners
private boolean isIterating
private java.util.LinkedList queuedEvents
| Constructor Detail |
|---|
public GeneralEventSource()
| Method Detail |
|---|
public void add(java.util.EventListener newListener)
newListener - listener to add (duplicates harmless)public void remove(java.util.EventListener listenerToRemove)
listenerToRemove - public void visit(GeneralEventSource.Invoke functor)
functor - Object to be invoked per entry in the set.
public void visit(GeneralEventSource.InvokeWithException functor)
throws java.lang.Exception
functor - Object to be invoked per entry in the set.
java.lang.Exceptionpublic void clear()
private void processQueuedEvents()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||