|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface IEntityLockService
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.
| Field Summary | |
|---|---|
static int |
READ_LOCK
|
static int |
WRITE_LOCK
|
| Method Summary | |
|---|---|
void |
convert(IEntityLock lock,
int newType)
Attempts to change the lock's lockType to newType. |
void |
convert(IEntityLock lock,
int newType,
int newDuration)
Attempts to change the lock's lockType to newType. |
boolean |
existsInStore(IEntityLock lock)
Answer if this IEntityLock exists in the store. |
boolean |
isValid(IEntityLock lock)
Answers if this IEntityLock represents a lock that is still
good. |
IEntityLock |
newLock(Class entityType,
String entityKey,
int lockType,
String owner)
Returns a lock for the entity, lock type and owner. |
IEntityLock |
newLock(Class entityType,
String entityKey,
int lockType,
String owner,
int durationSecs)
Returns a lock for the entity, lock type and owner. |
IEntityLock |
newLock(EntityIdentifier entityID,
int lockType,
String owner)
Returns a lock for the entity, lock type and owner. |
IEntityLock |
newLock(EntityIdentifier entityID,
int lockType,
String owner,
int durationSecs)
Returns a lock for the entity, lock type and owner. |
void |
release(IEntityLock lock)
Releases the IEntityLock. |
void |
renew(IEntityLock lock)
Extends the expiration time of the lock by the default increment. |
void |
renew(IEntityLock lock,
int duration)
Extends the expiration time of the lock by duration seconds. |
| Field Detail |
|---|
static final int READ_LOCK
static final int WRITE_LOCK
| Method Detail |
|---|
void convert(IEntityLock lock,
int newType)
throws LockingException
lockType to newType.
lock - IEntityLocknewType - int
LockingException
void convert(IEntityLock lock,
int newType,
int newDuration)
throws LockingException
lockType to newType.
lock - IEntityLocknewType - intnewDuration - int
LockingException
boolean existsInStore(IEntityLock lock)
throws LockingException
IEntityLock exists in the store.
lock -
LockingException
boolean isValid(IEntityLock lock)
throws LockingException
IEntityLock represents a lock that is still
good. To be valid, a lock must exist in the underlying store and be
unexpired and unreleased.
lock - IEntityLock
LockingException
IEntityLock newLock(Class entityType,
String entityKey,
int lockType,
String owner)
throws LockingException
entityType - ClassentityKey - StringlockType - intowner - String
LockingException
IEntityLock newLock(Class entityType,
String entityKey,
int lockType,
String owner,
int durationSecs)
throws LockingException
entityType - ClassentityKey - StringlockType - intowner - StringdurationSecs - int
LockingException
IEntityLock newLock(EntityIdentifier entityID,
int lockType,
String owner)
throws LockingException
entityID - EntityIdentifierlockType - intowner - String
LockingException
IEntityLock newLock(EntityIdentifier entityID,
int lockType,
String owner,
int durationSecs)
throws LockingException
entityID - EntityIdentifierlockType - intowner - StringdurationSecs - int
LockingException
void release(IEntityLock lock)
throws LockingException
IEntityLock.
lock - IEntityLock
LockingException
void renew(IEntityLock lock)
throws LockingException
lock - IEntityLock
LockingException
void renew(IEntityLock lock,
int duration)
throws LockingException
duration seconds.
lock - IEntityLockduration -
LockingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||