org.abstracthorizon.danube.webdav.lock
Class Lock

java.lang.Object
  extended by org.abstracthorizon.danube.webdav.lock.Lock

public class Lock
extends Object

This clas represents a lock

Author:
Daniel Sendula

Field Summary
protected static long counter
          Static token element counter
protected  int depth
          Locks depth.
protected  Object owner
          Locks owner.
protected  int scope
          Lock scope
protected  Timeout timeout
          Locks timeout
protected  String token
          Lock's token
protected  int type
          Lock type
protected  long validUntil
          Timestamp until where this lock is valid
 
Constructor Summary
Lock(int type, int scope, Object owner, Timeout timeout, int depth)
          Constructor
 
Method Summary
protected  void createToken()
          Creates new lock's token
 boolean equals(Object o)
          Retunrs true if locks are same (token wise)
 void freeLock()
          Frees lock.
 int getDepth()
          Returns lock depth
 Object getOwner()
          Returns lock owner
 int getScope()
          Returns lock scope
 Timeout getTimeout()
          Returns lock timeout
 String getToken()
          Return's lock token
 int getType()
          Returns lock type
 long getValidUntil()
          Returns timestamp until lock is valid
 boolean refreshTimeout(Timeout timeout)
          Refreshes locks validity by reusing given timeout
 void setDepth(int depth)
          Sets lock depth
 void setOwner(Object owner)
          Sets lock owner
 void setScope(int scope)
          Sets lock scope
 void setTimeout(Timeout timeout)
          Sets lock timeout
 void setToken(String token)
          Sets lock token
 void setType(int type)
          Sets lock type
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected int type
Lock type

See Also:
LockingMechanism.TYPE_WRITE

scope

protected int scope
Lock scope

See Also:
LockingMechanism.SCOPE_SHARED, LockingMechanism.SCOPE_EXCLUSIVE

owner

protected Object owner
Locks owner. May be null


depth

protected int depth
Locks depth. May be null


timeout

protected Timeout timeout
Locks timeout


token

protected String token
Lock's token


validUntil

protected long validUntil
Timestamp until where this lock is valid


counter

protected static long counter
Static token element counter

Constructor Detail

Lock

public Lock(int type,
            int scope,
            Object owner,
            Timeout timeout,
            int depth)
Constructor

Parameters:
type - lock type
scope - lock scope
owner - lock owner
timeout - lock timeout
depth - lock depth
Method Detail

createToken

protected void createToken()
Creates new lock's token


getDepth

public int getDepth()
Returns lock depth

Returns:
lock depth

setDepth

public void setDepth(int depth)
Sets lock depth

Parameters:
depth - lock depth

getOwner

public Object getOwner()
Returns lock owner

Returns:
lock owner

setOwner

public void setOwner(Object owner)
Sets lock owner

Parameters:
owner - lock owner

getScope

public int getScope()
Returns lock scope

Returns:
lock scope

setScope

public void setScope(int scope)
Sets lock scope

Parameters:
scope - lock scope

getTimeout

public Timeout getTimeout()
Returns lock timeout

Returns:
lock timeout

setTimeout

public void setTimeout(Timeout timeout)
Sets lock timeout

Parameters:
timeout - lock timeout

getToken

public String getToken()
Return's lock token

Returns:
lock token

setToken

public void setToken(String token)
Sets lock token

Parameters:
token - lock token

getType

public int getType()
Returns lock type

Returns:
lock type

setType

public void setType(int type)
Sets lock type

Parameters:
type - lock type

getValidUntil

public long getValidUntil()
Returns timestamp until lock is valid

Returns:
timestamp until lock is valid

refreshTimeout

public boolean refreshTimeout(Timeout timeout)
Refreshes locks validity by reusing given timeout

Parameters:
timeout - timeout
Returns:
true

freeLock

public void freeLock()
Frees lock. This implementation does nothing - it is defined hook point for extensions


equals

public boolean equals(Object o)
Retunrs true if locks are same (token wise)

Overrides:
equals in class Object
Returns:
true if locks are same (token wise)


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.