public class ERXFileNotificationCenter extends Object
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.
Modifier and Type | Class and Description |
---|---|
static class |
ERXFileNotificationCenter._ObserverSelectorHolder
Simple observer-selector holder class.
|
Modifier and Type | Field and Description |
---|---|
static String |
FileDidChange
Contains the name of the notification that is posted when a file changes.
|
Constructor and Description |
---|
ERXFileNotificationCenter()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected String |
cacheKeyForFile(File file)
Returns the path that should be used as the cache key for the given file.
|
protected Object |
cacheValueForFile(File file)
Returns the value to cache to detect changes to this 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.
|
public static final String FileDidChange
public ERXFileNotificationCenter()
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.public static ERXFileNotificationCenter defaultCenter()
public void finalize() throws Throwable
NSNotificationCenter
.
Not doing this will cause exceptions.public void addObserver(Object observer, NSSelector selector, String filePath)
observer
- object to be notified when a file changesselector
- selector to be invoked on the observer when
the file changes.filePath
- location of the filepublic void addObserver(Object observer, NSSelector selector, File file)
observer
- object to be notified when a file changesselector
- selector to be invoked on the observer when
the file changes.file
- file to watch for changesprotected String cacheKeyForFile(File file)
file
- the file to lookup a cache key forprotected Object cacheValueForFile(File file)
file
- the file to lookup a cache value forpublic void registerLastModifiedDateForFile(File file)
file
- file to record the last modified datepublic boolean hasFileChanged(File file)
file
- file to compare last modified date.lastModified
value
was recorded.protected void fileHasChanged(File file)
file
- file that has changedpublic void checkIfFilesHaveChanged(NSNotification n)
n
- NSNotification notification posted from the NSNotificationCenter.Copyright © 2002 – 2024 Project Wonder.