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.
  • Field Details

  • Constructor Details

  • Method Details

    • close

      public void close()
      Description copied from interface: LockManager
      Method to close the manager and release resources.
      Specified by:
      close in interface LockManager
    • clear

      public void clear()
      Description copied from interface: LockManager
      Method to clear all settings of required lock level.
      Specified by:
      clear in interface LockManager
    • 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 interface LockManager
      Parameters:
      id - Identity of the object
      lockMode - 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 interface LockManager
      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 interface LockManager
      Parameters:
      sm - StateManager for the object
      lockMode - 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 interface LockManager
      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 interface LockManager
      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 interface LockManager
      Parameters:
      sm - StateManager of the object to check
      versionStrategy - Version strategy
      versionDatastore - Version of the object in the datastore
      Throws:
      NucleusUserException - thrown when an invalid strategy is specified
      NucleusOptimisticException - 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 interface LockManager
      Parameters:
      vermd - Version metadata
      currentVersion - The current version
      Returns:
      The next version
      Throws:
      NucleusUserException - Thrown if the strategy is not supported.