org.deegree.feature.persistence.lock
Class DefaultLockManager

java.lang.Object
  extended by org.deegree.feature.persistence.lock.DefaultLockManager
All Implemented Interfaces:
LockManager

public class DefaultLockManager
extends Object
implements LockManager

LockManager implementation that is based on an SQL database.

TODO Currently this class is only tested with Derby 10, h2, but it should be easy to make it work with PostGIS, Oracle and other SQL DBs.

Version:
$Revision: 28796 $, $Date: 2010-12-16 10:34:09 +0100 (Thu, 16 Dec 2010) $
Author:
Markus Schneider, last edited by: $Author: aschmitz $

Constructor Summary
DefaultLockManager(FeatureStore store, String jdbcConnId)
          Creates a new DefaultLockManager for the given FeatureStore.
 
Method Summary
 Lock acquireLock(LockOperation[] lockRequests, boolean mustLockAll, long expireTimeout)
          Acquires a lock for the specified features instances.
 CloseableIterator<Lock> getActiveLocks()
          Returns all active locks.
 Lock getLock(String lockId)
          Returns the active lock with the given id.
 boolean isFeatureLocked(String fid)
          Returns whether an active lock on the specified feature exists.
 boolean isFeatureModifiable(String fid, String lockId)
          Returns whether the specified feature is modifiable for the owner of the specified lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLockManager

public DefaultLockManager(FeatureStore store,
                          String jdbcConnId)
                   throws FeatureStoreException
Creates a new DefaultLockManager for the given FeatureStore.

Parameters:
store -
jdbcConnId -
Throws:
FeatureStoreException - if the initialization of the locking backend fails
Method Detail

acquireLock

public Lock acquireLock(LockOperation[] lockRequests,
                        boolean mustLockAll,
                        long expireTimeout)
                 throws FeatureStoreException
Description copied from interface: LockManager
Acquires a lock for the specified features instances.

If mustLockAll is true and not all of the specified features can be locked, a FeatureStoreException is 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.).

Specified by:
acquireLock in interface LockManager
Parameters:
lockRequests - lock requests to be executed, must not be null
mustLockAll - if true, a FeatureStoreException is thrown if any of the requested feature instances could not be locked
expireTimeout - number of milliseconds before the lock is automatically released
Returns:
lock identifier, never null
Throws:
FeatureStoreException - if an internal error occurs or if mustLockAll is true and at least one feature could not be locked

getActiveLocks

public CloseableIterator<Lock> getActiveLocks()
Description copied from interface: LockManager
Returns all active locks.

NOTE: The caller must invoke CloseableIterator.close() after it's not needed anymore -- otherwise, backing resources (such as database connections) may not be freed.

Specified by:
getActiveLocks in interface LockManager
Returns:
an iterator for all locks

getLock

public Lock getLock(String lockId)
             throws FeatureStoreException
Description copied from interface: LockManager
Returns the active lock with the given id.

Specified by:
getLock in interface LockManager
Returns:
the active lock with the given id
Throws:
FeatureStoreException

isFeatureLocked

public boolean isFeatureLocked(String fid)
                        throws FeatureStoreException
Description copied from interface: LockManager
Returns whether an active lock on the specified feature exists.

Specified by:
isFeatureLocked in interface LockManager
Parameters:
fid - id of the feature
Returns:
true, if an active lock on the feature exists, false otherwise
Throws:
FeatureStoreException

isFeatureModifiable

public boolean isFeatureModifiable(String fid,
                                   String lockId)
                            throws FeatureStoreException
Description copied from interface: LockManager
Returns whether the specified feature is modifiable for the owner of the specified lock.

Specified by:
isFeatureModifiable in interface LockManager
Parameters:
fid - id of the feature, must not be null
lockId - if of the lock, may be null (in this case the feature is only modifiable if the feature is not locked at all)
Returns:
true, if the feature is not locked at all or the specified lock matches the feature's lock, false otherwise
Throws:
FeatureStoreException


Copyright © 2011. All Rights Reserved.