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.concurrency.locking
Class ReferenceEntityLockService

    java.lang.Object
      org.jasig.portal.concurrency.locking.ReferenceEntityLockService

All Implemented Interfaces:
  IEntityLockService

    public class ReferenceEntityLockService

extends java.lang.Object
implements IEntityLockService

Version:
  $Revision: 1.16 $
Author:
  Dan Ellentuck

Field Summary
`private int` | `defaultLockPeriod`
`private IEntityLockStore` | `lockStore`
`private int` | `lockToleranceMillis`
`private static org.apache.commons.logging.Log` | `log`
`private boolean` | `multiServer`
`private static IEntityLockService` | `singleton`

Fields inherited from interface org.jasig.portal.concurrency.IEntityLockService
`READ_LOCK, WRITE_LOCK`

Constructor Summary
`ReferenceEntityLockService()` ReferenceEntityLockingService constructor comment.

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.
`private int` | `getDefaultLockPeriod()`
`private IEntityLockStore` | `getLockStore()`
`private int` | `getLockToleranceMillis()`
`private java.util.Date` | `getNewExpiration(int durationSecs)`
`private void` | `initialize()`
`private boolean` | `isLocked(java.lang.Class entityType, java.lang.String entityKey)` Answers if the entity represented by the entityType and entityKey already has a lock of some type.
`private boolean` | `isLocked(java.lang.Class entityType, java.lang.String entityKey, java.lang.Integer lockType)` Answers if the entity represented by entityType and entityKey has one or more locks.
`private boolean` | `isMultiServer()`
`private boolean` | `isUnexpired(IEntityLock lock)`
`boolean` | `isValid(IEntityLock lock)` Answers if this `IEntityLock` represents a lock that is still good.
`private boolean` | `isValidLockType(int lockType)`
`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 if no conflicting locks exist.
`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 if no conflicting locks exist.
`IEntityLock` | `newLock(EntityIdentifier entityID, int lockType, java.lang.String owner)` Returns a lock for the entity, lock type and owner if no conflicting locks exist.
`IEntityLock` | `newLock(EntityIdentifier entityID, int lockType, java.lang.String owner, int durationSecs)` Returns a lock for the entity, lock type and owner if no conflicting locks exist.
`void` | `release(IEntityLock lock)` Releases the `IEntityLock`.
`void` | `renew(IEntityLock lock)` Extends the expiration time of the lock by some service-defined increment.
`void` | `renew(IEntityLock lock, int duration)` Extends the expiration time of the lock by some service-defined increment.
`private IEntityLock[]` | `retrieveLocks(java.lang.Class entityType, java.lang.String entityKey, java.lang.Integer lockType)` Returns an IEntityLock[] containing unexpired locks for the entityType, entityKey and lockType.
`private void` | `setDefaultLockPeriod(int newDefaultLockPeriod)`
`private void` | `setLockToleranceMillis(int newLockToleranceMillis)`
`private void` | `setMultiServer(boolean newMultiServer)`
`static IEntityLockService` | `singleton()`

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

### singleton

    private static IEntityLockService singleton

### lockStore

    private IEntityLockStore lockStore

### multiServer

    private boolean multiServer

### defaultLockPeriod

    private int defaultLockPeriod

### lockToleranceMillis

    private int lockToleranceMillis

Constructor Detail

### ReferenceEntityLockService

    public ReferenceEntityLockService()
                               throws LockingException

  ReferenceEntityLockingService constructor comment.

  Throws:
    `LockingException`

Method Detail

### convert

    public void convert(IEntityLock lock,
                        int newType)
                 throws LockingException

  Attempts to change the lock's `lockType` to `newType`.

  Specified by:
    `convert` in interface `IEntityLockService`
  Parameters:
    `lock` - IEntityLock
    `newType` - int
  Throws:
    `LockingException`

### convert

    public void convert(IEntityLock lock,
                        int newType,
                        int newDuration)
                 throws LockingException

  Attempts to change the lock's `lockType` to `newType`.

  Specified by:
    `convert` in interface `IEntityLockService`
  Parameters:
    `lock` - IEntityLock
    `newType` - int
    `newDuration` - int
  Throws:
    `LockingException`

### existsInStore

    public boolean existsInStore(IEntityLock lock)
                          throws LockingException

  Answer if this `IEntityLock` exists in the store.

  Specified by:
    `existsInStore` in interface `IEntityLockService`
  Parameters:
    `lock` -
  Returns:
    boolean
  Throws:
    `LockingException`

### getDefaultLockPeriod

    private int getDefaultLockPeriod()

  Returns:
    int

### getLockStore

    private IEntityLockStore getLockStore()

  Returns:
    org.jasig.portal.concurrency.locking.IEntityLockStore

### getLockToleranceMillis

    private int getLockToleranceMillis()

  Returns:
    int

### getNewExpiration

    private java.util.Date getNewExpiration(int durationSecs)

  Returns:
    java.util.Date

### initialize

    private void initialize()
                     throws LockingException

  Throws:
    `LockingException`

### isLocked

    private boolean isLocked(java.lang.Class entityType,
                             java.lang.String entityKey)
                      throws LockingException

  Answers if the entity represented by the entityType and entityKey already has a lock of some type.

  Parameters:
    `entityType` -
    `entityKey` -
  Throws:
    `LockingException`

### isLocked

    private boolean isLocked(java.lang.Class entityType,
                             java.lang.String entityKey,
                             java.lang.Integer lockType)
                      throws LockingException

  Answers if the entity represented by entityType and entityKey has one or more locks. Param `lockType` can be null.

  Parameters:
    `entityType` -
    `entityKey` -
    `lockType` - (optional)
  Throws:
    `LockingException`

### isMultiServer

    private boolean isMultiServer()

  Returns:
    boolean

### isUnexpired

    private boolean isUnexpired(IEntityLock lock)

  Parameters:
    `lock` - IEntityLock
  Returns:
    boolean

### isValid

    public boolean isValid(IEntityLock lock)
                    throws LockingException

  Answers if this `IEntityLock` represents a lock that is still good. To be valid, a lock must exist in the underlying store and be unexpired.

  Specified by:
    `isValid` in interface `IEntityLockService`
  Parameters:
    `lock` - IEntityLock
  Throws:
    `LockingException`

### isValidLockType

    private boolean isValidLockType(int lockType)

### newLock

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

  Returns a lock for the entity, lock type and owner if no conflicting locks exist.

  Specified by:
    `newLock` in interface `IEntityLockService`
  Parameters:
    `entityType` -
    `entityKey` -
    `lockType` -
    `owner` -
  Returns:
    org.jasig.portal.groups.IEntityLock
  Throws:
    `LockingException`

### newLock

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

  Returns a lock for the entity, lock type and owner if no conflicting locks exist.

  Specified by:
    `newLock` in interface `IEntityLockService`
  Parameters:
    `entityType` -
    `entityKey` -
    `lockType` -
    `owner` -
    `durationSecs` -
  Returns:
    org.jasig.portal.groups.IEntityLock
  Throws:
    `LockingException` - Retrieves potentially conflicting locks and checks them before adding the new lock to the store. The add of a write lock will fail if any other lock exists for the entity. The add of a read lock will fail if a write lock exists for the entity. After we add a write lock we check the store a second time and roll back if any other lock has snuck in. I think this is slightly safer than depending on the db isolation level for transactional integrity.

### newLock

    public IEntityLock newLock(EntityIdentifier entityID,
                               int lockType,
                               java.lang.String owner)
                        throws LockingException

  Returns a lock for the entity, lock type and owner if no conflicting locks exist.

  Specified by:
    `newLock` in interface `IEntityLockService`
  Parameters:
    `entityID` - org.jasig.portal.EntityIdentifier
    `lockType` - int
    `owner` - String
  Returns:
    org.jasig.portal.groups.IEntityLock
  Throws:
    `LockingException`

### newLock

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

  Returns a lock for the entity, lock type and owner if no conflicting locks exist.

  Specified by:
    `newLock` in interface `IEntityLockService`
  Parameters:
    `entityID` - org.jasig.portal.EntityIdentifier
    `lockType` - int
    `owner` - String
    `durationSecs` - int
  Returns:
    org.jasig.portal.groups.IEntityLock
  Throws:
    `LockingException`

### release

    public void release(IEntityLock lock)
                 throws LockingException

  Releases the `IEntityLock`.

  Specified by:
    `release` in interface `IEntityLockService`
  Parameters:
    `lock` - IEntityLock
  Throws:
    `LockingException`

### renew

    public void renew(IEntityLock lock)
               throws LockingException

  Extends the expiration time of the lock by some service-defined increment.

  Specified by:
    `renew` in interface `IEntityLockService`
  Parameters:
    `lock` - IEntityLock
  Throws:
    `LockingException`

### renew

    public void renew(IEntityLock lock,
                      int duration)
               throws LockingException

  Extends the expiration time of the lock by some service-defined increment.

  Specified by:
    `renew` in interface `IEntityLockService`
  Parameters:
    `lock` - IEntityLock
  Throws:
    `LockingException`

### retrieveLocks

    private IEntityLock[] retrieveLocks(java.lang.Class entityType,
                                        java.lang.String entityKey,
                                        java.lang.Integer lockType)
                                 throws LockingException

  Returns an IEntityLock[] containing unexpired locks for the entityType, entityKey and lockType. Param `lockType` can be null.

  Parameters:
    `entityType` -
    `entityKey` -
    `lockType` - (optional)
  Throws:
    `LockingException`

### setDefaultLockPeriod

    private void setDefaultLockPeriod(int newDefaultLockPeriod)

  Parameters:
    `newDefaultLockPeriod` - int

### setLockToleranceMillis

    private void setLockToleranceMillis(int newLockToleranceMillis)

  Parameters:
    `newLockToleranceMillis` - int

### setMultiServer

    private void setMultiServer(boolean newMultiServer)

  Parameters:
    `newMultiServer` - boolean

### singleton

    public static IEntityLockService singleton()
                                        throws LockingException

  Returns:
    org.jasig.portal.concurrency.locking.ReferenceEntityLockService
  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