Class LockingReaderWriter

java.lang.Object
net.adoptopenjdk.icedteaweb.lockingfile.LockingReaderWriter
Direct Known Subclasses:
UnsignedAppletActionStorageImpl

public abstract class LockingReaderWriter extends Object
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 Details

  • Constructor Details

    • LockingReaderWriter

      public LockingReaderWriter(File file)
      Create locking file-backed storage.
      Parameters:
      file - the storage file
  • Method Details

    • getBackingFile

      public File 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

      protected void writeContents() throws IOException
      Writes stored contents to file. Assumes lock is held.
      Throws:
      IOException
    • readContents

      protected void readContents() throws IOException
      Reads contents from file. Assumes lock is held.
      Throws:
      IOException
    • writeContentsLocked

      protected void writeContentsLocked() throws IOException
      Write contents to the file, first acquiring a lock.
      Throws:
      IOException
    • doLocked

      protected void doLocked(Runnable r)
    • writeContent

      protected abstract void writeContent(BufferedWriter writer) throws IOException
      Throws:
      IOException
    • readLine

      protected abstract void readLine(String line)