PATH  Documentation > WebObjects 4.5 > EOControl Reference

Table of Contents

EODelayedObserverQueue


Inherits from:
(com.apple.client.eocontrol) Object
(com.apple.yellow.eocontrol) NSObject
Package:
com.apple.client.eocontrol
com.apple.yellow.eocontrol


Class Description


The EODelayedObserverQueue class is a part of EOControl's change tracking mechanism. An EODelayedObserverQueue collects change notifications for observers of multiple objects and notifies them of the changes en masse during the application's run loop, according to their individual priorities. For an overview of the general change tracking mechanism, see "Tracking Enterprise Objects Changes" in the introduction to the EOControl Framework.

EODelayedObserverQueue's style of notification is particularly useful for coalescing and prioritizing multiple changes; the interface layer's EOAssociation classes use it extensively to update Java Client and Application Kit user interfaces, for example. Instead of being told that an object will change, an EODelayedObserver is told that it did change, with a subjectChanged message, as described in the EODelayedObserver class specification. Delayed observation is thus not useful for comparing old and new states, but only for examining the new state. Delayed observation also isn't ordinarily used outside the scope of a Java Client or Application Kit application (in a command line tool or WebObjects application, for example).

The motivation for a delayed change notification mechanism arises mainly from issues in observing multiple objects. Any single change to an observed object typically requires the observer to update some state or perform an action. When many such objects change, it makes no sense to recalculate the new state and perform the action for each object. EODelayedObserverQueue allows these changes to be collected into a single notification. It further orders change notifications according to priorities, allowing observers to be updated in sequence according to dependencies among them. For example, an EOMasterDetailAssociation (EOInterface), which must update its detail EODisplayGroup (EOInterface) according to the selection in the master before any redisplay occurs, has an earlier priority than the default for EOAssociations. This prevents regular EOAssociations from redisplaying old values and then displaying the new values after the EOMasterDetailAssociation updates.

For more information on using EODelayedObserverQueues, see the sections




Constants


EODelayedObserverQueue defines the following int constant:


Constant Description
FlushDelayedObserversRunLoopOrdering Determines when to notify delayed observers during end of event processing.



Method Types


Constructors
EODelayedObserverQueue
Getting the default queue
defaultObserverQueue
Enqueuing and dequeuing observers
enqueueObserver
dequeueObserver
Sending change notifications
notifyObserversUpToPriority
Configuring notification behavior
runLoopModes (com.apple.yellow.eocontrol only)
setRunLoopModes (com.apple.yellow.eocontrol only)


Constructors



EODelayedObserverQueue

public EODelayedObserverQueue()

Creates and returns a new EODelayedObserverQueue with NSRunLoop.DefaultRunLoopMode as its only run loop mode.

See Also: runLoopModes (com.apple.yellow.eocontrol only)




Static Methods



defaultObserverQueue

public static EODelayedObserverQueue defaultObserverQueue()

Returns the EODelayedObserverQueue that EODelayedObservers use by default.


Instance Methods



dequeueObserver

public void dequeueObserver(EODelayedObserver anObserver)

Removes anObserver from the receiver.

See Also: enqueueObserver



enqueueObserver

public void enqueueObserver(EODelayedObserver anObserver)

Records anObserver to be sent subjectChanged messages. If anObserver's priority is ObserverPriorityImmediate, it's immediately sent the message and not enqueued. Otherwise anObserver is sent the message the next time notifyObserversUpToPriority is invoked with a priority later than or equal to anObserver's. Does nothing if anObserver is already recorded.

The first time this method is invoked during the run loop with an observer whose priority isn't ObserverPriorityImmediate, it registers the receiver to be sent a notifyObserversUpToPriority message at the end of the run loop, using FlushDelayedObserversRunLoopOrdering and the receiver's run loop modes. This causes enqueued observers up to a priority of ObserverPrioritySixth to be notified automatically during each pass of the run loop.

When anObserver is done observing changes, it should invoke discardPendingNotification to remove itself from the queue.

See Also: dequeueObserver, priority (EODelayedObserver), discardPendingNotification (EODelayedObserver), runLoopModes (com.apple.yellow.eocontrol only)



notifyObserversUpToPriority

public void notifyObserversUpToPriority(int priority)

Sends subjectChanged messages to all of the receiver's enqueued observers whose priority is priority or earlier. This method cycles through the receiver's enqueued observers in priority order, sending each a subjectChanged message and then returning to the very beginning of the queue, in case another observer with an earlier priority was enqueued as a result of the message.

EODelayedObserverQueue invokes this method automatically as needed during the run loop, with a priority of ObserverPrioritySixth.

See Also: enqueueObserver, priority (EODelayedObserver)



runLoopModes

public NSArray runLoopModes()

(com.apple.yellow.eocontrol only) Returns the receiver's run loop modes.



setRunLoopModes

public void setRunLoopModes(NSArray modes)

(com.apple.yellow.eocontrol only) Sets the receiver's run loop modes to modes, an array of NSString objects representing run loop modes. For more information see the Foundation class NSRunLoop.




Table of Contents