Class ResourceLocks

  • All Implemented Interfaces:
    IResourceLocks

    public class ResourceLocks
    extends Object
    implements IResourceLocks
    simple locking management for concurrent data access, NOT the webdav locking. ( could that be used instead? )

    IT IS ACTUALLY USED FOR DOLOCK

    Author:
    re
    • Constructor Detail

      • ResourceLocks

        public ResourceLocks()
    • Method Detail

      • lock

        public boolean lock​(Transaction transaction,
                            String path,
                            String owner,
                            boolean exclusive,
                            int depth,
                            int timeout,
                            boolean temporary)
        Description copied from interface: IResourceLocks
        Tries to lock the resource at "path".
        Specified by:
        lock in interface IResourceLocks
        path - what resource to lock
        owner - the owner of the lock
        exclusive - if the lock should be exclusive (or shared)
        depth - depth
        timeout - Lock Duration in seconds.
        Returns:
        true if the resource at path was successfully locked, false if an existing lock prevented this
      • unlock

        public boolean unlock​(Transaction transaction,
                              String id,
                              String owner)
        Description copied from interface: IResourceLocks
        Unlocks all resources at "path" (and all subfolders if existing)

        that have the same owner.

        Specified by:
        unlock in interface IResourceLocks
        id - id to the resource to unlock
        owner - who wants to unlock
      • unlockTemporaryLockedObjects

        public void unlockTemporaryLockedObjects​(Transaction transaction,
                                                 String path,
                                                 String owner)
        Description copied from interface: IResourceLocks
        Unlocks all resources at "path" (and all subfolders if existing)

        that have the same owner.

        Specified by:
        unlockTemporaryLockedObjects in interface IResourceLocks
        path - what resource to unlock
        owner - who wants to unlock
      • checkTimeouts

        public void checkTimeouts​(Transaction transaction,
                                  boolean temporary)
        Description copied from interface: IResourceLocks
        Deletes LockedObjects, where timeout has reached.
        Specified by:
        checkTimeouts in interface IResourceLocks
        temporary - Check timeout on temporary or real locks
      • exclusiveLock

        public boolean exclusiveLock​(Transaction transaction,
                                     String path,
                                     String owner,
                                     int depth,
                                     int timeout)
        Description copied from interface: IResourceLocks
        Tries to lock the resource at "path" exclusively.
        Specified by:
        exclusiveLock in interface IResourceLocks
        Parameters:
        transaction - Transaction
        path - what resource to lock
        owner - the owner of the lock
        depth - depth
        timeout - Lock Duration in seconds.
        Returns:
        true if the resource at path was successfully locked, false if an existing lock prevented this
      • sharedLock

        public boolean sharedLock​(Transaction transaction,
                                  String path,
                                  String owner,
                                  int depth,
                                  int timeout)
        Description copied from interface: IResourceLocks
        Tries to lock the resource at "path" shared.
        Specified by:
        sharedLock in interface IResourceLocks
        Parameters:
        transaction - Transaction
        path - what resource to lock
        owner - the owner of the lock
        depth - depth
        timeout - Lock Duration in seconds.
        Returns:
        true if the resource at path was successfully locked, false if an existing lock prevented this
      • getTempLocks

        public Map<String,​LockedObject> getTempLocks()
        keys: path value: Temporary LockedObject from that path
      • getTempLocksByID

        public Map<String,​LockedObject> getTempLocksByID()
        keys: id value: Temporary LockedObject from that id
      • getLocksByID

        public Map<String,​LockedObject> getLocksByID()
        keys: id value: LockedObject from that id
      • getCleanupCounter

        public int getCleanupCounter()
      • setCleanupCounter

        public void setCleanupCounter​(int cleanupCounter)