Class DefaultActiveLock

  • All Implemented Interfaces:
    DavConstants, ActiveLock, XmlSerializable
    Direct Known Subclasses:
    TxActiveLock

    public class DefaultActiveLock
    extends AbstractActiveLock
    DefaultActiveLock implements the ActiveLock interface and represents an exclusive write lock with a random uuid lock token. Lock owner, timeout and depth is retrieved from the LockInfo object passed in the constructor. If the lockinfo is null, the following default values are set:
     - timeout is set to infinity.
     - isDeep is set to true.
     
    • Constructor Detail

      • DefaultActiveLock

        public DefaultActiveLock()
        Create a new DefaultActiveLock with default values.
      • DefaultActiveLock

        public DefaultActiveLock​(LockInfo lockInfo)
        Create a new lock
        Parameters:
        lockInfo -
        Throws:
        java.lang.IllegalArgumentException - if either scope or type is invalid.
    • Method Detail

      • isLockedByToken

        public boolean isLockedByToken​(java.lang.String lockToken)
        Description copied from interface: ActiveLock
        Return true, if the given token matches the lock token present in this lock thus indicating that any lock relevant operation should not fail due to a lock.
        Parameters:
        lockToken - to be checked
        Returns:
        true if the given lock token matches.
        See Also:
        ActiveLock.isLockedByToken(String)
      • isExpired

        public boolean isExpired()
        Description copied from interface: ActiveLock
        Returns true, if this lock is already expired.
        Returns:
        true if the lock is expired
        See Also:
        ActiveLock.isExpired()
      • getToken

        public java.lang.String getToken()
        Description copied from interface: ActiveLock
        Return the lock token.
        Returns:
        token string representing the lock token.
        See Also:
        ActiveLock.getToken()
      • getOwner

        public java.lang.String getOwner()
        Description copied from interface: ActiveLock
        Return the name (or id) of the lock owner.
        Returns:
        name (or id) of the lock owner.
        See Also:
        ActiveLock.getOwner()
      • setOwner

        public void setOwner​(java.lang.String owner)
        Description copied from interface: ActiveLock
        Set the name (or id) of the lock owner
        See Also:
        ActiveLock.setOwner(String)
      • getTimeout

        public long getTimeout()
        Description copied from interface: ActiveLock
        Return the number of milliseconds the lock will live until it is expired or -1 if the timeout is not available (or the client is not allowed to retrieve it).
        Returns:
        number of milliseconds.
        See Also:
        ActiveLock.getTimeout()
      • setTimeout

        public void setTimeout​(long timeout)
        Description copied from interface: ActiveLock
        Defines the number of milliseconds until the timeout is reached.
        See Also:
        ActiveLock.setTimeout(long)
      • isDeep

        public boolean isDeep()
        Description copied from interface: ActiveLock
        Return true if the lock is deep.
        Returns:
        true if the lock is deep.
        See Also:
        ActiveLock.isDeep()
      • getType

        public Type getType()
        This is always a write lock.
        Returns:
        the lock type
        See Also:
        Type.WRITE
      • getScope

        public Scope getScope()
        This is always an exclusive lock.
        Returns:
        the lock scope.
        See Also:
        Scope.EXCLUSIVE