public class InProcessLockingManager extends Object implements LockingManager
If at all possible DataStore implementations should provide a real Feature Locking support that is persisted to disk or database and resepected by other processes.
This class provides a stop gap solution that implementations may use for GeoServer compatability.
Modifier and Type | Class and Description |
---|---|
static interface |
InProcessLockingManager.Lock
Represents In-Process locks for Transactions or FeatureLocks.
|
Modifier and Type | Field and Description |
---|---|
protected Map<String,Map<String,InProcessLockingManager.Lock>> |
lockTables
lockTable access by typeName stores Transactions or MemoryLocks
|
Constructor and Description |
---|
InProcessLockingManager() |
Modifier and Type | Method and Description |
---|---|
Set<InProcessLockingManager.Lock> |
allLocks()
Set of all locks.
|
void |
assertAccess(String typeName,
String featureID,
Transaction transaction)
Checks mutability of featureID for this transaction.
|
FeatureWriter<SimpleFeatureType,SimpleFeature> |
checkedWriter(FeatureWriter<SimpleFeatureType,SimpleFeature> writer,
Transaction transaction)
Provides a wrapper on the provided writer that checks locks.
|
protected InProcessLockingManager.Lock |
createLock(Transaction transaction,
FeatureLock featureLock)
Creates the right sort of In-Process Lock.
|
boolean |
exists(String authID)
Implment lockExists.
|
protected InProcessLockingManager.Lock |
getLock(String typeName,
String featureID)
Lock for typeName & featureID if it exists.
|
boolean |
isLocked(String typeName,
String featureID)
Used by test cases
|
void |
lockFeatureID(String typeName,
String featureID,
Transaction transaction,
FeatureLock featureLock)
Aquire lock on featureID.
|
Map<String,InProcessLockingManager.Lock> |
locks(String typeName)
Access to a Map of locks for typeName
|
boolean |
refresh(String authID,
Transaction transaction)
Refresh locks held by the authorization
authID . |
boolean |
release(String authID,
Transaction transaction)
Release locks held by the authorization
authID . |
void |
unLockFeatureID(String typeName,
String featureID,
Transaction transaction,
FeatureLock featureLock)
Release indicated featureID, must have correct authroization.
|
protected Map<String,Map<String,InProcessLockingManager.Lock>> lockTables
public void lockFeatureID(String typeName, String featureID, Transaction transaction, FeatureLock featureLock) throws FeatureLockException
This method will fail if Lock is already held by another.
lockFeatureID
in interface LockingManager
typeName
- TypeName storing featurefeatureID
- FeatureID to locktransaction
- Transaction to lock againstfeatureLock
- FeatureLock describing lock requestFeatureLockException
- Indicates a problem with the lock requestprotected InProcessLockingManager.Lock getLock(String typeName, String featureID)
This method will not return expired locks.
protected InProcessLockingManager.Lock createLock(Transaction transaction, FeatureLock featureLock) throws FeatureLockException
FeatureLockException
- When a Transaction lock is requested against
Transaction.AUTO_COMMITpublic Map<String,InProcessLockingManager.Lock> locks(String typeName)
typeName
- typeNamepublic Set<InProcessLockingManager.Lock> allLocks()
public void assertAccess(String typeName, String featureID, Transaction transaction) throws FeatureLockException
Two behaviors are defined by FeatureLocking:
Right now we are just going to error out with an exception
typeName
- Feature type to check againstfeatureID
- FeatureID to checktransaction
- Provides AuthorizationFeatureLockException
- If transaction does not have sufficient authroizationpublic FeatureWriter<SimpleFeatureType,SimpleFeature> checkedWriter(FeatureWriter<SimpleFeatureType,SimpleFeature> writer, Transaction transaction)
writer
- FeatureWriter requiring access controltransaction
- Transaction being usedpublic void unLockFeatureID(String typeName, String featureID, Transaction transaction, FeatureLock featureLock) throws IOException
unLockFeatureID
in interface LockingManager
IOException
- If lock could not be releasedpublic boolean refresh(String authID, Transaction transaction) throws IOException
authID
.
(remember that the lock may have expired)
refresh
in interface LockingManager
authID
- Authorization identifing Lock to refreshtransaction
- Transaction with authorization for lockIDtrue
if lock was found and refreshedIOException
- If transaction not authorized to refresh authIDIllegalArgumentException
- If authID or transaction not providedpublic boolean release(String authID, Transaction transaction) throws IOException
authID
.
(remember that the lock may have expired)
release
in interface LockingManager
authID
- Authorization identifing Lock to releasetransaction
- Transaction with authorization for lockIDtrue
if lock was found and releasedIOException
- If transaction not authorized to release authIDIllegalArgumentException
- If authID or transaction not providedpublic boolean exists(String authID)
Remeber lock may have expired.
exists
in interface LockingManager
authID
- Authorization for lockorg.geotools.data.LockingManager#lockExists(java.lang.String)
Copyright © 1996–2022 Geotools. All rights reserved.