Class FormRecordLockManager
- java.lang.Object
-
- de.xima.fc.workflow.processor.logic.execution.FormRecordLockManager
-
@Deprecated public final class FormRecordLockManager extends Object
Deprecated.Form records are locked viaVorgang.isInArbeit()
. In a future release the lock date of theFormRecordLock
may return in one way or another.ALock
that allows locking aVorgang
for exclusive use. Used for example by the workflow processing engine.This is achieved via the
Vorgang.isInArbeit()
attribute. Locking uses the following SQL statement to ensure that only one thread can acquire the lock:update form_record set flag_in_progress = true where id = ID and flag_in_progress = false;
The lock is acquire successfully when the above statement returns an update count of 1. When two threads attempt to acquire the lock at the same time, only one of these statements can succeed with an update count of 1, assuming the database does not let queries access a temporary state from another transaction.Please note that the UPDATE statement used to acquire the lock is a so-called JPQL Bulk Update statement. According to the JPQL language reference, the "persistence context is not synchronized with the result of the bulk update or delete." (10.2.9. JPQL Bulk Update and Delete ) This means that even after successfully locking a
Vorgang
instance, theVorgang.setInArbeit(boolean)
flag WILL NOT betrue
, not even after rereading theVorgang
from the persistence context, such as viaIAbstractDao.read(IBaseEntityContext, Comparable)
. To quote the spec again:In general, bulk update and delete operations [and thus, form record lock operations] should only be performed within a separate transaction or at the beginning of a transaction (before entities have been accessed whose state might be affected by such operations).
- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FormRecordLockManager.ILockedFormRecord
Deprecated.Result returned bylockFormRecord(Vorgang)
.
-
Constructor Summary
Constructors Constructor Description FormRecordLockManager()
Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static FormRecordLockManager.ILockedFormRecord
getEmptyLock()
Deprecated.static Lock
getLock(long formRecordId)
Deprecated.Creates a new lock for the form record with the given ID.static Lock
getLock(Vorgang formRecord)
Deprecated.Creates a new lock for the given form record.static FormRecordLockManager.ILockedFormRecord
lockFormRecord(Vorgang formRecord)
Deprecated.Attempts to acquire aLock
on the with the givenVorgang.getId()
.
-
-
-
Method Detail
-
getEmptyLock
public static FormRecordLockManager.ILockedFormRecord getEmptyLock()
Deprecated.- Returns:
- An empty lock representing no form record that can be used as a default. The
FormRecordLockManager.ILockedFormRecord.close()
is a no-op andFormRecordLockManager.ILockedFormRecord.getFormRecordId()
returnsITransferableEntity.INVALID_ID
.
-
getLock
public static Lock getLock(long formRecordId)
Deprecated.Creates a new lock for the form record with the given ID. Uses a newly created system entity context for accessing the database.- Parameters:
formRecordId
- ID of the form record to lock.- Returns:
- A lock for locking the given form record for exclusive access.
-
getLock
public static Lock getLock(Vorgang formRecord)
Deprecated.Creates a new lock for the given form record. Uses a newly created system entity context for accessing the database.- Parameters:
formRecord
- Form record to lock.- Returns:
- A lock for locking the given form record for exclusive access.
-
lockFormRecord
public static FormRecordLockManager.ILockedFormRecord lockFormRecord(Vorgang formRecord) throws CouldNotLockFormRecordException
Deprecated.Attempts to acquire aLock
on the with the givenVorgang.getId()
. Waits forXfcConfigKeys.Application.FORM_RECORD_LOCK_TIMEOUT_MILLIS
to acquire a lock, then gives up by throwing an exception.- Parameters:
formRecord
- Form record to lock.- Returns:
- A handler for releasing the lock, should be used with try-resource statement.
- Throws:
CouldNotLockFormRecordException
- When the form record could not be locked, such as when another process holds the lock already.
-
-