Package org.bonitasoft.engine.lock
Interface LockService
-
- All Known Implementing Classes:
MemoryLockService
public interface LockService
This service allows to synchronize access to a resource using ReadWrite lock pattern. Creating an exclusive lock allows to be the only one at a time accessing the resource.- Author:
- Elias Ricken de Medeiros, Baptiste Mesta, Matthieu Chaffotte
- See Also:
ReentrantReadWriteLock
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BonitaLock
lock(long objectToLockId, java.lang.String objectType, long tenantId)
Acquire the lock for the object having type and id in parameters
This method wait for the lock to be availableBonitaLock
tryLock(long objectToLockId, java.lang.String objectType, long timeout, java.util.concurrent.TimeUnit timeUnit, long tenantId)
Acquire the lock for the object having type and id in parameters waiting maximum timeout
This method wait for the lock to be available.void
unlock(BonitaLock lock, long tenantId)
-
-
-
Method Detail
-
unlock
void unlock(BonitaLock lock, long tenantId) throws SLockException
- Throws:
SLockException
-
lock
BonitaLock lock(long objectToLockId, java.lang.String objectType, long tenantId) throws SLockException, SLockTimeoutException
Acquire the lock for the object having type and id in parameters
This method wait for the lock to be available- Parameters:
objectToLockId
-objectType
-tenantId
- TODO- Returns:
- the lock
- Throws:
SLockException
- when we were unable to lock due to an unexpected errorSLockTimeoutException
- when we were unable to lock due to a timeout
-
tryLock
BonitaLock tryLock(long objectToLockId, java.lang.String objectType, long timeout, java.util.concurrent.TimeUnit timeUnit, long tenantId) throws SLockException
Acquire the lock for the object having type and id in parameters waiting maximum timeout
This method wait for the lock to be available. If it becomes available before the timeout expires the returns the obtained lock, else returns null- Parameters:
objectToLockId
-objectType
-timeout
-timeUnit
-tenantId
-- Returns:
- the obtained lock if it has been acquired before the timeout expires or null if the timeout has expired.
- Throws:
SLockException
- when we were unable to lock (not because of the timeout)
-
-