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 void
checkTimeouts(Transaction transaction, boolean temporary)
Deletes LockedObjects, where timeout has reached.boolean
exclusiveLock(Transaction transaction, String path, String owner, int depth, int timeout)
Tries to lock the resource at "path" exclusively.int
getCleanupCounter()
LockedObject
getLockedObjectByID(Transaction transaction, String id)
Gets the LockedObject corresponding to specified id.LockedObject
getLockedObjectByPath(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 idLockedObject
getRoot()
LockedObject
getTempLockedObjectByID(Transaction transaction, String id)
Gets the LockedObject corresponding to specified id (locktoken).LockedObject
getTempLockedObjectByPath(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 idLockedObject
getTempRoot()
boolean
lock(Transaction transaction, String path, String owner, boolean exclusive, int depth, int timeout, boolean temporary)
Tries to lock the resource at "path".void
setCleanupCounter(int cleanupCounter)
boolean
sharedLock(Transaction transaction, String path, String owner, int depth, int timeout)
Tries to lock the resource at "path" shared.boolean
unlock(Transaction transaction, String id, String owner)
Unlocks all resources at "path" (and all subfolders if existing)void
unlockTemporaryLockedObjects(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:IResourceLocks
Tries to lock the resource at "path".- Specified by:
lock
in interfaceIResourceLocks
path
- 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:IResourceLocks
Unlocks all resources at "path" (and all subfolders if existing)that have the same owner.
- Specified by:
unlock
in interfaceIResourceLocks
id
- id to the resource to unlockowner
- 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 interfaceIResourceLocks
path
- what resource to unlockowner
- 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 interfaceIResourceLocks
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 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:IResourceLocks
Tries to lock the resource at "path" shared.- Specified by:
sharedLock
in 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:IResourceLocks
Gets the LockedObject corresponding to specified id.- Specified by:
getLockedObjectByID
in interfaceIResourceLocks
id
- 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:IResourceLocks
Gets the LockedObject on specified path.- Specified by:
getLockedObjectByPath
in interfaceIResourceLocks
path
- 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:IResourceLocks
Gets the LockedObject corresponding to specified id (locktoken).- Specified by:
getTempLockedObjectByID
in interfaceIResourceLocks
id
- 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:IResourceLocks
Gets the LockedObject on specified path.- Specified by:
getTempLockedObjectByPath
in interfaceIResourceLocks
path
- 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()
-
-