|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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(java.lang.Class entityType,
java.lang.String entityKey,
int lockType,
java.lang.String owner)
Returns a lock for the entity, lock type and owner. |
IEntityLock |
newLock(java.lang.Class entityType,
java.lang.String entityKey,
int lockType,
java.lang.String owner,
int durationSecs)
Returns a lock for the entity, lock type and owner. |
IEntityLock |
newLock(EntityIdentifier entityID,
int lockType,
java.lang.String owner)
Returns a lock for the entity, lock type and owner. |
IEntityLock |
newLock(EntityIdentifier entityID,
int lockType,
java.lang.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 |
public static final int READ_LOCK
public static final int WRITE_LOCK
Method Detail |
public void convert(IEntityLock lock, int newType) throws LockingException
lockType
to newType
.
lock
- IEntityLocknewType
- int
LockingException
public void convert(IEntityLock lock, int newType, int newDuration) throws LockingException
lockType
to newType
.
lock
- IEntityLocknewType
- intnewDuration
- int
LockingException
public boolean existsInStore(IEntityLock lock) throws LockingException
IEntityLock
exists in the store.
lock
-
LockingException
public 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
public IEntityLock newLock(java.lang.Class entityType, java.lang.String entityKey, int lockType, java.lang.String owner) throws LockingException
entityType
- ClassentityKey
- StringlockType
- intowner
- String
LockingException
public IEntityLock newLock(java.lang.Class entityType, java.lang.String entityKey, int lockType, java.lang.String owner, int durationSecs) throws LockingException
entityType
- ClassentityKey
- StringlockType
- intowner
- StringdurationSecs
- int
LockingException
public IEntityLock newLock(EntityIdentifier entityID, int lockType, java.lang.String owner) throws LockingException
entityID
- EntityIdentifierlockType
- intowner
- String
LockingException
public IEntityLock newLock(EntityIdentifier entityID, int lockType, java.lang.String owner, int durationSecs) throws LockingException
entityID
- EntityIdentifierlockType
- intowner
- StringdurationSecs
- int
LockingException
public void release(IEntityLock lock) throws LockingException
IEntityLock
.
lock
- IEntityLock
LockingException
public void renew(IEntityLock lock) throws LockingException
lock
- IEntityLock
LockingException
public void renew(IEntityLock lock, int duration) throws LockingException
duration
seconds.
lock
- IEntityLockduration
-
LockingException
|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |