smbdav
Interface LockManager

All Known Implementing Classes:
DefaultLockManager

public interface LockManager

This is the interface that must be implemented by lock management providers. This provides the core operations used by Davenport to coordinate locking of resources. A provider would implement this interface and install a subclass of LockManagerFactory to create instances of the implementation.

Author:
Eric Glass

Field Summary
static int EXCLUSIVE_LOCK_SUPPORT
          Indicates that exclusive locking is supported for a given resource.
static int NO_LOCK_SUPPORT
          Indicates that no locking support is provided for a given resource.
static int SHARED_LOCK_SUPPORT
          Indicates that shared locking is supported for a given resource.
 
Method Summary
 Lock[] getActiveLocks(jcifs.smb.SmbFile resource)
          Returns the set of active locks on the specified resource.
 jcifs.smb.SmbFile getLockedResource(jcifs.smb.SmbFile resource, java.security.Principal principal)
          Returns a handle for manipulating a locked SMB resource.
 int getLockSupport(jcifs.smb.SmbFile resource)
          Retrieves the lock support mask for a specified resource.
 boolean isLocked(jcifs.smb.SmbFile resource, java.lang.String lockToken)
          Indicates whether the specified resource is locked under the provided lock token.
 java.lang.String lock(jcifs.smb.SmbFile resource, java.security.Principal principal, LockInfo lockInfo)
          Locks the specified resource, using the provided lock information.
 void refresh(jcifs.smb.SmbFile resource, java.security.Principal principal, java.lang.String[] lockTokens, long timeout)
          Refreshes the locks represented by the provided lock tokens on the specified resource.
 void unlock(jcifs.smb.SmbFile resource, java.security.Principal principal, java.lang.String lockToken)
          Removes the lock on the specified resource represented by the provided lock token.
 

Field Detail

NO_LOCK_SUPPORT

public static final int NO_LOCK_SUPPORT
Indicates that no locking support is provided for a given resource.

See Also:
Constant Field Values

EXCLUSIVE_LOCK_SUPPORT

public static final int EXCLUSIVE_LOCK_SUPPORT
Indicates that exclusive locking is supported for a given resource.

See Also:
Constant Field Values

SHARED_LOCK_SUPPORT

public static final int SHARED_LOCK_SUPPORT
Indicates that shared locking is supported for a given resource.

See Also:
Constant Field Values
Method Detail

getLockSupport

public int getLockSupport(jcifs.smb.SmbFile resource)
                   throws java.io.IOException
Retrieves the lock support mask for a specified resource.

Parameters:
resource - The resource for which lock support is being inspected.
Returns:
An int representing the supported locks for the specified resource. This value is the exclusive-OR of all supported lock types.
Throws:
java.io.IOException - If an IO error occurs.

isLocked

public boolean isLocked(jcifs.smb.SmbFile resource,
                        java.lang.String lockToken)
                 throws java.io.IOException
Indicates whether the specified resource is locked under the provided lock token.

Parameters:
resource - The resource.
lockToken - The lock token.
Returns:
A boolean indicating whether the lock token provided represents an active lock on the specified resource.
Throws:
java.io.IOException - If an IO error occurs.

getActiveLocks

public Lock[] getActiveLocks(jcifs.smb.SmbFile resource)
                      throws java.io.IOException
Returns the set of active locks on the specified resource.

Parameters:
resource - The resource.
Returns:
A Lock[] representing the set of all current active locks held on the specified resource.
Throws:
java.io.IOException - If an IO error occurs.

getLockedResource

public jcifs.smb.SmbFile getLockedResource(jcifs.smb.SmbFile resource,
                                           java.security.Principal principal)
                                    throws java.io.IOException
Returns a handle for manipulating a locked SMB resource. A manager enforcing locks at the SMB level will return a singleton SmbFile instance for performing operations against the resource. If such management is not required, this method returns the resource passed in by the caller.

Parameters:
resource - The resource for which the lock instance is to be obtained.
principal - The requesting principal.
Returns:
The SmbFile object used to perform write and delete operations on the resource. If no special resource management is required by this manager, this method returns the resource passed in by the caller.
Throws:
java.io.IOException - If an IO error occurs.

lock

public java.lang.String lock(jcifs.smb.SmbFile resource,
                             java.security.Principal principal,
                             LockInfo lockInfo)
                      throws LockException,
                             java.io.IOException
Locks the specified resource, using the provided lock information.

Parameters:
resource - The resource that will be locked.
principal - The principal requesting the lock.
lockInfo - Information regarding the lock that is to be applied.
Returns:
A String containing the lock token that was created as a result of this operation.
Throws:
LockException - If the lock could not be created.
java.io.IOException - If an IO error occurs.

refresh

public void refresh(jcifs.smb.SmbFile resource,
                    java.security.Principal principal,
                    java.lang.String[] lockTokens,
                    long timeout)
             throws LockException,
                    java.io.IOException
Refreshes the locks represented by the provided lock tokens on the specified resource.

Parameters:
resource - The resource whose locks will be refreshed.
principal - The principal requesting the lock refresh.
lockTokens - The set of lock tokens for the locks that are to be refreshed.
timeout - The requested lock timeout value. This is a value in milliseconds, or one of SmbDAVUtilities.UNSPECIFIED_TIMEOUT (if no timeout is specified) or SmbDAVUtilities.INFINITE_TIMEOUT (if an infinite timeout is requested).
Throws:
LockException - If the locks could not be refreshed.
java.io.IOException - If an IO error occurs.

unlock

public void unlock(jcifs.smb.SmbFile resource,
                   java.security.Principal principal,
                   java.lang.String lockToken)
            throws LockException,
                   java.io.IOException
Removes the lock on the specified resource represented by the provided lock token.

Parameters:
resource - The resource whose lock is to be removed.
principal - The principal requesting the lock removal.
lockToken - The lock token representing the lock that is to be removed.
Throws:
LockException - If the lock could not be removed.
java.io.IOException - If an IO error occurs.


Copyright © 2004 Eric Glass