Project Wonder 2.0

er.extensions
Class ERXFileNotificationCenter

java.lang.Object
  extended byer.extensions.ERXFileNotificationCenter

public class ERXFileNotificationCenter
extends Object

The file notification center is only used in developement systems. It provides a nice repository about files and their last modified dates. So instead of every dynamic spot having to keep track of the files' dates, register and check at the end of every request-response loop, instead you can just add an observer to this center and be notified when the file changes. Files' last modification dates are checked at the end of every request-response loop.

It should be noted that the current version of the file notification center will retain a reference to each registered observer. This is not ideal and will be corrected in the future.


Nested Class Summary
static class ERXFileNotificationCenter._ObserverSelectorHolder
          Simple observer-selector holder class.
 
Field Summary
static String FileDidChange
          Contains the name of the notification that is posted when a file changes.
static ERXLogger log
          Logging support
 
Constructor Summary
ERXFileNotificationCenter()
          Default constructor.
 
Method Summary
 void addObserver(Object observer, NSSelector selector, File file)
          Used to register file observers for a particular file.
 void addObserver(Object observer, NSSelector selector, String filePath)
          Used to register file observers for a particular file.
 void checkIfFilesHaveChanged(NSNotification n)
          Notified by the NSNotificationCenter at the end of every request-response loop.
static ERXFileNotificationCenter defaultCenter()
           
protected  void fileHasChanged(File file)
          Only used internally.
 void finalize()
          When the file notification center is garbage collected it removes itself as an observer from the NSNotificationCenter.
 boolean hasFileChanged(File file)
          Compares the last modified date of the file with the last recorded modification date.
 void registerLastModifiedDateForFile(File file)
          Records the last modified date of the file for future comparison.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final ERXLogger log
Logging support


FileDidChange

public static final String FileDidChange
Contains the name of the notification that is posted when a file changes.

See Also:
Constant Field Values
Constructor Detail

ERXFileNotificationCenter

public ERXFileNotificationCenter()
Default constructor. If WOCaching is disabled (we take this to mean we are in developement) then this object will register for the notification WOApplication.ApplicationWillDispatchRequestNotification which will enable it to check if files have changed at the end of every request-response loop. If WOCaching is enabled then this object will not register for anything and will generate warning messages if observers are registered with caching enabled.

Method Detail

defaultCenter

public static ERXFileNotificationCenter defaultCenter()
Returns:
the singleton instance of file notification center

finalize

public void finalize()
              throws Throwable
When the file notification center is garbage collected it removes itself as an observer from the NSNotificationCenter. Not doing this will cause exceptions.

Throws:
Throwable

addObserver

public void addObserver(Object observer,
                        NSSelector selector,
                        String filePath)
Used to register file observers for a particular file.

Parameters:
observer - object to be notified when a file changes
selector - selector to be invoked on the observer when the file changes.
filePath - location of the file

addObserver

public void addObserver(Object observer,
                        NSSelector selector,
                        File file)
Used to register file observers for a particular file.

Parameters:
observer - object to be notified when a file changes
selector - selector to be invoked on the observer when the file changes.
file - file to watch for changes

registerLastModifiedDateForFile

public void registerLastModifiedDateForFile(File file)
Records the last modified date of the file for future comparison.

Parameters:
file - file to record the last modified date

hasFileChanged

public boolean hasFileChanged(File file)
Compares the last modified date of the file with the last recorded modification date.

Parameters:
file - file to compare last modified date.
Returns:
if the file has changed since the last time the lastModified value was recorded.

fileHasChanged

protected void fileHasChanged(File file)
Only used internally. Notifies all of the observers who have been registered for the given file.

Parameters:
file - file that has changed

checkIfFilesHaveChanged

public void checkIfFilesHaveChanged(NSNotification n)
Notified by the NSNotificationCenter at the end of every request-response loop. It is here that all of the currently watched files are checked to see if they have any changes.


Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.