Package org.eclipse.aether.internal.impl
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static PathcanonicalPath(Path path) Tries the best it can to figure out actual file the workload is about, while resolving cases like symlinked local repository etc.booleanDeletes the specified properties file, if exists.private FileLockfileLock(FileChannel channel, boolean shared) private static ObjectThis 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.Reads up the specified properties file intoProperties, if exists, otherwisenullis returned.Applies updates to specified properties file and returns resultingPropertieswith contents same as in updated file, nevernull.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
-
Constructor Details
-
DefaultTrackingFileManager
public DefaultTrackingFileManager()
-
-
Method Details
-
read
Description copied from interface:TrackingFileManagerReads up the specified properties file intoProperties, if exists, otherwisenullis returned.- Specified by:
readin interfaceTrackingFileManager
-
update
Description copied from interface:TrackingFileManagerApplies updates to specified properties file and returns resultingPropertieswith contents same as in updated file, nevernull.- Specified by:
updatein interfaceTrackingFileManager
-
delete
Description copied from interface:TrackingFileManagerDeletes the specified properties file, if exists. If file existed and was deleted, returnstrue.- Specified by:
deletein interfaceTrackingFileManager
-
mutex
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
Tries the best it can to figure out actual file the workload is about, while resolving cases like symlinked local repository etc. -
fileLock
- Throws:
IOException
-