net.wotonomy.control
Class EODelayedObserverQueue

java.lang.Object
  extended by net.wotonomy.control.EODelayedObserverQueue

public class EODelayedObserverQueue
extends java.lang.Object

EODelayedObserverQueue allows EODelayedObservers to receive only one subjectChanged() message after numerous willChange() messages have been sent. Observers are then notified in order of their priority property, so that certain observers can be notified before others for whatever application-specific purpose. This class is not thread-safe and should be used only for single-threaded GUI clients (AWT and Swing).

Important note: because AWT's event queue does not allow for priority-based scheduling, this class installs a custom event queue, replacing the existing queue on the AWT dispatch thread. We know of no way around this problem.

Implementation note: this queue relies on the result of equals() for maintaining a set of objects on the queue. If two EODelayedObservers evaluate to the same value using equals(), only one of them will exist on the queue. If this, starts to suck, we can change it.

Version:
$Revision: 894 $
Author:
michael@mpowers.net, $Author: cgruber $

Field Summary
static int FlushDelayedObserversRunLoopOrdering
          The default run loop ordering flushes the delayed observers up to ObserverPrioritySixth before dispatching the AWT event queue.
 
Constructor Summary
EODelayedObserverQueue()
          Default constructor.
 
Method Summary
static EODelayedObserverQueue defaultObserverQueue()
          Returns the system default observer queue.
 void dequeueObserver(EODelayedObserver anObserver)
          Removes the specified observer from the queue.
 void enqueueObserver(EODelayedObserver anObserver)
          Adds the specified observer to the queue.
 void flushObserverQueue(java.lang.Object anObject)
          This method is called by the event queue run loop and calls notifyObserversUpToPriority with ObserverPriorityLater.
 void notifyObserversUpToPriority(int priority)
          Notifies all observers with priority equal to or greater than the specified priority.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FlushDelayedObserversRunLoopOrdering

public static int FlushDelayedObserversRunLoopOrdering
The default run loop ordering flushes the delayed observers up to ObserverPrioritySixth before dispatching the AWT event queue. ObserverPriorityLater is run last.

Constructor Detail

EODelayedObserverQueue

public EODelayedObserverQueue()
Default constructor.

Method Detail

defaultObserverQueue

public static EODelayedObserverQueue defaultObserverQueue()
Returns the system default observer queue.


dequeueObserver

public void dequeueObserver(EODelayedObserver anObserver)
Removes the specified observer from the queue.


enqueueObserver

public void enqueueObserver(EODelayedObserver anObserver)
Adds the specified observer to the queue. An already enqueued observer will not be added again. If the observer's priority is ObserverPriorityImmediate, it will be notified immediately and not added to the queue. Otherwise, the queue sets itself up to call notifyObserversUpToPriority during the run loop as specified by FlushDelayedObserversRunLoopOrdering.


notifyObserversUpToPriority

public void notifyObserversUpToPriority(int priority)
Notifies all observers with priority equal to or greater than the specified priority.


flushObserverQueue

public void flushObserverQueue(java.lang.Object anObject)
This method is called by the event queue run loop and calls notifyObserversUpToPriority with ObserverPriorityLater. NOTE: This method is not part of the specification.



Copyright © 2006 null. All Rights Reserved.