Class FileLockManager

java.lang.Object
com.tridion.concurrent.FileLockManager

public final class FileLockManager extends Object
The FileLockManager is a single point of access to lock files for reading, writing and removing.

Make sure all concurrent file access is done through locking otherwise the prevention of concurrent access is bypassed.

Only works with a single JVM since this is a singleton.

  • Field Details

    • DEFAULT_WAITING_TIME_MINUTES

      public static final int DEFAULT_WAITING_TIME_MINUTES
      See Also:
  • Method Details

    • getInstance

      public static FileLockManager getInstance()
    • lock

      public final long lock(File object)
      Lock's the object for any usage through this LockManager and returns the 'lock-cookie' to unlock it with.

      CAUTION: Always unlock in the finally block to prevent starvation.

      Parameters:
      object - The object to lock.
      Returns:
      the object's lock 'cookie'.
    • unlock

      public final void unlock(File object, long lockCookie)
      Unlocks the object for usage through this LockManager.
      Parameters:
      object - The object to unlock.
      lockCookie - The cookie to unlock it with.
      Throws:
      SecurityException - on an invalid lock cookie.