org.abstracthorizon.danube.webdav.lock
Interface LockingMechanism

All Known Implementing Classes:
FSLockingMechanism, SimpleInMemoryLockingMechanism

public interface LockingMechanism

This interface describes locking mechanism used for WebDAV locking

Author:
Daniel Sendula

Field Summary
static int SCOPE_EXCLUSIVE
          Exclusive lock
static int SCOPE_NONE
          No scope defined
static int SCOPE_SHARED
          Shared lock
static int TYPE_WRITE
          Write lock
 
Method Summary
 Lock createLock(int type, int scope, Object owner, Timeout timeout, int depth)
          Creates lock
 Lock findLock(String token)
          Finds a lock or returns null
 Lock[] getLocks(Object resource)
          Returns all locks on the resource or null
 Object[] getResources(Lock lock)
          Returns all resources locked by the given lock
 int[] getSupportedLockScopes(Object resource)
          Returns an array of supported lock scopes on a resource
 boolean isAccessAllowed(Object resource, String token)
          Checks if resource is accessible if token is supplied
 boolean isLocked(Object resource)
          Checks if the resource is locked
 boolean lockResource(Lock lock, Object resource)
          Locks a resource
 void removeLocks(Object resource)
          Removes a lock form the resource
 void unlockResources(Lock lock)
          Unlocks all resource defined by this lock
 

Field Detail

SCOPE_NONE

static final int SCOPE_NONE
No scope defined

See Also:
Constant Field Values

SCOPE_SHARED

static final int SCOPE_SHARED
Shared lock

See Also:
Constant Field Values

SCOPE_EXCLUSIVE

static final int SCOPE_EXCLUSIVE
Exclusive lock

See Also:
Constant Field Values

TYPE_WRITE

static final int TYPE_WRITE
Write lock

See Also:
Constant Field Values
Method Detail

createLock

Lock createLock(int type,
                int scope,
                Object owner,
                Timeout timeout,
                int depth)
Creates lock

Parameters:
type - lcok type
scope - lock scope
owner - lock owner
timeout - lock timeout
depth - lock depth
Returns:
newly created lock

findLock

Lock findLock(String token)
Finds a lock or returns null

Parameters:
token - lock token
Returns:
a lock or null

lockResource

boolean lockResource(Lock lock,
                     Object resource)
Locks a resource

Parameters:
lock - lock
resource - resource
Returns:
true if locking succeded

unlockResources

void unlockResources(Lock lock)
Unlocks all resource defined by this lock

Parameters:
lock - lock

removeLocks

void removeLocks(Object resource)
Removes a lock form the resource

Parameters:
resource - resource

getLocks

Lock[] getLocks(Object resource)
Returns all locks on the resource or null

Parameters:
resource - resource
Returns:
all locks on the resource or null

getResources

Object[] getResources(Lock lock)
Returns all resources locked by the given lock

Parameters:
lock - lock
Returns:
all resources locked by the given lock

isLocked

boolean isLocked(Object resource)
Checks if the resource is locked

Parameters:
resource - resource
Returns:
true if the resource is locked

isAccessAllowed

boolean isAccessAllowed(Object resource,
                        String token)
Checks if resource is accessible if token is supplied

Parameters:
resource - resource
token - token, may be null
Returns:
true if not locked or locked by the lock with givne token

getSupportedLockScopes

int[] getSupportedLockScopes(Object resource)
Returns an array of supported lock scopes on a resource

Parameters:
resource - resource
Returns:
an array of supported lock scopes


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