public class AutoSaveListener extends FileHandlerListenerAdapter implements EventListener<ConfigurationEvent>
| Modifier and Type | Field and Description |
|---|---|
protected PropertiesFileConfiguration |
conf
The configuration of which to save the contents when changed.
|
protected int |
failedSaves
The amount of consecutive failures when saving the file.
|
protected int |
failedSavesWarning
The amount of failed saves leading to a warning in the log.
|
protected java.util.concurrent.locks.ReadWriteLock |
fileLock
The lock to synchronise file access.
|
protected java.util.logging.Logger |
logger
The logger to which to log problems occurring when saving the configuration.
|
protected java.nio.file.Path |
path
The path to the configuration file,
null in case of a URL. |
| Modifier | Constructor and Description |
|---|---|
protected |
AutoSaveListener(PropertiesFileConfiguration conf,
FileHandler fileHandler,
java.util.logging.Logger logger)
Creates a new listener automatically saving a properties configuration to the corresponding
file when changing the configuration.
|
protected |
AutoSaveListener(PropertiesFileConfiguration conf,
FileHandler fileHandler,
java.nio.file.Path path,
java.util.logging.Logger logger)
Creates a new listener automatically saving a properties configuration to the corresponding
file when changing the configuration.
|
| Modifier and Type | Method and Description |
|---|---|
void |
loaded(FileHandler handler) |
void |
loading(FileHandler handler) |
void |
onEvent(ConfigurationEvent event) |
protected void |
resetCount()
Resets the failure and the warning limit count.
|
locationChanged, saved, savingprotected final PropertiesFileConfiguration conf
protected final java.nio.file.Path path
null in case of a URL.protected final java.util.logging.Logger logger
protected final java.util.concurrent.locks.ReadWriteLock fileLock
protected int failedSaves
protected int failedSavesWarning
protected AutoSaveListener(PropertiesFileConfiguration conf, FileHandler fileHandler, java.util.logging.Logger logger)
conf - The properties configuration of which to save all changes.fileHandler - The handler for the configuration file.logger - The logger to log failed saves.protected AutoSaveListener(PropertiesFileConfiguration conf, FileHandler fileHandler, java.nio.file.Path path, java.util.logging.Logger logger)
conf - The properties configuration of which to save all changes.fileHandler - The handler for the configuration file.path - The path to the configuration file. This will be used to create the file and its
parent directories if required. If this is null, the file has to exist
and must be writable.logger - The logger to log failed saves.public void onEvent(ConfigurationEvent event)
onEvent in interface EventListener<ConfigurationEvent>public void loading(FileHandler handler)
loading in interface FileHandlerListenerloading in class FileHandlerListenerAdapterpublic void loaded(FileHandler handler)
loaded in interface FileHandlerListenerloaded in class FileHandlerListenerAdapterprotected void resetCount()