ModeShape Distribution 3.0.0.Beta4

org.modeshape.webdav.locking
Class LockedObject

java.lang.Object
  extended by org.modeshape.webdav.locking.LockedObject

public class LockedObject
extends Object

a helper class for ResourceLocks, represents the Locks


Field Summary
protected  LockedObject[] children
          children of that lock
protected  boolean exclusive
          weather the lock is exclusive or not. if owner=null the exclusive value doesn't matter
protected  long expiresAt
          Describing the timeout of a locked object (ms)
protected  int lockDepth
          Describing the depth of a locked collection.
protected  String[] owner
          owner of the lock. shared locks can have multiple owners. is null if no owner is present
protected  LockedObject parent
           
protected  String type
          weather the lock is a write or read lock
 
Constructor Summary
LockedObject(ResourceLocks resLocks, String path, boolean temporary)
           
 
Method Summary
 void addChild(LockedObject newChild)
          adds a new child lock to this lock
 boolean addLockedObjectOwner(String owner)
          adds a new owner to a lock
 boolean checkLocks(boolean exclusive, int depth)
          checks if a lock of the given exclusivity can be placed, only considering children up to "depth"
 String getID()
          Gets the LockID (locktoken) for the LockedObject
 int getLockDepth()
          Gets the depth of the lock
 String[] getOwner()
          Gets the owners for the LockedObject
 String getPath()
          Gets the path for the LockedObject
 long getTimeoutMillis()
          Gets the timeout for the LockedObject
 String getType()
          Gets the type of the lock
 boolean hasExpired()
          Return true if the lock has expired.
 boolean isExclusive()
          Gets the exclusivity for the LockedObject
 boolean isShared()
          Gets the exclusivity for the LockedObject
 void refreshTimeout(int timeout)
          Sets a new timeout for the LockedObject
 void removeLockedObject()
          deletes this Lock object. assumes that it has no children and no owners (does not check this itself)
 void removeLockedObjectOwner(String owner)
          tries to remove the owner from the lock
 void removeTempLockedObject()
          deletes this Lock object. assumes that it has no children and no owners (does not check this itself)
 void setExclusive(boolean exclusive)
          Sets the exclusivity for the LockedObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockDepth

protected int lockDepth
Describing the depth of a locked collection. If the locked resource is not a collection, depth is 0 / doesn't matter.


expiresAt

protected long expiresAt
Describing the timeout of a locked object (ms)


owner

protected String[] owner
owner of the lock. shared locks can have multiple owners. is null if no owner is present


children

protected LockedObject[] children
children of that lock


parent

protected LockedObject parent

exclusive

protected boolean exclusive
weather the lock is exclusive or not. if owner=null the exclusive value doesn't matter


type

protected String type
weather the lock is a write or read lock

Constructor Detail

LockedObject

public LockedObject(ResourceLocks resLocks,
                    String path,
                    boolean temporary)
Parameters:
resLocks - the resourceLocks where locks are stored
path - the path to the locked object
temporary - indicates if the LockedObject should be temporary or not
Method Detail

addLockedObjectOwner

public boolean addLockedObjectOwner(String owner)
adds a new owner to a lock

Parameters:
owner - string that represents the owner
Returns:
true if the owner was added, false otherwise

removeLockedObjectOwner

public void removeLockedObjectOwner(String owner)
tries to remove the owner from the lock

Parameters:
owner - string that represents the owner

addChild

public void addChild(LockedObject newChild)
adds a new child lock to this lock

Parameters:
newChild - new child

removeLockedObject

public void removeLockedObject()
deletes this Lock object. assumes that it has no children and no owners (does not check this itself)


removeTempLockedObject

public void removeTempLockedObject()
deletes this Lock object. assumes that it has no children and no owners (does not check this itself)


checkLocks

public boolean checkLocks(boolean exclusive,
                          int depth)
checks if a lock of the given exclusivity can be placed, only considering children up to "depth"

Parameters:
exclusive - wheather the new lock should be exclusive
depth - the depth to which should be checked
Returns:
true if the lock can be placed

refreshTimeout

public void refreshTimeout(int timeout)
Sets a new timeout for the LockedObject

Parameters:
timeout -

getTimeoutMillis

public long getTimeoutMillis()
Gets the timeout for the LockedObject

Returns:
timeout

hasExpired

public boolean hasExpired()
Return true if the lock has expired.

Returns:
true if timeout has passed

getID

public String getID()
Gets the LockID (locktoken) for the LockedObject

Returns:
locktoken

getOwner

public String[] getOwner()
Gets the owners for the LockedObject

Returns:
owners

getPath

public String getPath()
Gets the path for the LockedObject

Returns:
path

setExclusive

public void setExclusive(boolean exclusive)
Sets the exclusivity for the LockedObject

Parameters:
exclusive -

isExclusive

public boolean isExclusive()
Gets the exclusivity for the LockedObject

Returns:
exclusivity

isShared

public boolean isShared()
Gets the exclusivity for the LockedObject

Returns:
exclusivity

getType

public String getType()
Gets the type of the lock

Returns:
type

getLockDepth

public int getLockDepth()
Gets the depth of the lock

Returns:
depth

ModeShape Distribution 3.0.0.Beta4

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