src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java

Print this page




  62       The flush timer is scheduled to fire some time after each pref change,
  63       unless it's already scheduled to fire before that. syncWorld and
  64       flushWorld will cancel any outstanding flush timer as unnecessary.
  65       The flush timer flushes all changed files (the changedFiles list).
  66     The time between pref write and flush timer call is controlled by the
  67       java.util.prefs.flushDelay property (unlike FileSystemPreferences).
  68       The default is 60 seconds and the minimum is 5 seconds.
  69 
  70   The flush timer's behavior is required by the Java Preferences spec
  71   ("changes will eventually propagate to the persistent backing store with
  72   an implementation-dependent delay"). The sync timer is not required by
  73   the spec (multiple VMs are only required to not corrupt the prefs), but
  74   the periodic sync is implemented by FileSystemPreferences and may be
  75   useful to some programs. The sync timer is disabled by default because
  76   it's expensive and is usually not necessary.
  77 */
  78 
  79 class MacOSXPreferencesFile {
  80 
  81     static {
  82         java.security.AccessController.doPrivileged(new sun.security.action.LoadLibraryAction("osx"));




  83     }


  84 
  85     private class FlushTask extends TimerTask {
  86         public void run() {
  87             MacOSXPreferencesFile.flushWorld();
  88         }
  89     }
  90 
  91     private class SyncTask extends TimerTask {
  92         public void run() {
  93             MacOSXPreferencesFile.syncWorld();
  94         }
  95     }
  96 
  97     // Maps string -> weak reference to MacOSXPreferencesFile
  98     private static HashMap cachedFiles = null;
  99     // Files that may have unflushed changes
 100     private static HashSet changedFiles = null;
 101 
 102 
 103     // Timer and pending sync and flush tasks (which are both scheduled




  62       The flush timer is scheduled to fire some time after each pref change,
  63       unless it's already scheduled to fire before that. syncWorld and
  64       flushWorld will cancel any outstanding flush timer as unnecessary.
  65       The flush timer flushes all changed files (the changedFiles list).
  66     The time between pref write and flush timer call is controlled by the
  67       java.util.prefs.flushDelay property (unlike FileSystemPreferences).
  68       The default is 60 seconds and the minimum is 5 seconds.
  69 
  70   The flush timer's behavior is required by the Java Preferences spec
  71   ("changes will eventually propagate to the persistent backing store with
  72   an implementation-dependent delay"). The sync timer is not required by
  73   the spec (multiple VMs are only required to not corrupt the prefs), but
  74   the periodic sync is implemented by FileSystemPreferences and may be
  75   useful to some programs. The sync timer is disabled by default because
  76   it's expensive and is usually not necessary.
  77 */
  78 
  79 class MacOSXPreferencesFile {
  80 
  81     static {
  82         java.security.AccessController.doPrivileged(
  83             new java.security.PrivilegedAction<Void>() {
  84                 public Void run() {
  85                     System.loadLibrary("osx");
  86                     return null;
  87                 }
  88             });
  89     }
  90 
  91     private class FlushTask extends TimerTask {
  92         public void run() {
  93             MacOSXPreferencesFile.flushWorld();
  94         }
  95     }
  96 
  97     private class SyncTask extends TimerTask {
  98         public void run() {
  99             MacOSXPreferencesFile.syncWorld();
 100         }
 101     }
 102 
 103     // Maps string -> weak reference to MacOSXPreferencesFile
 104     private static HashMap cachedFiles = null;
 105     // Files that may have unflushed changes
 106     private static HashSet changedFiles = null;
 107 
 108 
 109     // Timer and pending sync and flush tasks (which are both scheduled