Class DefaultTrackingFileManager

  • All Implemented Interfaces:
    TrackingFileManager

    @Singleton
    @Named
    public final class DefaultTrackingFileManager
    extends java.lang.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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger LOGGER  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.nio.channels.FileLock fileLock​(java.nio.channels.FileChannel channel, long size, boolean shared)  
      private java.lang.Object getMutex​(java.io.File file)  
      java.util.Properties read​(java.io.File file)
      Reads up the specified properties file into Properties, if exists, otherwise null is returned.
      java.util.Properties update​(java.io.File file, java.util.Map<java.lang.String,​java.lang.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 Detail

      • LOGGER

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

      • DefaultTrackingFileManager

        public DefaultTrackingFileManager()
    • Method Detail

      • read

        public java.util.Properties read​(java.io.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 java.util.Properties update​(java.io.File file,
                                           java.util.Map<java.lang.String,​java.lang.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
      • getMutex

        private java.lang.Object getMutex​(java.io.File file)
      • fileLock

        private java.nio.channels.FileLock fileLock​(java.nio.channels.FileChannel channel,
                                                    long size,
                                                    boolean shared)
                                             throws java.io.IOException
        Throws:
        java.io.IOException