Package org.datanucleus.state
Interface LockManager
-
- All Known Implementing Classes:
LockManagerImpl
public interface LockManager
Interface defining a manager for locking of objects. There are currently two modes to a LockManager.- Where the user has the object and wants it locking. In this case they provide StateManager and we lock it (by a call to the datastore where appropriate).
- Where the user wants to do a find of an object with a particular id. In this case we register the identity as needing this lock level, and the datastore will be called to retrieve the object and will check back what lock level to use.
-
-
Method Summary
All Methods Instance Methods Abstract 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)
Method to perform an optimistic version check on the specified StateManager.void
unlock(DNStateManager sm)
Method to unlock the object managed by the passed StateManager (mode 1).
-
-
-
Method Detail
-
lock
void lock(DNStateManager sm, LockMode lockMode)
Method to lock the object managed by the passed StateManager (mode 1).- Parameters:
sm
- StateManager for the objectlockMode
- mode for locking
-
unlock
void unlock(DNStateManager sm)
Method to unlock the object managed by the passed StateManager (mode 1).- Parameters:
sm
- StateManager for the object
-
getLockMode
LockMode getLockMode(DNStateManager sm)
Accessor for the current lock mode for the object managed by the passed StateManager (mode 1).- Parameters:
sm
- StateManager for the object- Returns:
- The lock mode
-
lock
void lock(Object id, LockMode lockMode)
Method to lock the object with the provided identity (mode 2).- Parameters:
id
- Identity of the objectlockMode
- mode for locking
-
getLockMode
LockMode getLockMode(Object id)
Accessor for what locking should be applied to the object with the specified identity (mode 2).- Parameters:
id
- The identity- Returns:
- The lock mode to apply (NONE if nothing defined)
-
clear
void clear()
Method to clear all settings of required lock level.
-
close
void close()
Method to close the manager and release resources.
-
performOptimisticVersionCheck
void performOptimisticVersionCheck(DNStateManager sm, VersionStrategy versionStrategy, Object versionDatastore)
Method to perform an optimistic version check on the specified StateManager.- Parameters:
sm
- StateManagerversionStrategy
- The version strategy in useversionDatastore
- Version of the object in the datastore
-
getNextVersion
Object getNextVersion(VersionMetaData vermd, Object currentVersion)
Convenience method to provide the next version to use given the VersionMetaData and the current version.- Parameters:
vermd
- Version metadatacurrentVersion
- The current version- Returns:
- The next version
- Throws:
NucleusUserException
- Thrown if the strategy is not supported.
-
-