Package org.drjekyll.webdav.locking
Class ResourceLocks
- java.lang.Object
-
- org.drjekyll.webdav.locking.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 Summary
Constructors Constructor Description ResourceLocks()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckTimeouts(Transaction transaction, boolean temporary)Deletes LockedObjects, where timeout has reached.booleanexclusiveLock(Transaction transaction, String path, String owner, int depth, int timeout)Tries to lock the resource at "path" exclusively.intgetCleanupCounter()LockedObjectgetLockedObjectByID(Transaction transaction, String id)Gets the LockedObject corresponding to specified id.LockedObjectgetLockedObjectByPath(Transaction transaction, String path)Gets the LockedObject on specified path.Map<String,LockedObject>getLocks()keys: path value: LockedObject from that pathMap<String,LockedObject>getLocksByID()keys: id value: LockedObject from that idLockedObjectgetRoot()LockedObjectgetTempLockedObjectByID(Transaction transaction, String id)Gets the LockedObject corresponding to specified id (locktoken).LockedObjectgetTempLockedObjectByPath(Transaction transaction, String path)Gets the LockedObject on specified path.Map<String,LockedObject>getTempLocks()keys: path value: Temporary LockedObject from that pathMap<String,LockedObject>getTempLocksByID()keys: id value: Temporary LockedObject from that idLockedObjectgetTempRoot()booleanlock(Transaction transaction, String path, String owner, boolean exclusive, int depth, int timeout, boolean temporary)Tries to lock the resource at "path".voidsetCleanupCounter(int cleanupCounter)booleansharedLock(Transaction transaction, String path, String owner, int depth, int timeout)Tries to lock the resource at "path" shared.booleanunlock(Transaction transaction, String id, String owner)Unlocks all resources at "path" (and all subfolders if existing)voidunlockTemporaryLockedObjects(Transaction transaction, String path, String owner)Unlocks all resources at "path" (and all subfolders if existing)
-
-
-
Method Detail
-
lock
public boolean lock(Transaction transaction, String path, String owner, boolean exclusive, int depth, int timeout, boolean temporary)
Description copied from interface:IResourceLocksTries to lock the resource at "path".- Specified by:
lockin interfaceIResourceLockspath- what resource to lockowner- the owner of the lockexclusive- if the lock should be exclusive (or shared)depth- depthtimeout- 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:IResourceLocksUnlocks all resources at "path" (and all subfolders if existing)that have the same owner.
- Specified by:
unlockin interfaceIResourceLocksid- id to the resource to unlockowner- who wants to unlock
-
unlockTemporaryLockedObjects
public void unlockTemporaryLockedObjects(Transaction transaction, String path, String owner)
Description copied from interface:IResourceLocksUnlocks all resources at "path" (and all subfolders if existing)that have the same owner.
- Specified by:
unlockTemporaryLockedObjectsin interfaceIResourceLockspath- what resource to unlockowner- who wants to unlock
-
checkTimeouts
public void checkTimeouts(Transaction transaction, boolean temporary)
Description copied from interface:IResourceLocksDeletes LockedObjects, where timeout has reached.- Specified by:
checkTimeoutsin interfaceIResourceLockstemporary- 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:IResourceLocksTries to lock the resource at "path" exclusively.- Specified by:
exclusiveLockin interfaceIResourceLocks- Parameters:
transaction- Transactionpath- what resource to lockowner- the owner of the lockdepth- depthtimeout- 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:IResourceLocksTries to lock the resource at "path" shared.- Specified by:
sharedLockin interfaceIResourceLocks- Parameters:
transaction- Transactionpath- what resource to lockowner- the owner of the lockdepth- depthtimeout- Lock Duration in seconds.- Returns:
- true if the resource at path was successfully locked, false if an existing lock prevented this
-
getLockedObjectByID
@Nullable public LockedObject getLockedObjectByID(Transaction transaction, String id)
Description copied from interface:IResourceLocksGets the LockedObject corresponding to specified id.- Specified by:
getLockedObjectByIDin interfaceIResourceLocksid- LockToken to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-
getLockedObjectByPath
@Nullable public LockedObject getLockedObjectByPath(Transaction transaction, String path)
Description copied from interface:IResourceLocksGets the LockedObject on specified path.- Specified by:
getLockedObjectByPathin interfaceIResourceLockspath- Path to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-
getTempLockedObjectByID
@Nullable public LockedObject getTempLockedObjectByID(Transaction transaction, String id)
Description copied from interface:IResourceLocksGets the LockedObject corresponding to specified id (locktoken).- Specified by:
getTempLockedObjectByIDin interfaceIResourceLocksid- LockToken to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-
getTempLockedObjectByPath
@Nullable public LockedObject getTempLockedObjectByPath(Transaction transaction, String path)
Description copied from interface:IResourceLocksGets the LockedObject on specified path.- Specified by:
getTempLockedObjectByPathin interfaceIResourceLockspath- Path to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-
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
-
getLocks
public Map<String,LockedObject> getLocks()
keys: path value: LockedObject from that path
-
getLocksByID
public Map<String,LockedObject> getLocksByID()
keys: id value: LockedObject from that id
-
getCleanupCounter
public int getCleanupCounter()
-
setCleanupCounter
public void setCleanupCounter(int cleanupCounter)
-
getRoot
public LockedObject getRoot()
-
getTempRoot
public LockedObject getTempRoot()
-
-