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:
  • Method Summary

    Modifier and Type
    Method
    Description
    lock(long objectToLockId, String objectType)
    Acquire the lock for the object having type and id in parameters
    This method wait for the lock to be available
    tryLock(long objectToLockId, String objectType, long timeout, TimeUnit timeUnit)
    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
     
  • Method Details

    • unlock

      void unlock(BonitaLock lock) throws SLockException
      Throws:
      SLockException
    • lock

      BonitaLock lock(long objectToLockId, String objectType) 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 -
      Returns:
      the lock
      Throws:
      SLockException - when we were unable to lock due to an unexpected error
      SLockTimeoutException - when we were unable to lock due to a timeout
    • tryLock

      BonitaLock tryLock(long objectToLockId, String objectType, long timeout, TimeUnit timeUnit) 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 -
      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)