Package org.nuxeo.ecm.core.api.lock
Interface LockManager
-
- All Known Subinterfaces:
DBSConnection,DBSRepository
- All Known Implementing Classes:
DBSCachingConnection,DBSCachingRepository,DBSConnectionBase,DBSRepositoryBase,DBSTransactionState,MemConnection,MemRepository,MongoDBConnection,MongoDBRepository,RedisLockManager,VCSLockManager
public interface LockManager
Manager of locks for a repository.The method
closeLockManager()must be called when done with the lock manager.- Since:
- 6.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static booleancanLockBeRemoved(String oldOwner, String owner)Checks if a given lock can be removed by the given owner.default voidclearLockManagerCaches()Clears any cache held by the lock manager.default voidcloseLockManager()Closes the lock manager and releases resources.LockgetLock(String id)Gets the lock on a document.LockremoveLock(String id, String owner)Removes the lock from a document.LocksetLock(String id, Lock lock)Sets a lock on a document.
-
-
-
Method Detail
-
getLock
Lock getLock(String id)
Gets the lock on a document.If the document does not exist,
nullis returned.- Parameters:
id- the document id- Returns:
- the existing lock, or
nullwhen there is no lock
-
setLock
Lock setLock(String id, Lock lock)
Sets a lock on a document.If the document is already locked, returns its existing lock status (there is no re-locking,
removeLock(java.lang.String, java.lang.String)must be called first).- Parameters:
id- the document idlock- the lock to set- Returns:
nullif locking succeeded, or the existing lock if locking failed
-
removeLock
Lock removeLock(String id, String owner)
Removes the lock from a document.The previous lock is returned.
If
ownerisnullthen the lock is unconditionally removed.If
owneris notnull, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrueforLock.getFailed().- Parameters:
id- the document idowner- the owner to check, ornullfor no check- Returns:
- the previous lock (may be
null), with a failed flag if locking failed
-
canLockBeRemoved
static boolean canLockBeRemoved(String oldOwner, String owner)
Checks if a given lock can be removed by the given owner.- Parameters:
oldOwner- the existing lock's ownerowner- the owner (may benull)- Returns:
trueif the lock can be removed
-
closeLockManager
default void closeLockManager()
Closes the lock manager and releases resources.
-
clearLockManagerCaches
default void clearLockManagerCaches()
Clears any cache held by the lock manager.
-
-