IEntityLocks
, that can be used to control concurrent access to portal entities. A lock is associated with a particular entity and has an owner
, a lockType
and a service-controlled expirationTime
. Currently supported lock types are READ_LOCK and WRITE_LOCK. If I want to lock an entity for update, I ask the service for a write lock:
int lockType = IEntityLockService.WRITE_LOCK;
EntityIdentifier eid = myEntity.getEntityIdentifier();
IEntityLock lock = svc.newLock(eid, lockType, lockOwner);
If there is no conflicting lock on the entity, the service responds with the requested lock. If I acquire the lock, I know that no other client will get be able to get a conflicting lock. From then on, I communicate with the service via the lock:
lock.convert(int newType);
lock.isValid();
lock.release();
lock.renew();
A READ lock guarantees repeatable reads; other clients can get READ locks but not WRITE locks. A WRITE lock guarantees exclusive access; no other clients can get either READ or WRITE locks on the entity.
NB: since the locking service is not part of a transactional or object persistence framework, it has no way to enforce its own use. @author Dan Ellentuck @version $Revision: 19776 $
|
|
|
|
|
|
|
|
|
|
|
|