Interface LockDAO

All Known Implementing Classes:
AbstractLockDAOImpl, LockDAOImpl

public interface LockDAO
DAO services for alf_lock and related tables
Since:
3.2
Author:
Derek Hulley
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    getLock(QName lockQName, String lockToken, long timeToLive)
    Acquire a given exclusive lock, assigning it (and any implicitly shared locks) a timeout.
    void
    refreshLock(QName lockQName, String lockToken, long timeToLive)
    Refresh a held lock.
    boolean
    releaseLock(QName lockQName, String lockToken, boolean optimistic)
    Release a lock.
  • Method Details

    • getLock

      void getLock(QName lockQName, String lockToken, long timeToLive)
      Acquire a given exclusive lock, assigning it (and any implicitly shared locks) a timeout. All shared locks are implicitly taken as well.

      A lock can be re-taken if it has expired and if the lock token has not changed

      Parameters:
      lockQName - the unique name of the lock to acquire
      lockToken - the potential lock token (max 36 chars)
      timeToLive - the time (in milliseconds) that the lock must remain
      Throws:
      LockAcquisitionException - on failure
    • refreshLock

      void refreshLock(QName lockQName, String lockToken, long timeToLive)
      Refresh a held lock. This is successful if the lock in question still exists and if the lock token has not changed. Lock expiry does not prevent the lock from being refreshed.
      Parameters:
      lockQName - the unique name of the lock to update
      lockToken - the lock token for the lock held
      timeToLive - the new time to live (in milliseconds)
      Throws:
      LockAcquisitionException - on failure
    • releaseLock

      boolean releaseLock(QName lockQName, String lockToken, boolean optimistic)
      Release a lock. The lock token must still apply and all the shared and exclusive locks need to still be present, unless the method is optimistic, in which case the unlock is considered to be a success.
      Lock expiration does not prevent this operation from succeeding.

      Note: Failure to release a lock due to a exception condition is dealt with by passing the exception out.

      Parameters:
      lockQName - the unique name of the lock to release
      lockToken - the current lock token
      optimistic - true if the release attempt is enough even if the number of released locks was incorrect.
      Returns:
      Returns true if all the required locks were (still) held under the lock token and were valid at the time of release, otherwise false
      Throws:
      LockAcquisitionException - if the number of locks released was incorrect and pessimistic release is requested.