deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.io.datastore
Class LockManager

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

public class LockManager
extends java.lang.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, java.util.List<FeatureId> fidsToLock)
          Acquires a lock for the given LockFeature request.
static LockManager getInstance()
          Returns the only instance of LockManager.
 java.lang.String getLockId(FeatureId fid)
          Returns the id of the lock that locks the specified feature (if it is locked).
static void initialize(java.io.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(java.lang.String lockId)
          Releases the specified lock completely (all associated features are unlocked) and removes it (also from the temporary directory).
 void releaseLockPartly(java.lang.String lockId, java.util.Set<FeatureId> unlockFids)
          Releases the specified lock partly (all specified features are unlocked).
 java.lang.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(java.io.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 java.lang.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,
                        java.util.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(java.lang.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(java.lang.String lockId,
                              java.util.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 java.lang.String toString()
Overrides:
toString in class java.lang.Object

deegree 2.5 (2011/06/29 09:44 build-8-official)

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