Package nl.info.webdav.locking
Class ResourceLocks
java.lang.Object
nl.info.webdav.locking.ResourceLocks
- All Implemented Interfaces:
IResourceLocks
Simple locking management for concurrent data access, NOT the webdav locking.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected Hashtable<String, LockedObject> keys: path value: LockedObject from that pathprotected Hashtable<String, LockedObject> keys: id value: LockedObject from that idprotected LockedObjectprotected Hashtable<String, LockedObject> keys: path value: Temporary LockedObject from that pathprotected Hashtable<String, LockedObject> keys: id value: Temporary LockedObject from that idprotected LockedObject -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckTimeouts(ITransaction transaction, boolean temporary) Deletes LockedObjects, where timeout has reached.booleanexclusiveLock(ITransaction transaction, String path, String owner, int depth, int timeout) Tries to lock the resource at "path" exclusively.getLockedObjectByID(ITransaction transaction, String id) Gets the LockedObject corresponding to specified id.getLockedObjectByPath(ITransaction transaction, String path) Gets the locked object on specified path.getTempLockedObjectByID(ITransaction transaction, String id) Gets the LockedObject corresponding to specified id (lock token).getTempLockedObjectByPath(ITransaction transaction, String path) Gets the LockedObject on specified path.booleanlock(ITransaction transaction, String path, String owner, boolean exclusive, int depth, int timeout, boolean temporary) Tries to lock the resource at "path".booleansharedLock(ITransaction transaction, String path, String owner, int depth, int timeout) Tries to lock the resource at "path" shared.booleanunlock(ITransaction transaction, String id, String owner) Unlocks all resources at "path" (and all sub-folders if existing) that have the same owner.voidunlockTemporaryLockedObjects(ITransaction transaction, String path, String owner) Unlocks all resources at "path" (and all sub-folders if existing) that have the same owner.
-
Field Details
-
_cleanupCounter
protected int _cleanupCounter -
_locks
keys: path value: LockedObject from that path -
_locksByID
keys: id value: LockedObject from that id -
_tempLocks
keys: path value: Temporary LockedObject from that path -
_tempLocksByID
keys: id value: Temporary LockedObject from that id -
_root
-
_tempRoot
-
-
Constructor Details
-
ResourceLocks
public ResourceLocks()
-
-
Method Details
-
lock
public boolean lock(ITransaction transaction, String path, String owner, boolean exclusive, int depth, int timeout, boolean temporary) throws LockFailedException Description copied from interface:IResourceLocksTries to lock the resource at "path".- Specified by:
lockin interfaceIResourceLocks- Parameters:
transaction- the transactionpath- 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
- Throws:
LockFailedException- if the lock failed
-
unlock
Description copied from interface:IResourceLocksUnlocks all resources at "path" (and all sub-folders if existing) that have the same owner.- Specified by:
unlockin interfaceIResourceLocks- Parameters:
transaction- the transactionid- id to the resource to unlockowner- who wants to unlock
-
unlockTemporaryLockedObjects
Description copied from interface:IResourceLocksUnlocks all resources at "path" (and all sub-folders if existing) that have the same owner.- Specified by:
unlockTemporaryLockedObjectsin interfaceIResourceLocks- Parameters:
transaction- the transactionpath- what resource to unlockowner- who wants to unlock
-
checkTimeouts
Description copied from interface:IResourceLocksDeletes LockedObjects, where timeout has reached.- Specified by:
checkTimeoutsin interfaceIResourceLocks- Parameters:
transaction- the transactiontemporary- check timeout on temporary or real locks
-
exclusiveLock
public boolean exclusiveLock(ITransaction transaction, String path, String owner, int depth, int timeout) throws LockFailedException Description copied from interface:IResourceLocksTries to lock the resource at "path" exclusively.- Specified by:
exclusiveLockin interfaceIResourceLocks- Parameters:
transaction- the 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
- Throws:
LockFailedException- if the lock failed
-
getLockedObjectByID
Description copied from interface:IResourceLocksGets the LockedObject corresponding to specified id.- Specified by:
getLockedObjectByIDin interfaceIResourceLocks- Parameters:
transaction- the transactionid- lock token to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-
getLockedObjectByPath
Description copied from interface:IResourceLocksGets the locked object on specified path.- Specified by:
getLockedObjectByPathin interfaceIResourceLocks- Parameters:
transaction- the transactionpath- the path to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-
getTempLockedObjectByID
Description copied from interface:IResourceLocksGets the LockedObject corresponding to specified id (lock token).- Specified by:
getTempLockedObjectByIDin interfaceIResourceLocks- Parameters:
transaction- the transactionid- the lock token to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-
getTempLockedObjectByPath
Description copied from interface:IResourceLocksGets the LockedObject on specified path.- Specified by:
getTempLockedObjectByPathin interfaceIResourceLocks- Parameters:
transaction- the transactionpath- path to requested resource- Returns:
- LockedObject or null if no LockedObject on specified path exists
-