|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasig.portal.services.EntityLockService
This is a bootstrap class and facade for the IEntityLockService implementation.
It presents a simple api for acquiring lock objects, IEntityLocks
,
that can be used to control concurrent access to portal entities in a
multi-server environment. (See org.jasig.portal.concurrency.IEntityLockService
for a fuller description.)
Currently supported lock types are IEntityLockService.READ_LOCK and IEntityLockService.WRITE_LOCK.
If I want to lock an entity for update, I ask the service for a write lock:
Class type = anEntity.getClass(); // maybe hard-coded(?)
String key = anEntity.getKey();
EntityIdentifier ei = new EntityIdentifier(key, type);
String owner = getThePortalUserId();
IEntityLock lock = EntityLockService.instance().newWriteLock(ei, owner);
Or maybe:
IEntityLock lock = EntityLockService.instance().newWriteLock(ei, owner, duration);
If there are no conflicting locks on the entity, the service returns the requested lock. If I acquire the lock, I know that no other client will be able to get a conflicting lock, and from then on, I communicate with the service via the lock:
lock.convert(int newType); // See IEntityLockService for types.
lock.isValid();
lock.release();
lock.renew();
A READ lock guarantees shared access; 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.
Method Summary | |
static EntityLockService |
instance()
|
IEntityLock |
newReadLock(java.lang.Class entityType,
java.lang.String entityKey,
java.lang.String owner)
Returns a read lock for the entity type, entity key and owner. |
IEntityLock |
newReadLock(java.lang.Class entityType,
java.lang.String entityKey,
java.lang.String owner,
int duration)
Returns a read lock for the entity type, entity key and owner. |
IEntityLock |
newReadLock(EntityIdentifier entityID,
java.lang.String owner)
Returns a read lock for the IBasicEntity and owner. |
IEntityLock |
newReadLock(EntityIdentifier entityID,
java.lang.String owner,
int durationSecs)
Returns a read lock for the IBasicEntity , owner and duration. |
IEntityLock |
newWriteLock(java.lang.Class entityType,
java.lang.String entityKey,
java.lang.String owner)
Returns a write lock for the entity type, entity key and owner. |
IEntityLock |
newWriteLock(java.lang.Class entityType,
java.lang.String entityKey,
java.lang.String owner,
int durationSecs)
Returns a write lock for the entity type, entity key and owner. |
IEntityLock |
newWriteLock(EntityIdentifier entityID,
java.lang.String owner)
Returns a write lock for the IBasicEntity and owner. |
IEntityLock |
newWriteLock(EntityIdentifier entityID,
java.lang.String owner,
int durationSecs)
Returns a write lock for the IBasicEntity , owner and duration. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static EntityLockService instance() throws LockingException
LockingException
public IEntityLock newReadLock(java.lang.Class entityType, java.lang.String entityKey, java.lang.String owner) throws LockingException
entityType
- ClassentityKey
- Stringowner
- String
LockingException
public IEntityLock newReadLock(java.lang.Class entityType, java.lang.String entityKey, java.lang.String owner, int duration) throws LockingException
entityType
- ClassentityKey
- Stringowner
- Stringduration
- int (in seconds)
LockingException
public IEntityLock newReadLock(EntityIdentifier entityID, java.lang.String owner) throws LockingException
IBasicEntity
and owner.
entityID
- EntityIdentifierowner
- String
LockingException
public IEntityLock newReadLock(EntityIdentifier entityID, java.lang.String owner, int durationSecs) throws LockingException
IBasicEntity
, owner and duration.
entityID
- EntityIdentifierowner
- StringdurationSecs
- int
LockingException
public IEntityLock newWriteLock(java.lang.Class entityType, java.lang.String entityKey, java.lang.String owner) throws LockingException
entityType
- ClassentityKey
- Stringowner
- String
LockingException
public IEntityLock newWriteLock(java.lang.Class entityType, java.lang.String entityKey, java.lang.String owner, int durationSecs) throws LockingException
entityType
- ClassentityKey
- Stringowner
- StringdurationSecs
- int
LockingException
public IEntityLock newWriteLock(EntityIdentifier entityID, java.lang.String owner) throws LockingException
IBasicEntity
and owner.
entityID
- EntityIdentifierowner
- String
LockingException
public IEntityLock newWriteLock(EntityIdentifier entityID, java.lang.String owner, int durationSecs) throws LockingException
IBasicEntity
, owner and duration.
entityID
- EntityIdentifierowner
- StringdurationSecs
- int
LockingException
|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |