Class DefaultTrackingFileManager

java.lang.Object
org.eclipse.aether.internal.impl.DefaultTrackingFileManager
All Implemented Interfaces:
TrackingFileManager

@Singleton @Named public final class DefaultTrackingFileManager extends Object implements TrackingFileManager
Manages access to a properties file.

Note: the file locking in this component (that predates SyncContext) is present only to back off two parallel implementations that coexist in Maven (this class and maven-compat one), as in certain cases the two implementations may collide on properties files. This locking must remain in place for as long as maven-compat code exists. IMPORTANT: This class is kept fully in sync with the master branch one (w/ simple change to convert File to Path instances).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static Path
    Tries the best it can to figure out actual file the workload is about, while resolving cases like symlinked local repository etc.
    boolean
    delete(File file)
    Deletes the specified properties file, if exists.
    private FileLock
    fileLock(FileChannel channel, boolean shared)
     
    private static Object
    mutex(Path path)
    This method creates a "mutex" object to synchronize on thread level, within same JVM, to prevent multiple threads from trying to lock the same file at the same time.
    read(File file)
    Reads up the specified properties file into Properties, if exists, otherwise null is returned.
    update(File file, Map<String,String> updates)
    Applies updates to specified properties file and returns resulting Properties with contents same as in updated file, never null.

    Methods inherited from class java.lang.Object

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

    • LOGGER

      private static final org.slf4j.Logger LOGGER
  • Constructor Details

    • DefaultTrackingFileManager

      public DefaultTrackingFileManager()
  • Method Details

    • read

      public Properties read(File file)
      Description copied from interface: TrackingFileManager
      Reads up the specified properties file into Properties, if exists, otherwise null is returned.
      Specified by:
      read in interface TrackingFileManager
    • update

      public Properties update(File file, Map<String,String> updates)
      Description copied from interface: TrackingFileManager
      Applies updates to specified properties file and returns resulting Properties with contents same as in updated file, never null.
      Specified by:
      update in interface TrackingFileManager
    • delete

      public boolean delete(File file)
      Description copied from interface: TrackingFileManager
      Deletes the specified properties file, if exists. If file existed and was deleted, returns true.
      Specified by:
      delete in interface TrackingFileManager
    • mutex

      private static Object mutex(Path path)
      This method creates a "mutex" object to synchronize on thread level, within same JVM, to prevent multiple threads from trying to lock the same file at the same time. Threads concurrently working on different files are okay, as after syncing on mutex, they operate with FS locking, that goal is to synchronize with possible other Maven processes, and not with other threads in this JVM.
    • canonicalPath

      private static Path canonicalPath(Path path)
      Tries the best it can to figure out actual file the workload is about, while resolving cases like symlinked local repository etc.
    • fileLock

      private FileLock fileLock(FileChannel channel, boolean shared) throws IOException
      Throws:
      IOException