ModeShape Distribution 3.0.0.Beta4

org.modeshape.webdav.locking
Class ResourceLocks

java.lang.Object
  extended by org.modeshape.webdav.locking.ResourceLocks
All Implemented Interfaces:
IResourceLocks

public class ResourceLocks
extends Object
implements IResourceLocks

simple locking management for concurrent data access, NOT the webdav locking. ( could that be used instead? ) IT IS ACTUALLY USED FOR DOLOCK


Field Summary
protected  int cleanupCounter
           
protected  Hashtable<String,LockedObject> locks
          keys: path value: LockedObject from that path
protected  Hashtable<String,LockedObject> locksByID
          keys: id value: LockedObject from that id
protected  LockedObject root
           
protected  Hashtable<String,LockedObject> tempLocks
          keys: path value: Temporary LockedObject from that path
protected  Hashtable<String,LockedObject> tempLocksByID
          keys: id value: Temporary LockedObject from that id
protected  LockedObject tempRoot
           
 
Constructor Summary
ResourceLocks()
           
 
Method Summary
 void checkTimeouts(ITransaction transaction, boolean temporary)
          Deletes LockedObjects, where timeout has reached.
 boolean exclusiveLock(ITransaction transaction, String path, String owner, int depth, int timeout)
          Tries to lock the resource at "path" exclusively.
 LockedObject getLockedObjectByID(ITransaction transaction, String id)
          Gets the LockedObject corresponding to specified id.
 LockedObject getLockedObjectByPath(ITransaction transaction, String path)
          Gets the LockedObject on specified path.
 LockedObject getTempLockedObjectByID(ITransaction transaction, String id)
          Gets the LockedObject corresponding to specified id (locktoken).
 LockedObject getTempLockedObjectByPath(ITransaction transaction, String path)
          Gets the LockedObject on specified path.
 boolean lock(ITransaction transaction, String path, String owner, boolean exclusive, int depth, int timeout, boolean temporary)
          Tries to lock the resource at "path".
 boolean sharedLock(ITransaction transaction, String path, String owner, int depth, int timeout)
          Tries to lock the resource at "path" shared.
 boolean unlock(ITransaction transaction, String id, String owner)
          Unlocks all resources at "path" (and all subfolders if existing)

that have the same owner.

 void unlockTemporaryLockedObjects(ITransaction transaction, String path, String owner)
          Unlocks all resources at "path" (and all subfolders if existing)

that have the same owner.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cleanupCounter

protected int cleanupCounter

locks

protected Hashtable<String,LockedObject> locks
keys: path value: LockedObject from that path


locksByID

protected Hashtable<String,LockedObject> locksByID
keys: id value: LockedObject from that id


tempLocks

protected Hashtable<String,LockedObject> tempLocks
keys: path value: Temporary LockedObject from that path


tempLocksByID

protected Hashtable<String,LockedObject> tempLocksByID
keys: id value: Temporary LockedObject from that id


root

protected LockedObject root

tempRoot

protected LockedObject tempRoot
Constructor Detail

ResourceLocks

public ResourceLocks()
Method Detail

lock

public boolean lock(ITransaction transaction,
                    String path,
                    String owner,
                    boolean exclusive,
                    int depth,
                    int timeout,
                    boolean temporary)
             throws LockFailedException
Description copied from interface: IResourceLocks
Tries to lock the resource at "path".

Specified by:
lock in interface IResourceLocks
path - what resource to lock
owner - the owner of the lock
exclusive - if the lock should be exclusive (or shared)
depth - depth
timeout - Lock Duration in seconds.
Returns:
true if the resource at path was successfully locked, false if an existing lock prevented this
Throws:
LockFailedException

unlock

public boolean unlock(ITransaction transaction,
                      String id,
                      String owner)
Description copied from interface: IResourceLocks
Unlocks all resources at "path" (and all subfolders if existing)

that have the same owner.

Specified by:
unlock in interface IResourceLocks
id - id to the resource to unlock
owner - who wants to unlock
Returns:
true if the resources were unlocked, or false otherwise

unlockTemporaryLockedObjects

public void unlockTemporaryLockedObjects(ITransaction transaction,
                                         String path,
                                         String owner)
Description copied from interface: IResourceLocks
Unlocks all resources at "path" (and all subfolders if existing)

that have the same owner.

Specified by:
unlockTemporaryLockedObjects in interface IResourceLocks
path - what resource to unlock
owner - who wants to unlock

checkTimeouts

public void checkTimeouts(ITransaction transaction,
                          boolean temporary)
Description copied from interface: IResourceLocks
Deletes LockedObjects, where timeout has reached.

Specified by:
checkTimeouts in interface IResourceLocks
temporary - Check timeout on temporary or real locks

exclusiveLock

public boolean exclusiveLock(ITransaction transaction,
                             String path,
                             String owner,
                             int depth,
                             int timeout)
                      throws LockFailedException
Description copied from interface: IResourceLocks
Tries to lock the resource at "path" exclusively.

Specified by:
exclusiveLock in interface IResourceLocks
Parameters:
transaction - Transaction
path - what resource to lock
owner - the owner of the lock
depth - depth
timeout - Lock Duration in seconds.
Returns:
true if the resource at path was successfully locked, false if an existing lock prevented this
Throws:
LockFailedException

sharedLock

public boolean sharedLock(ITransaction transaction,
                          String path,
                          String owner,
                          int depth,
                          int timeout)
                   throws LockFailedException
Description copied from interface: IResourceLocks
Tries to lock the resource at "path" shared.

Specified by:
sharedLock in interface IResourceLocks
Parameters:
transaction - Transaction
path - what resource to lock
owner - the owner of the lock
depth - depth
timeout - Lock Duration in seconds.
Returns:
true if the resource at path was successfully locked, false if an existing lock prevented this
Throws:
LockFailedException

getLockedObjectByID

public LockedObject getLockedObjectByID(ITransaction transaction,
                                        String id)
Description copied from interface: IResourceLocks
Gets the LockedObject corresponding to specified id.

Specified by:
getLockedObjectByID in interface IResourceLocks
id - LockToken to requested resource
Returns:
LockedObject or null if no LockedObject on specified path exists

getLockedObjectByPath

public LockedObject getLockedObjectByPath(ITransaction transaction,
                                          String path)
Description copied from interface: IResourceLocks
Gets the LockedObject on specified path.

Specified by:
getLockedObjectByPath in interface IResourceLocks
path - Path to requested resource
Returns:
LockedObject or null if no LockedObject on specified path exists

getTempLockedObjectByID

public LockedObject getTempLockedObjectByID(ITransaction transaction,
                                            String id)
Description copied from interface: IResourceLocks
Gets the LockedObject corresponding to specified id (locktoken).

Specified by:
getTempLockedObjectByID in interface IResourceLocks
id - LockToken to requested resource
Returns:
LockedObject or null if no LockedObject on specified path exists

getTempLockedObjectByPath

public LockedObject getTempLockedObjectByPath(ITransaction transaction,
                                              String path)
Description copied from interface: IResourceLocks
Gets the LockedObject on specified path.

Specified by:
getTempLockedObjectByPath in interface IResourceLocks
path - Path to requested resource
Returns:
LockedObject or null if no LockedObject on specified path exists

ModeShape Distribution 3.0.0.Beta4

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.