public interface OptimisticLockHandle
See Optimistic concurrency control for a general discussion about optimistic locking.
In Dragom, optimistic locking is used mainly by MutableNodeConfig and
MutableNode, the latter being what is generally seen by applications
using Dragom.
The idea is that an application that allow modifying the configuration data
underlying a Model is expected to the Node's to the user in a
hierarchical manner, allowing him to edit their properties on a Node by Node
basis. The user can look at Node properties, modify them and then save the
changes. At that point it is pertinent to ensure that the same Node properties
have not been changed by another user. To do that, the application obtains an
OptimisticLockHandle representing the state of the Node data. When saving the
data, it provides the same OptimisticLockHandle which allows the object to
validate the state of the data has not changed since it was read.
Typically, a last modification timestamp or unique revision number is maintained within an OptimisticLockHandle implementation.
An OptimisticLockHandle is mutable. When configuration data is saved successfully (the state of the OptimisticLockHandle corresponds to the state of the data it represents), it is updated to reflect the new state of the data so that the caller can save changed data repetitively withouth having to read them again.
Optimistic locking is managed externally to NodeConfigTransferObject,
even though the data represented by an OptimisticLockHandle is generally the
state of a NodeConfigTransferObject. The reason is to support the fact that
applications manage multiple independent groups of properties for a given Node,
for which independent NodeConfigTransferObject's are typically managed. But when
one is saved, it must not rendre the lock representing the others since they all
relate to the same conversation the user has. The caller can therefore obtain a
single OptimisticLockHandle that it shares among the multiple groups of data.
| Modifier and Type | Method and Description |
|---|---|
void |
clearLock()
Clears the lock.
|
boolean |
isLocked()
Indicates if the OptimisticLockHandle is actually locked, meaning that it
represents some state.
|
boolean isLocked()
An OptimisticLockHandle that is not locked is expected to get automatically locked to the state of data that is obtained (using a "get" method).
void clearLock()
Copyright © 2015–2017 AZYVA INC.. All rights reserved.