|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.abstracthorizon.danube.webdav.lock.impl.SimpleInMemoryLockingMechanism
public class SimpleInMemoryLockingMechanism
Simple, in-memory locking mechanism
| Field Summary | |
|---|---|
protected int |
harvestMinimumInterval
Minimal interval timed out locks are removed. |
protected Map<Lock,Collection<Object>> |
lockResources
Map of locks to resources |
protected long |
nextHarvested
Time locks can be harvesed as the earliest |
protected Map<Object,Collection<Lock>> |
resourcesLocks
Map of resources to locks |
protected Map<String,Lock> |
tokenLocks
Map of tokens to locks |
| Fields inherited from interface org.abstracthorizon.danube.webdav.lock.LockingMechanism |
|---|
SCOPE_EXCLUSIVE, SCOPE_NONE, SCOPE_SHARED, TYPE_WRITE |
| Constructor Summary | |
|---|---|
SimpleInMemoryLockingMechanism()
Constructor |
|
| Method Summary | |
|---|---|
Lock |
createLock(int type,
int scope,
Object owner,
Timeout timeout,
int depth)
Creates the lock |
protected Lock |
createLockImpl(int type,
int scope,
Object owner,
Timeout timeout,
int depth)
Constructs lock object |
Lock |
findLock(String token)
Retunrs the lock with the given token or null |
int |
getHarvestMinimumInterval()
Returns minimal harvest interval in miliseconds |
Lock[] |
getLocks(Object resource)
Returns locks for the given resource |
Object[] |
getResources(Lock lock)
Returns an array of resources for the given lock |
int[] |
getSupportedLockScopes(Object resource)
Returns array with LockingMechanism.SCOPE_EXCLUSIVE and LockingMechanism.SCOPE_SHARED |
protected void |
harvestLocks()
Removes all locks that are not valid anymore (due to timeout) |
boolean |
isAccessAllowed(Object resource,
String token)
Returns true if access to the resource is allowed |
boolean |
isLocked(Object resource)
Returns true if resource is locked |
boolean |
lockResource(Lock lock,
Object resource)
Locks reource |
protected void |
removeLock(Lock lock)
Removes a lock |
void |
removeLocks(Object resource)
Removes locks form the given resource |
void |
setHarvestMinimumInterval(int harvestMinimumInterval)
Sets minimal harvest interval in miliseconds |
void |
unlockResources(Lock lock)
Unlocks resource |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Map<String,Lock> tokenLocks
protected Map<Lock,Collection<Object>> lockResources
protected Map<Object,Collection<Lock>> resourcesLocks
protected int harvestMinimumInterval
protected long nextHarvested
| Constructor Detail |
|---|
public SimpleInMemoryLockingMechanism()
| Method Detail |
|---|
public Lock createLock(int type,
int scope,
Object owner,
Timeout timeout,
int depth)
createLock in interface LockingMechanismtype - lock typescope - lock typeowner - lock ownertimeout - lock timeoutdepth - lock depth
protected Lock createLockImpl(int type,
int scope,
Object owner,
Timeout timeout,
int depth)
type - lock typescope - lock scopeowner - lock ownertimeout - lock timeoutdepth - lock depth
public Lock findLock(String token)
null
findLock in interface LockingMechanismtoken - token
null
public boolean lockResource(Lock lock,
Object resource)
lockResource in interface LockingMechanismlock - lockresource - resource
true if lock succededpublic void unlockResources(Lock lock)
unlockResources in interface LockingMechanismlock - lockpublic void removeLocks(Object resource)
removeLocks in interface LockingMechanismresource - resourcepublic Lock[] getLocks(Object resource)
getLocks in interface LockingMechanismresource - resource
public Object[] getResources(Lock lock)
getResources in interface LockingMechanismlock - lock
public boolean isLocked(Object resource)
true if resource is locked
isLocked in interface LockingMechanismresource - resource
true if resource is locked
public boolean isAccessAllowed(Object resource,
String token)
true if access to the resource is allowed
isAccessAllowed in interface LockingMechanismresource - resourcetoken - token
true if access to the resource is allowedpublic int[] getSupportedLockScopes(Object resource)
LockingMechanism.SCOPE_EXCLUSIVE and LockingMechanism.SCOPE_SHARED
getSupportedLockScopes in interface LockingMechanismresource - resource
LockingMechanism.SCOPE_EXCLUSIVE and LockingMechanism.SCOPE_SHAREDprotected void harvestLocks()
protected void removeLock(Lock lock)
lock - lockpublic int getHarvestMinimumInterval()
public void setHarvestMinimumInterval(int harvestMinimumInterval)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||