smbdav
Class DefaultLockManager

java.lang.Object
  extended bysmbdav.DefaultLockManager
All Implemented Interfaces:
LockManager
Direct Known Subclasses:
SmbLockManager

public class DefaultLockManager
extends java.lang.Object
implements LockManager


Nested Class Summary
protected  class DefaultLockManager.BasicLock
           
 
Field Summary
protected  java.util.Map locks
           
protected static java.util.Timer TIMER
           
 
Fields inherited from interface smbdav.LockManager
EXCLUSIVE_LOCK_SUPPORT, NO_LOCK_SUPPORT, SHARED_LOCK_SUPPORT
 
Constructor Summary
DefaultLockManager()
           
DefaultLockManager(long defaultTimeout)
           
DefaultLockManager(long defaultTimeout, long maximumTimeout)
           
 
Method Summary
protected  DefaultLockManager.BasicLock createLock(jcifs.smb.SmbFile resource, java.security.Principal principal, java.lang.String lockToken, LockInfo lockInfo)
           
 Lock[] getActiveLocks(jcifs.smb.SmbFile resource)
          Returns the set of active locks on the specified resource.
 long getDefaultTimeout()
           
 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.
 long getMaximumTimeout()
           
 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 setDefaultTimeout(long defaultTimeout)
           
 void setMaximumTimeout(long maximumTimeout)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIMER

protected static final java.util.Timer TIMER

locks

protected final java.util.Map locks
Constructor Detail

DefaultLockManager

public DefaultLockManager()

DefaultLockManager

public DefaultLockManager(long defaultTimeout)

DefaultLockManager

public DefaultLockManager(long defaultTimeout,
                          long maximumTimeout)
Method Detail

getDefaultTimeout

public long getDefaultTimeout()

setDefaultTimeout

public void setDefaultTimeout(long defaultTimeout)

getMaximumTimeout

public long getMaximumTimeout()

setMaximumTimeout

public void setMaximumTimeout(long maximumTimeout)

getLockSupport

public int getLockSupport(jcifs.smb.SmbFile resource)
                   throws java.io.IOException
Description copied from interface: LockManager
Retrieves the lock support mask for a specified resource.

Specified by:
getLockSupport in interface LockManager
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
Description copied from interface: LockManager
Indicates whether the specified resource is locked under the provided lock token.

Specified by:
isLocked in interface LockManager
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
Description copied from interface: LockManager
Returns the set of active locks on the specified resource.

Specified by:
getActiveLocks in interface LockManager
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
Description copied from interface: LockManager
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.

Specified by:
getLockedResource in interface LockManager
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
Description copied from interface: LockManager
Locks the specified resource, using the provided lock information.

Specified by:
lock in interface LockManager
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
Description copied from interface: LockManager
Refreshes the locks represented by the provided lock tokens on the specified resource.

Specified by:
refresh in interface LockManager
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:
java.io.IOException - If an IO error occurs.
LockException - If the locks could not be refreshed.

unlock

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

Specified by:
unlock in interface LockManager
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:
java.io.IOException - If an IO error occurs.
LockException - If the lock could not be removed.

createLock

protected DefaultLockManager.BasicLock createLock(jcifs.smb.SmbFile resource,
                                                  java.security.Principal principal,
                                                  java.lang.String lockToken,
                                                  LockInfo lockInfo)
                                           throws java.io.IOException,
                                                  LockException
Throws:
java.io.IOException
LockException


Copyright © 2004 Eric Glass