Package org.datanucleus.state
Class LockManagerImpl
- java.lang.Object
-
- org.datanucleus.state.LockManagerImpl
-
- All Implemented Interfaces:
LockManager
public class LockManagerImpl extends Object implements LockManager
Implementation of a lock manager for objects.
-
-
Constructor Summary
Constructors Constructor Description LockManagerImpl(ExecutionContext ec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Method to clear all settings of required lock level.void
close()
Method to close the manager and release resources.LockMode
getLockMode(Object id)
Accessor for what locking should be applied to the object with the specified identity (mode 2).LockMode
getLockMode(DNStateManager sm)
Accessor for the current lock mode for the object managed by the passed StateManager (mode 1).Object
getNextVersion(VersionMetaData vermd, Object currentVersion)
Convenience method to provide the next version to use given the VersionMetaData and the current version.void
lock(Object id, LockMode lockMode)
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).
-
-
-
Constructor Detail
-
LockManagerImpl
public LockManagerImpl(ExecutionContext ec)
-
-
Method Detail
-
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
public void lock(Object id, LockMode lockMode)
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
public LockMode getLockMode(Object id)
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
public void lock(DNStateManager sm, LockMode lockMode)
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
public void unlock(DNStateManager sm)
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
public LockMode getLockMode(DNStateManager sm)
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
public Object getNextVersion(VersionMetaData vermd, Object currentVersion)
Convenience method to provide the next version to use given the VersionMetaData and the current version.- Specified by:
getNextVersion
in interfaceLockManager
- Parameters:
currentVersion
- The current versionvermd
- Version metadata- Returns:
- The next version
- Throws:
NucleusUserException
- Thrown if the strategy is not supported.
-
-