Class LockManagerImpl
java.lang.Object
org.datanucleus.state.LockManagerImpl
- All Implemented Interfaces:
LockManager
Implementation of a lock manager for objects.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ExecutionContext(package private) Map<DNStateManager, LockMode> Map of lock mode, keyed by StateManager.Map of lock mode, keyed by the object identity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Method to clear all settings of required lock level.voidclose()Method to close the manager and release resources.getLockMode(Object id) Accessor for what locking should be applied to the object with the specified identity (mode 2).Accessor for the current lock mode for the object managed by the passed StateManager (mode 1).getNextVersion(VersionMetaData vermd, Object currentVersion) Convenience method to provide the next version to use given the VersionMetaData and the current version.voidMethod to lock the object with the provided identity (mode 2).voidlock(DNStateManager sm, LockMode lockMode) Method to lock the object managed by the passed StateManager (mode 1).voidperformOptimisticVersionCheck(DNStateManager sm, VersionStrategy versionStrategy, Object versionDatastore) Perform an optimistic version check on the passed object, against the passed version in the datastore.voidunlock(DNStateManager sm) Method to unlock the object managed by the passed StateManager (mode 1).
-
Field Details
-
ec
-
requiredLockModesById
-
lockModeBySM
Map<DNStateManager, LockMode> lockModeBySMMap of lock mode, keyed by StateManager.
-
-
Constructor Details
-
LockManagerImpl
-
-
Method Details
-
close
public void close()Description copied from interface:LockManagerMethod to close the manager and release resources.- Specified by:
closein interfaceLockManager
-
clear
public void clear()Description copied from interface:LockManagerMethod to clear all settings of required lock level.- Specified by:
clearin interfaceLockManager
-
lock
Description copied from interface:LockManagerMethod to lock the object with the provided identity (mode 2).- Specified by:
lockin interfaceLockManager- Parameters:
id- Identity of the objectlockMode- mode for locking
-
getLockMode
Description copied from interface:LockManagerAccessor for what locking should be applied to the object with the specified identity (mode 2).- Specified by:
getLockModein interfaceLockManager- Parameters:
id- The identity- Returns:
- The lock mode to apply (NONE if nothing defined)
-
lock
Description copied from interface:LockManagerMethod to lock the object managed by the passed StateManager (mode 1).- Specified by:
lockin interfaceLockManager- Parameters:
sm- StateManager for the objectlockMode- mode for locking
-
unlock
Description copied from interface:LockManagerMethod to unlock the object managed by the passed StateManager (mode 1).- Specified by:
unlockin interfaceLockManager- Parameters:
sm- StateManager for the object
-
getLockMode
Description copied from interface:LockManagerAccessor for the current lock mode for the object managed by the passed StateManager (mode 1).- Specified by:
getLockModein interfaceLockManager- Parameters:
sm- StateManager for the object- Returns:
- The lock mode
-
performOptimisticVersionCheck
public void performOptimisticVersionCheck(DNStateManager sm, VersionStrategy versionStrategy, Object versionDatastore) Perform an optimistic version check on the passed object, against the passed version in the datastore.- Specified by:
performOptimisticVersionCheckin interfaceLockManager- Parameters:
sm- StateManager of the object to checkversionStrategy- Version strategyversionDatastore- Version of the object in the datastore- Throws:
NucleusUserException- thrown when an invalid strategy is specifiedNucleusOptimisticException- thrown when the version check fails
-
getNextVersion
Convenience method to provide the next version to use given the VersionMetaData and the current version.- Specified by:
getNextVersionin interfaceLockManager- Parameters:
vermd- Version metadatacurrentVersion- The current version- Returns:
- The next version
- Throws:
NucleusUserException- Thrown if the strategy is not supported.
-