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 voidclear()Method to clear all settings of required lock level.voidclose()Method to close the manager and release resources.LockModegetLockMode(Object id)Accessor for what locking should be applied to the object with the specified identity (mode 2).LockModegetLockMode(DNStateManager sm)Accessor for the current lock mode for the object managed by the passed StateManager (mode 1).ObjectgetNextVersion(VersionMetaData vermd, Object currentVersion)Convenience method to provide the next version to use given the VersionMetaData and the current version.voidlock(Object id, LockMode lockMode)Method 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).
-
-
-
Constructor Detail
-
LockManagerImpl
public LockManagerImpl(ExecutionContext ec)
-
-
Method Detail
-
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
public void lock(Object id, LockMode lockMode)
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
public LockMode getLockMode(Object id)
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
public void lock(DNStateManager sm, LockMode lockMode)
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
public void unlock(DNStateManager sm)
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
public LockMode getLockMode(DNStateManager sm)
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
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:
getNextVersionin interfaceLockManager- Parameters:
currentVersion- The current versionvermd- Version metadata- Returns:
- The next version
- Throws:
NucleusUserException- Thrown if the strategy is not supported.
-
-