| org.apache.commons.transaction.locking.LockManager2
All known Subclasses: org.apache.commons.transaction.locking.GenericLockManager,
LockManager2 | public interface LockManager2 (Code) | | Extended version of a lock manager that also has global knowledge or all locks and should be
used as a delegate for all locking requests. This allows for things like deadlock detection.
version: $Id: LockManager2.java 493628 2007-01-07 01:42:48Z joerg $ See Also: MultiLevelLock See Also: MultiLevelLock2 See Also: LockManager See Also: GenericLockManager See Also: GenericLock since: 1.1 |
Method Summary | |
public boolean | checkLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) Determines if a lock could be acquire without actually acquiring it. | public Set | getAll(Object ownerId) Gets all locks (partially) held by an owner. | public int | getLevel(Object ownerId, Object resourceId) Gets the lock level held by certain owner on a certain resource. | public MultiLevelLock | getLock(Object resourceId) Gets an existing lock on the specified resource. | public boolean | hasLock(Object ownerId, Object resourceId, int lockLevel) Determines if a lock is owner by an owner. | public void | lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) Tries to acquire a lock on a resource. | public void | lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant, long timeoutMSecs) Tries to acquire a lock on a resource. | public void | lock(Object ownerId, Object resourceId, int targetLockLevel, int compatibility, boolean preferred, long timeoutMSecs) Most flexible way to acquire a lock on a resource. | public boolean | release(Object ownerId, Object resourceId) Releases all locks for a certain resource held by a certain owner. | public void | releaseAll(Object ownerId) Releases all locks (partially) held by an owner. | public void | removeLock(MultiLevelLock lock) Removes the specified lock from the associated resource. | public void | startGlobalTimeout(Object ownerId, long timeoutMSecs) Starts a global timeout for an owner. | public boolean | tryLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) Tries to acquire a lock on a resource. |
checkLock | public boolean checkLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant)(Code) | | Determines if a lock could be acquire without actually acquiring it.
This method does not block, but immediatly returns.
Parameters: ownerId - a unique id identifying the entity that wants to check thislock Parameters: resourceId - the resource to get the level for Parameters: targetLockLevel - the lock level to check Parameters: reentrant - true if this request shall not be influenced byother locks held by the same owner true if the lock could be acquired, false otherwise |
getAll | public Set getAll(Object ownerId)(Code) | | Gets all locks (partially) held by an owner.
Parameters: ownerId - the id of the owner all locks held by ownerId |
getLevel | public int getLevel(Object ownerId, Object resourceId)(Code) | | Gets the lock level held by certain owner on a certain resource.
Parameters: ownerId - the id of the owner of the lock Parameters: resourceId - the resource to get the level for |
getLock | public MultiLevelLock getLock(Object resourceId)(Code) | | Gets an existing lock on the specified resource. If none exists it returns null .
Parameters: resourceId - the resource to get the lock for the lock on the specified resource |
hasLock | public boolean hasLock(Object ownerId, Object resourceId, int lockLevel)(Code) | | Determines if a lock is owner by an owner.
Parameters: ownerId - a unique id identifying the entity that wants to check thislock Parameters: resourceId - the resource to get the level for Parameters: lockLevel - the lock level to check true if the owner has the lock, false otherwise |
lock | public void lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) throws LockException(Code) | | Tries to acquire a lock on a resource.
This method blocks and waits for the lock in case it is not avaiable. If
there is a timeout or a deadlock or the thread is interrupted a
LockException is thrown.
Parameters: ownerId - a unique id identifying the entity that wants to acquire thislock Parameters: resourceId - the resource to get the level for Parameters: targetLockLevel - the lock level to acquire Parameters: reentrant - true if this request shall not be blocked byother locks held by the same owner throws: LockException - will be thrown when the lock can not be acquired |
lock | public void lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant, long timeoutMSecs) throws LockException(Code) | | Tries to acquire a lock on a resource.
This method blocks and waits for the lock in case it is not avaiable. If
there is a timeout or a deadlock or the thread is interrupted a
LockException is thrown.
Parameters: ownerId - a unique id identifying the entity that wants to acquire thislock Parameters: resourceId - the resource to get the level for Parameters: targetLockLevel - the lock level to acquire Parameters: reentrant - true if this request shall not be blocked byother locks held by the same owner Parameters: timeoutMSecs - specifies the maximum wait time in milliseconds throws: LockException - will be thrown when the lock can not be acquired |
lock | public void lock(Object ownerId, Object resourceId, int targetLockLevel, int compatibility, boolean preferred, long timeoutMSecs) throws LockException(Code) | | Most flexible way to acquire a lock on a resource.
This method blocks and waits for the lock in case it is not avaiable. If
there is a timeout or a deadlock or the thread is interrupted a
LockException is thrown.
Parameters: ownerId - a unique id identifying the entity that wants to acquire thislock Parameters: resourceId - the resource to get the level for Parameters: targetLockLevel - the lock level to acquire Parameters: compatibility - GenericLock.COMPATIBILITY_NONEif no additional compatibility isdesired (same as reentrant set to false) ,GenericLock.COMPATIBILITY_REENTRANTif lock level by the sameowner shall not affect compatibility (same as reentrant set totrue), or GenericLock.COMPATIBILITY_SUPPORTif lock levels thatare the same as the desired shall not affect compatibility, orfinally GenericLock.COMPATIBILITY_REENTRANT_AND_SUPPORTwhich isa combination of reentrant and support Parameters: preferred - in case this lock request is incompatible with existing onesand we wait, it shall be granted before other waiting requeststhat are not preferred Parameters: timeoutMSecs - specifies the maximum wait time in milliseconds throws: LockException - will be thrown when the lock can not be acquired |
release | public boolean release(Object ownerId, Object resourceId)(Code) | | Releases all locks for a certain resource held by a certain owner.
Parameters: ownerId - the id of the owner of the lock Parameters: resourceId - the resource to releases the lock for true if the lock actually was released, false in casethere was no lock held by the owner |
releaseAll | public void releaseAll(Object ownerId)(Code) | | Releases all locks (partially) held by an owner.
Parameters: ownerId - the id of the owner |
removeLock | public void removeLock(MultiLevelLock lock)(Code) | | Removes the specified lock from the associated resource.
Caution: This does not release the lock, but only moves it out
of the scope of this manager. Use
LockManager2.release(Object,Object) for that.
Parameters: lock - the lock to be removed |
startGlobalTimeout | public void startGlobalTimeout(Object ownerId, long timeoutMSecs)(Code) | | Starts a global timeout for an owner. This is especially usefull, when the owner is a
transaction. After a global timeout occurs all of the owner's lock will be released and
the owner will not be allowed to access any
locks before before calling
LockManager2.releaseAll(Object) .
Parameters: ownerId - a unique id identifying the entity that wants to acquire thislock Parameters: timeoutMSecs - specifies the global timeout in milliseconds |
tryLock | public boolean tryLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant)(Code) | | Tries to acquire a lock on a resource.
This method does not block, but immediatly returns. If a lock is not
available false will be returned.
Parameters: ownerId - a unique id identifying the entity that wants to acquire thislock Parameters: resourceId - the resource to get the level for Parameters: targetLockLevel - the lock level to acquire Parameters: reentrant - true if this request shall not be influenced byother locks held by the same owner true if the lock has been acquired, false otherwise |
|
|