ERXFileNotificationCenter Class Reference
List of all members.
Detailed Description
The file notification center is only used in development 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.
Constructor & Destructor Documentation
Member Function Documentation
| 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 |
| 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 |
| String cacheKeyForFile |
( |
File |
file |
) |
[protected] |
Returns the path that should be used as the cache key for the given file. This will return the absolute path of the file (specifically NOT the canonical path) so that we make sure to lookup files using their original sym links rather than resolving them at registration time.
- Parameters:
-
| file | the file to lookup a cache key for |
- Returns:
- the absolute path of the file
| Object cacheValueForFile |
( |
File |
file |
) |
[protected] |
Returns the value to cache to detect changes to this file. Currently this returns the lastModified date of the canonicalized version of this file, meaning that we compare the lastModified of the target of symlinks.
- Parameters:
-
| file | the file to lookup a cache value for |
- Returns:
- a value representing the current version of this file
| static int checkFilesPeriod |
( |
|
) |
[static, private] |
In seconds. 0 means we will not regularly check files.
| 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.
- Parameters:
-
| n | NSNotification notification posted from the NSNotificationCenter. |
- Returns:
- the singleton instance of file notification center
| void fileHasChanged |
( |
File |
file |
) |
[protected] |
Only used internally. Notifies all of the observers who have been registered for the given file.
- Parameters:
-
| file | file that has changed |
| 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.
| 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.
| void registerLastModifiedDateForFile |
( |
File |
file |
) |
|
Records the last modified date of the file for future comparison.
- Parameters:
-
| file | file to record the last modified date |
Member Data Documentation
holds a reference to the default file notification center
cache for last modified dates of files by file path
collections of observers by file path
flag to tell if caching is enabled, set in the object constructor
Contains the name of the notification that is posted when a file changes.
The last time we checked files. We only check if !WOCachingEnabled or if there is a CheckFilesPeriod set
final Logger log = Logger.getLogger(ERXFileNotificationCenter.class) [static] |
The documentation for this class was generated from the following file: