Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasig.portal.services
Class EntityLockService

    java.lang.Object
      org.jasig.portal.services.EntityLockService

    public class EntityLockService

extends java.lang.Object

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.

Version:
  $Revision: 1.11 $
Author:
  Dan Ellentuck

Field Summary
`private static EntityLockService` | `instance`
`private IEntityLockService` | `lockService`
`private static org.apache.commons.logging.Log` | `log`

Constructor Summary
`private` | `EntityLockService()` Creates new EntityLockService

Method Summary
`private void` | `initialize()`
`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
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    private static final org.apache.commons.logging.Log log

### instance

    private static EntityLockService instance

### lockService

    private IEntityLockService lockService

Constructor Detail

### EntityLockService

    private EntityLockService()
                       throws LockingException

  Creates new EntityLockService

  Throws:
    `LockingException`

Method Detail

### initialize

    private void initialize()
                     throws LockingException

  Throws:
    `LockingException`

### instance

    public static EntityLockService instance()
                                      throws LockingException

  Throws:
    `LockingException`

### newReadLock

    public IEntityLock newReadLock(java.lang.Class entityType,
                                   java.lang.String entityKey,
                                   java.lang.String owner)
                            throws LockingException

  Returns a read lock for the entity type, entity key and owner.

  Parameters:
    `entityType` - Class
    `entityKey` - String
    `owner` - String
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

### newReadLock

    public IEntityLock newReadLock(java.lang.Class entityType,
                                   java.lang.String entityKey,
                                   java.lang.String owner,
                                   int duration)
                            throws LockingException

  Returns a read lock for the entity type, entity key and owner.

  Parameters:
    `entityType` - Class
    `entityKey` - String
    `owner` - String
    `duration` - int (in seconds)
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

### newReadLock

    public IEntityLock newReadLock(EntityIdentifier entityID,
                                   java.lang.String owner)
                            throws LockingException

  Returns a read lock for the `IBasicEntity` and owner.

  Parameters:
    `entityID` - EntityIdentifier
    `owner` - String
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

### newReadLock

    public IEntityLock newReadLock(EntityIdentifier entityID,
                                   java.lang.String owner,
                                   int durationSecs)
                            throws LockingException

  Returns a read lock for the `IBasicEntity`, owner and duration.

  Parameters:
    `entityID` - EntityIdentifier
    `owner` - String
    `durationSecs` - int
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

### newWriteLock

    public IEntityLock newWriteLock(java.lang.Class entityType,
                                    java.lang.String entityKey,
                                    java.lang.String owner)
                             throws LockingException

  Returns a write lock for the entity type, entity key and owner.

  Parameters:
    `entityType` - Class
    `entityKey` - String
    `owner` - String
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

### newWriteLock

    public IEntityLock newWriteLock(java.lang.Class entityType,
                                    java.lang.String entityKey,
                                    java.lang.String owner,
                                    int durationSecs)
                             throws LockingException

  Returns a write lock for the entity type, entity key and owner.

  Parameters:
    `entityType` - Class
    `entityKey` - String
    `owner` - String
    `durationSecs` - int
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

### newWriteLock

    public IEntityLock newWriteLock(EntityIdentifier entityID,
                                    java.lang.String owner)
                             throws LockingException

  Returns a write lock for the `IBasicEntity` and owner.

  Parameters:
    `entityID` - EntityIdentifier
    `owner` - String
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

### newWriteLock

    public IEntityLock newWriteLock(EntityIdentifier entityID,
                                    java.lang.String owner,
                                    int durationSecs)
                             throws LockingException

  Returns a write lock for the `IBasicEntity`, owner and duration.

  Parameters:
    `entityID` - EntityIdentifier
    `owner` - String
    `durationSecs` - int
  Returns:
    org.jasig.portal.concurrency.locking.IEntityLock
  Throws:
    `LockingException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD