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.
    1. 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).
    2. 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.
    The LockManager controls all aspects of what objects need any form of locking, the updates to versions, and version checking (optimistic locking).
    • 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 object
        lockMode - 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 object
        lockMode - 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 - StateManager
        versionStrategy - The version strategy in use
        versionDatastore - 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 metadata
        currentVersion - The current version
        Returns:
        The next version
        Throws:
        NucleusUserException - Thrown if the strategy is not supported.