|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.portal.concurrency.locking.ReferenceEntityLockService
public class ReferenceEntityLockService
| 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 |
|---|
private static final org.apache.commons.logging.Log log
private static IEntityLockService singleton
private IEntityLockStore lockStore
private boolean multiServer
private int defaultLockPeriod
private int lockToleranceMillis
| Constructor Detail |
|---|
public ReferenceEntityLockService()
throws LockingException
LockingException| Method Detail |
|---|
public void convert(IEntityLock lock,
int newType)
throws LockingException
lockType to newType.
convert in interface IEntityLockServicelock - IEntityLocknewType - int
LockingException
public void convert(IEntityLock lock,
int newType,
int newDuration)
throws LockingException
lockType to newType.
convert in interface IEntityLockServicelock - IEntityLocknewType - intnewDuration - int
LockingException
public boolean existsInStore(IEntityLock lock)
throws LockingException
IEntityLock exists in the store.
existsInStore in interface IEntityLockServicelock -
LockingExceptionprivate int getDefaultLockPeriod()
private IEntityLockStore getLockStore()
private int getLockToleranceMillis()
private java.util.Date getNewExpiration(int durationSecs)
private void initialize()
throws LockingException
LockingException
private boolean isLocked(java.lang.Class entityType,
java.lang.String entityKey)
throws LockingException
entityType - entityKey -
LockingException
private boolean isLocked(java.lang.Class entityType,
java.lang.String entityKey,
java.lang.Integer lockType)
throws LockingException
lockType can be null.
entityType - entityKey - lockType - (optional)
LockingExceptionprivate boolean isMultiServer()
private boolean isUnexpired(IEntityLock lock)
lock - IEntityLock
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.
isValid in interface IEntityLockServicelock - IEntityLock
LockingExceptionprivate boolean isValidLockType(int lockType)
public IEntityLock newLock(java.lang.Class entityType,
java.lang.String entityKey,
int lockType,
java.lang.String owner)
throws LockingException
newLock in interface IEntityLockServiceentityType - entityKey - lockType - owner -
LockingException
public IEntityLock newLock(java.lang.Class entityType,
java.lang.String entityKey,
int lockType,
java.lang.String owner,
int durationSecs)
throws LockingException
newLock in interface IEntityLockServiceentityType - entityKey - lockType - owner - durationSecs -
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.
public IEntityLock newLock(EntityIdentifier entityID,
int lockType,
java.lang.String owner)
throws LockingException
newLock in interface IEntityLockServiceentityID - org.jasig.portal.EntityIdentifierlockType - intowner - String
LockingException
public IEntityLock newLock(EntityIdentifier entityID,
int lockType,
java.lang.String owner,
int durationSecs)
throws LockingException
newLock in interface IEntityLockServiceentityID - org.jasig.portal.EntityIdentifierlockType - intowner - StringdurationSecs - int
LockingException
public void release(IEntityLock lock)
throws LockingException
IEntityLock.
release in interface IEntityLockServicelock - IEntityLock
LockingException
public void renew(IEntityLock lock)
throws LockingException
renew in interface IEntityLockServicelock - IEntityLock
LockingException
public void renew(IEntityLock lock,
int duration)
throws LockingException
renew in interface IEntityLockServicelock - IEntityLock
LockingException
private IEntityLock[] retrieveLocks(java.lang.Class entityType,
java.lang.String entityKey,
java.lang.Integer lockType)
throws LockingException
lockType can be null.
entityType - entityKey - lockType - (optional)
LockingExceptionprivate void setDefaultLockPeriod(int newDefaultLockPeriod)
newDefaultLockPeriod - intprivate void setLockToleranceMillis(int newLockToleranceMillis)
newLockToleranceMillis - intprivate void setMultiServer(boolean newMultiServer)
newMultiServer - boolean
public static IEntityLockService singleton()
throws LockingException
LockingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||