Class LockingReaderWriter
java.lang.Object
net.adoptopenjdk.icedteaweb.lockingfile.LockingReaderWriter
- Direct Known Subclasses:
UnsignedAppletActionStorageImpl
Process-locked string storage backed by a file.
Each string is stored on its own line.
Any new-lines must be encoded somehow if they are to be stored.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidGet the underlying file.booleanvoidlock()Lock the underlying storage.protected voidReads contents from file.protected abstract voidvoidunlock()Unlock the underlying storage.protected abstract voidwriteContent(BufferedWriter writer) protected voidWrites stored contents to file.protected voidWrite contents to the file, first acquiring a lock.
-
Field Details
-
lockableFile
-
-
Constructor Details
-
LockingReaderWriter
Create locking file-backed storage.- Parameters:
file- the storage file
-
-
Method Details
-
getBackingFile
Get the underlying file. Any access to this file should use lock() and unlock().- Returns:
- the file
-
isReadOnly
public boolean isReadOnly() -
lock
public void lock()Lock the underlying storage. Lock is reentrant. -
unlock
public void unlock()Unlock the underlying storage. Lock is reentrant. -
writeContents
Writes stored contents to file. Assumes lock is held.- Throws:
IOException
-
readContents
Reads contents from file. Assumes lock is held.- Throws:
IOException
-
writeContentsLocked
Write contents to the file, first acquiring a lock.- Throws:
IOException
-
doLocked
-
writeContent
- Throws:
IOException
-
readLine
-