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>
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 Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected int
protected boolean
protected Thread
Fields inherited from class java.util.Properties
defaults
-
Constructor Summary
ConstructorsConstructorDescriptionPersistentProperties
(File file, String comments) PersistentProperties
(File file, String comments, boolean requireInitial) Creates a new PersistentProperties object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
getFile()
int
Returns the maximum rate at which the file will be written.boolean
isNew()
keySet()
protected void
removeIntermediate
(Object key) void
setMaxStorageFrequencyMS
(int maxStorageFrequencyMS) Sets the maximum rate at which the file will be written.setProperty
(String key, String value) setPropertyIntermediate
(String key, String value) Sets a property without pesisting the change.void
Do the following to ensure there is always a well-formed file on the HD Write file to temp file Copy temp file to main fileprotected void
Tries to call super.loadFromXML with an input stream from this file.Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, replace, replace, replaceAll, save, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Field Details
-
_savePaused
protected transient boolean _savePaused -
maxStorageFrequencyMS
protected int maxStorageFrequencyMS -
writeThread
-
writeQueued
protected transient boolean writeQueued
-
-
Constructor Details
-
PersistentProperties
- Throws:
IOException
-
PersistentProperties
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
-
getTempFile
-
tryLoad
Tries to call super.loadFromXML with an input stream from this file.- Throws:
IOException
- if anything goes wrong with the load.
-
removeIntermediate
-
remove
-
setProperty
- Overrides:
setProperty
in classProperties
-
setPropertyIntermediate
Sets a property without pesisting the change. -
keySet
-
storeChanges
public void storeChanges()Do the following to ensure there is always a well-formed file on the HD- Write file to temp file
- Copy temp file to main file
-
potentiallyExecuteWrite
protected void potentiallyExecuteWrite() -
copyFile
- Throws:
IOException
-