Class FileBasedLockStrategy

java.lang.Object
org.apache.ivy.plugins.lock.AbstractLockStrategy
org.apache.ivy.plugins.lock.FileBasedLockStrategy
All Implemented Interfaces:
LockStrategy
Direct Known Subclasses:
ArtifactLockStrategy

public abstract class FileBasedLockStrategy extends AbstractLockStrategy
  • Field Details

  • Constructor Details

    • FileBasedLockStrategy

      protected FileBasedLockStrategy()
    • FileBasedLockStrategy

      protected FileBasedLockStrategy(boolean debugLocking)
    • FileBasedLockStrategy

      protected FileBasedLockStrategy(FileBasedLockStrategy.FileLocker locker, boolean debugLocking)
  • Method Details

    • acquireLock

      protected boolean acquireLock(File file) throws InterruptedException
      Throws:
      InterruptedException
    • releaseLock

      protected void releaseLock(File file)
    • debugLocking

      private static void debugLocking(String msg)
    • hasLock

      private int hasLock(File file, Thread forThread)
      Determine the state of the lockfile. Must be called from within a synchronized block. Three possibilities exist: - The lock is held by the current thread (>0) - The lock is held by one or more different threads (-1) - The lock is not held at all (0).
      Parameters:
      file - file to lock
      forThread - thread for which lock status is being queried
    • incrementLock

      private int incrementLock(File file, Thread forThread)
      Record that this thread holds the lock. Asserts that the lock has been previously grabbed by this thread. Must be called from a synchronized block in which the lock was grabbed.
      Parameters:
      file - file which has been locked
      forThread - thread for which locking occurred
      Returns:
      number of times this thread has grabbed the lock
    • decrementLock

      private int decrementLock(File file, Thread forThread)
      Decrease depth of this thread's lock. Must be called within a synchronized block. If this returns 0, the caller is responsible for releasing the lock within that same block.
      Parameters:
      file - file for which lock depth is being decreased
      forThread - thread for which lock depth is being decreased
      Returns:
      remaining depth of this lock
    • getCurrentLockHolderNames

      protected String getCurrentLockHolderNames(File file)
      Return a string naming the threads which currently hold this lock.
      Parameters:
      file - File
      Returns:
      String