Package org.datanucleus.state
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 TypeMethodDescriptionvoid
clear()
Method to clear all settings of required lock level.void
close()
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.void
Method to lock the object with the provided identity (mode 2).void
lock
(DNStateManager sm, LockMode lockMode) Method to lock the object managed by the passed StateManager (mode 1).void
performOptimisticVersionCheck
(DNStateManager sm, VersionStrategy versionStrategy, Object versionDatastore) Perform an optimistic version check on the passed object, against the passed version in the datastore.void
unlock
(DNStateManager sm) Method to unlock the object managed by the passed StateManager (mode 1).
-
Field Details
-
ec
-
requiredLockModesById
Map of lock mode, keyed by the object identity. Utilised on a find operation. -
lockModeBySM
Map<DNStateManager,LockMode> lockModeBySMMap of lock mode, keyed by StateManager.
-
-
Constructor Details
-
LockManagerImpl
-
-
Method Details
-
close
public void close()Description copied from interface:LockManager
Method to close the manager and release resources.- Specified by:
close
in interfaceLockManager
-
clear
public void clear()Description copied from interface:LockManager
Method to clear all settings of required lock level.- Specified by:
clear
in interfaceLockManager
-
lock
Description copied from interface:LockManager
Method to lock the object with the provided identity (mode 2).- Specified by:
lock
in interfaceLockManager
- Parameters:
id
- Identity of the objectlockMode
- mode for locking
-
getLockMode
Description copied from interface:LockManager
Accessor for what locking should be applied to the object with the specified identity (mode 2).- Specified by:
getLockMode
in interfaceLockManager
- Parameters:
id
- The identity- Returns:
- The lock mode to apply (NONE if nothing defined)
-
lock
Description copied from interface:LockManager
Method to lock the object managed by the passed StateManager (mode 1).- Specified by:
lock
in interfaceLockManager
- Parameters:
sm
- StateManager for the objectlockMode
- mode for locking
-
unlock
Description copied from interface:LockManager
Method to unlock the object managed by the passed StateManager (mode 1).- Specified by:
unlock
in interfaceLockManager
- Parameters:
sm
- StateManager for the object
-
getLockMode
Description copied from interface:LockManager
Accessor for the current lock mode for the object managed by the passed StateManager (mode 1).- Specified by:
getLockMode
in 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:
performOptimisticVersionCheck
in 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:
getNextVersion
in interfaceLockManager
- Parameters:
vermd
- Version metadatacurrentVersion
- The current version- Returns:
- The next version
- Throws:
NucleusUserException
- Thrown if the strategy is not supported.
-