Class FilesSupport.PathHolder

  • All Implemented Interfaces:
    java.lang.AutoCloseable
    Enclosing class:
    FilesSupport

    private static class FilesSupport.PathHolder
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Support class to open or lock a file for file operation impact assessment.

    Although this class has "support" for opening a directory, there appears to be no reliable means in Java of opening a directory and observing the impact on other file operations.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.Phaser barrier  
      private static org.slf4j.Logger LOGGER  
      private java.util.concurrent.atomic.AtomicBoolean started  
      private java.lang.Thread thread  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PathHolder​(java.nio.file.Path path, boolean lock)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes and unlocks the file.
      private void holdDirectory​(java.nio.file.Path dir)  
      private void holdFile​(java.nio.file.Path file)
      Holds open a file for read.
      private void lockFile​(java.nio.file.Path file)
      Holds a lock on a file.
      void start()
      Open or lock the file and return.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • thread

        private final java.lang.Thread thread
      • barrier

        private final java.util.concurrent.Phaser barrier
      • started

        private final java.util.concurrent.atomic.AtomicBoolean started
    • Constructor Detail

      • PathHolder

        private PathHolder​(java.nio.file.Path path,
                           boolean lock)
                    throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • holdFile

        private void holdFile​(java.nio.file.Path file)
        Holds open a file for read.
        Parameters:
        file - the file path to hold open
      • lockFile

        private void lockFile​(java.nio.file.Path file)
        Holds a lock on a file.
        Parameters:
        file - the file path to lock
      • holdDirectory

        private void holdDirectory​(java.nio.file.Path dir)
      • start

        public void start()
        Open or lock the file and return. The file remains opened or locked until close() is called.
      • close

        public void close()
        Closes and unlocks the file.
        Specified by:
        close in interface java.lang.AutoCloseable