Class PersistentProperties

java.lang.Object
java.util.Dictionary<K,V>
java.util.Hashtable<Object,Object>
java.util.Properties
com.inductiveautomation.ignition.common.PersistentProperties
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class PersistentProperties extends Properties
A simple extension of properties that is meant to represent a file based property file. The entire property file will be written eventually after a call to setProperty(), according to the max storage frequency.
See Also:
  • Field Details

    • _savePaused

      protected transient boolean _savePaused
    • maxStorageFrequencyMS

      protected int maxStorageFrequencyMS
    • writeThread

      protected transient Thread writeThread
    • writeQueued

      protected transient boolean writeQueued
  • Constructor Details

    • PersistentProperties

      public PersistentProperties(File file, String comments) throws IOException
      Throws:
      IOException
    • PersistentProperties

      public PersistentProperties(File file, String comments, boolean requireInitial) throws IOException
      Creates a new PersistentProperties object. The backup file will be "."+filename+".bak" and the clean file will be filename+"_clean".
      Parameters:
      requireInitial - Whether or not a valid file or _clean file is required. If false, the constructor will accept the situation where none of the 3 files exist.
      Throws:
      IOException
    • PersistentProperties

      public PersistentProperties()
  • Method Details

    • getMaxStorageFrequencyMS

      public int getMaxStorageFrequencyMS()
      Returns the maximum rate at which the file will be written. After a property is set, the file is written immediately, unless the specified time has not passed, in which case the file will be marked as "dirty" and written when the delay expires.

      Defaults to 500ms.

    • setMaxStorageFrequencyMS

      public void setMaxStorageFrequencyMS(int maxStorageFrequencyMS)
      Sets the maximum rate at which the file will be written. If 0, writes will occur immediately, and in the same thread, instead of asynchronously.
    • isNew

      public boolean isNew()
    • getFile

      public File getFile()
    • getTempFile

      public File getTempFile()
    • tryLoad

      protected void tryLoad(File file) throws IOException
      Tries to call super.loadFromXML with an input stream from this file.
      Throws:
      IOException - if anything goes wrong with the load.
    • removeIntermediate

      public Object removeIntermediate(Object key)
    • remove

      public Object remove(Object key)
      Specified by:
      remove in interface Map<Object,Object>
      Overrides:
      remove in class Properties
    • setProperty

      public Object setProperty(String key, String value)
      Overrides:
      setProperty in class Properties
    • setPropertyIntermediate

      public Object setPropertyIntermediate(String key, String value)
      Sets a property without pesisting the change.
    • keySet

      public Set<Object> keySet()
      Specified by:
      keySet in interface Map<Object,Object>
      Overrides:
      keySet in class Properties
    • storeChanges

      public void storeChanges()
      Do the following to ensure there is always a well-formed file on the HD
      1. Write file to temp file
      2. Copy temp file to main file
    • potentiallyExecuteWrite

      protected void potentiallyExecuteWrite()
    • copyFile

      protected void copyFile(File source, File dest) throws IOException
      Throws:
      IOException