uk.ac.soton.itinnovation.grid.pbac2.pdp.locking
Class LockSet

java.lang.Object
  extended by uk.ac.soton.itinnovation.grid.pbac2.pdp.locking.LockSet

public class LockSet
extends Object

A set of named locks.


Constructor Summary
LockSet()
           
 
Method Summary
 String getLockedFor(String resourceID)
          Ensure that the lock is held.
 void lockResource(String resourceID, String reason, long timeout)
          Lock a resource by name.
 void unlockResource(String resourceID)
          Unlock the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockSet

public LockSet()
Method Detail

lockResource

public void lockResource(String resourceID,
                         String reason,
                         long timeout)
                  throws AcquireResourceLockTimeoutException
Lock a resource by name. If no lock currently exists for the resource, a new one is created.

Parameters:
resourceID - name of the resource to lock
reason - string to associate with lock
timeout - time in ms to wait for lock
Throws:
AcquireResourceLockTimeoutException - if the lock could not be acquired within a time limit.

unlockResource

public void unlockResource(String resourceID)
                    throws ResourceNotLockedException
Unlock the resource. If the refcount drops to zero, also remove it from the map.

Throws:
ResourceNotLockedException

getLockedFor

public String getLockedFor(String resourceID)
                    throws ResourceNotLockedException
Ensure that the lock is held.

Returns:
the reason passed to lockResource
Throws:
ResourceNotLockedException - if not locked


Copyright © 2001-2008 University of Southampton IT Innovation Centre. All Rights Reserved.