deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.io.datastore
Class LockManager

java.lang.Object
  extended by org.deegree.io.datastore.LockManager

public class LockManager
extends Object

Keeps track of all persistent features that are in a locked state, i.e. a LockFeature request has been issued to lock them.

Locked features cannot be updated or deleted except by transactions that specify the appropriate lock identifier.

The LockManager also ensures that active locks survive a restart of the VM - therefore it keeps serialized and up-to-date versions of all active Lock instances in a temporary directory. The directory is specified by the java.io.tmpdir system property. On first initialization, i.e. the first call to getInstance(), the directory is scanned for all files matching the pattern deegree-lock*.tmp, and these are deserialized to rebuild the LockManager's status.

Version:
$Revision$, $Date$
Author:
Markus Schneider, last edited by: $Author$

Method Summary
 Lock acquireLock(LockFeature request, List<FeatureId> fidsToLock)
          Acquires a lock for the given LockFeature request.
static LockManager getInstance()
          Returns the only instance of LockManager.
 String getLockId(FeatureId fid)
          Returns the id of the lock that locks the specified feature (if it is locked).
static void initialize(File workingDir)
          Initializes the LockManager.
 boolean isLocked(FeatureId fid)
          Returns whether the specified feature is locked.
 void releaseLock(Lock lock)
          Releases the given lock completely (all associated features are unlocked) and removes it (also from the temporary directory).
 void releaseLock(String lockId)
          Releases the specified lock completely (all associated features are unlocked) and removes it (also from the temporary directory).
 void releaseLockPartly(String lockId, Set<FeatureId> unlockFids)
          Releases the specified lock partly (all specified features are unlocked).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

initialize

public static void initialize(File workingDir)
                       throws DatastoreException
Initializes the LockManager.

Parameters:
workingDir - directory where the LockManager will persists its locks
Throws:
DatastoreException

getInstance

public static LockManager getInstance()
Returns the only instance of LockManager.

Returns:
the only instance of LockManager

isLocked

public boolean isLocked(FeatureId fid)
Returns whether the specified feature is locked.

Parameters:
fid - id of the feature
Returns:
true, if the specified feature is locked, false otherwise

getLockId

public String getLockId(FeatureId fid)
Returns the id of the lock that locks the specified feature (if it is locked).

Parameters:
fid - id of the feature
Returns:
the lock id, or null if it is not locked

acquireLock

public Lock acquireLock(LockFeature request,
                        List<FeatureId> fidsToLock)
                 throws DatastoreException
Acquires a lock for the given LockFeature request. The affected feature instances and their descendant features + super features have to be specified as well.

If the lockAction in the request is set to ALL and not all requested features could be locked, a DatastoreException will be thrown.

If no features have been locked at all, a lock will be issued, but the lock is not registered (as requested by the WFS spec.).

Parameters:
request - LockFeature request
fidsToLock - all feature instances that are affected by the request
Returns:
the acquired lock, never null
Throws:
DatastoreException

releaseLock

public void releaseLock(String lockId)
                 throws DatastoreException
Releases the specified lock completely (all associated features are unlocked) and removes it (also from the temporary directory).

Parameters:
lockId - lock identifier
Throws:
DatastoreException

releaseLock

public void releaseLock(Lock lock)
Releases the given lock completely (all associated features are unlocked) and removes it (also from the temporary directory).

Parameters:
lock - lock to be released

releaseLockPartly

public void releaseLockPartly(String lockId,
                              Set<FeatureId> unlockFids)
                       throws DatastoreException
Releases the specified lock partly (all specified features are unlocked).

If there are no more features associated with the lock, the lock is removed.

Parameters:
lockId - lock identifier
unlockFids - features to be unlocked
Throws:
DatastoreException

toString

public String toString()
Overrides:
toString in class Object

deegree 2.3 (2010/04/09 10:10 build-4-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org