| java.lang.Object org.jasig.portal.services.EntityLockService
EntityLockService | public class EntityLockService (Code) | | 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.
author: Dan Ellentuck version: $Revision: 35551 $ |
Method Summary | |
public static synchronized EntityLockService | instance() | public IEntityLock | newReadLock(Class entityType, String entityKey, String owner) Returns a read lock for the entity type, entity key and owner. | public IEntityLock | newReadLock(Class entityType, String entityKey, String owner, int duration) Returns a read lock for the entity type, entity key and owner. | public IEntityLock | newReadLock(EntityIdentifier entityID, String owner) Returns a read lock for the IBasicEntity and owner. | public IEntityLock | newReadLock(EntityIdentifier entityID, String owner, int durationSecs) Returns a read lock for the IBasicEntity , owner and duration. | public IEntityLock | newWriteLock(Class entityType, String entityKey, String owner) Returns a write lock for the entity type, entity key and owner. | public IEntityLock | newWriteLock(Class entityType, String entityKey, String owner, int durationSecs) Returns a write lock for the entity type, entity key and owner. | public IEntityLock | newWriteLock(EntityIdentifier entityID, String owner) Returns a write lock for the IBasicEntity and owner. | public IEntityLock | newWriteLock(EntityIdentifier entityID, String owner, int durationSecs) Returns a write lock for the IBasicEntity , owner and duration. |
newReadLock | public IEntityLock newReadLock(Class entityType, String entityKey, String owner) throws LockingException(Code) | | Returns a read lock for the entity type, entity key and owner.
org.jasig.portal.concurrency.locking.IEntityLock Parameters: entityType - Class Parameters: entityKey - String Parameters: owner - String exception: LockingException - |
newReadLock | public IEntityLock newReadLock(Class entityType, String entityKey, String owner, int duration) throws LockingException(Code) | | Returns a read lock for the entity type, entity key and owner.
org.jasig.portal.concurrency.locking.IEntityLock Parameters: entityType - Class Parameters: entityKey - String Parameters: owner - String Parameters: duration - int (in seconds) exception: LockingException - |
newReadLock | public IEntityLock newReadLock(EntityIdentifier entityID, String owner, int durationSecs) throws LockingException(Code) | | Returns a read lock for the IBasicEntity , owner and duration.
org.jasig.portal.concurrency.locking.IEntityLock Parameters: entityID - EntityIdentifier Parameters: owner - String Parameters: durationSecs - int exception: LockingException - |
newWriteLock | public IEntityLock newWriteLock(Class entityType, String entityKey, String owner) throws LockingException(Code) | | Returns a write lock for the entity type, entity key and owner.
org.jasig.portal.concurrency.locking.IEntityLock Parameters: entityType - Class Parameters: entityKey - String Parameters: owner - String exception: LockingException - |
newWriteLock | public IEntityLock newWriteLock(Class entityType, String entityKey, String owner, int durationSecs) throws LockingException(Code) | | Returns a write lock for the entity type, entity key and owner.
org.jasig.portal.concurrency.locking.IEntityLock Parameters: entityType - Class Parameters: entityKey - String Parameters: owner - String Parameters: durationSecs - int exception: LockingException - |
newWriteLock | public IEntityLock newWriteLock(EntityIdentifier entityID, String owner, int durationSecs) throws LockingException(Code) | | Returns a write lock for the IBasicEntity , owner and duration.
org.jasig.portal.concurrency.locking.IEntityLock Parameters: entityID - EntityIdentifier Parameters: owner - String Parameters: durationSecs - int exception: LockingException - |
|
|