From 4a28fe8e17abb0cb390cb760f91f8b224a946e93 Mon Sep 17 00:00:00 2001 From: Konstantin Krivopustov Date: Wed, 24 Feb 2010 12:02:08 +0000 Subject: [PATCH] Refs #3 Pessimistic locking (JavaDoc added) --- .../cuba/core/app/LockManagerAPI.java | 27 +++++++++++++++++++ .../haulmont/cuba/core/app/LockService.java | 24 +++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/modules/core/src/com/haulmont/cuba/core/app/LockManagerAPI.java b/modules/core/src/com/haulmont/cuba/core/app/LockManagerAPI.java index 57e1c92727..4cddee89d9 100644 --- a/modules/core/src/com/haulmont/cuba/core/app/LockManagerAPI.java +++ b/modules/core/src/com/haulmont/cuba/core/app/LockManagerAPI.java @@ -18,13 +18,40 @@ public interface LockManagerAPI { String NAME = "cuba_LockManager"; + /** + * Try to lock object + * @param name locking object name + * @param id locking object ID + * @return
  • null in case of successful lock, + *
  • {@link com.haulmont.cuba.core.global.LockNotSupported} instance in case of locking is not configured for this object, + *
  • {@link LockInfo} instance in case of this object is already locked by someone + */ LockInfo lock(String name, String id); + /** + * Unlock object + * @param name locking object name + * @param id locking object ID + */ void unlock(String name, String id); + /** + * Get locking status for particular object + * @param name locking object name + * @param id locking object ID + * @return
  • null in case of no lock, + *
  • {@link com.haulmont.cuba.core.global.LockNotSupported} instance in case of locking is not configured for this object, + *
  • {@link LockInfo} instance in case of this object is locked by someone + */ LockInfo getLockInfo(String name, String id); + /** + * List of current locks + */ List getCurrentLocks(); + /** + * Process locks expiring. All expired locks will be removed. + */ void expireLocks(); } diff --git a/modules/global/src/com/haulmont/cuba/core/app/LockService.java b/modules/global/src/com/haulmont/cuba/core/app/LockService.java index a52b97e271..2f16046685 100644 --- a/modules/global/src/com/haulmont/cuba/core/app/LockService.java +++ b/modules/global/src/com/haulmont/cuba/core/app/LockService.java @@ -18,11 +18,35 @@ public interface LockService { String NAME = "cuba_LockService"; + /** + * Try to lock object + * @param name locking object name + * @param id locking object ID + * @return
  • null in case of successful lock, + *
  • {@link com.haulmont.cuba.core.global.LockNotSupported} instance in case of locking is not configured for this object, + *
  • {@link LockInfo} instance in case of this object is already locked by someone + */ LockInfo lock(String name, String id); + /** + * Unlock object + * @param name locking object name + * @param id locking object ID + */ void unlock(String name, String id); + /** + * Get locking status for particular object + * @param name locking object name + * @param id locking object ID + * @return
  • null in case of no lock, + *
  • {@link com.haulmont.cuba.core.global.LockNotSupported} instance in case of locking is not configured for this object, + *
  • {@link LockInfo} instance in case of this object is locked by someone + */ LockInfo getLockInfo(String name, String id); + /** + * List of current locks + */ List getCurrentLocks(); }