| org.jasig.portal.concurrency.IEntityLockService
All known Subclasses: org.jasig.portal.concurrency.locking.ReferenceEntityLockService,
IEntityLockService | public interface IEntityLockService (Code) | | Defines an api for acquiring lock objects, 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: 34757 $ |
Method Summary | |
public void | convert(IEntityLock lock, int newType) Attempts to change the lock's lockType to newType . | public void | convert(IEntityLock lock, int newType, int newDuration) Attempts to change the lock's lockType to newType . | public boolean | existsInStore(IEntityLock lock) Answer if this IEntityLock exists in the store. | public boolean | isValid(IEntityLock lock) Answers if this IEntityLock represents a lock that is still
good. | public IEntityLock | newLock(Class entityType, String entityKey, int lockType, String owner) Returns a lock for the entity, lock type and owner. | public IEntityLock | newLock(Class entityType, String entityKey, int lockType, String owner, int durationSecs) Returns a lock for the entity, lock type and owner. | public IEntityLock | newLock(EntityIdentifier entityID, int lockType, String owner) Returns a lock for the entity, lock type and owner. | public IEntityLock | newLock(EntityIdentifier entityID, int lockType, String owner, int durationSecs) Returns a lock for the entity, lock type and owner. | public void | release(IEntityLock lock) Releases the IEntityLock . | public void | renew(IEntityLock lock) Extends the expiration time of the lock by the default increment. | public void | renew(IEntityLock lock, int duration) Extends the expiration time of the lock by duration seconds. |
READ_LOCK | public static int READ_LOCK(Code) | | |
WRITE_LOCK | public static int WRITE_LOCK(Code) | | |
|
|