Interface LockManager

All Known Implementing Classes:
DefaultLockManager

public interface LockManager
Manager for token locks.

The lock manager maintains the state of all token locks in parallel to the token-lock attributes of the PDOs.
This allows to know all locks without the need to scan the PDO tables.

The lock manager is used for 2 purposes:

  1. If a client session crashes, the locks held by the session's user are removed.
  2. When the server crashes, all locks are removed at server start.
Notice that only non-remote servers provide an enabled lock manager. In 2-tier and remote applications the lockmanager is disabled.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cleanupUserTokens(Db session, long userId)
    Removes all tokens for a given user.
    The method is invoked when a user logs out or its session crashed.
    void
    commit(Db session, long txNumber)
    Notifies the lockmanager that a transaction has been committed.
    The singleton.
    getLock(T pdo)
    Gets the token lock for a PDO.
    Gets all token locks.
    getLocks(long userId)
    Gets the token locks for a user.
    void
    initialize(Db session)
    Initializes the lockmanager.
    Called once at server startup to remove all locks.
    boolean
    Returns whether the lock manager is enabled.
    void
    rollback(Db session, long txNumber)
    Notifies the lockmanager that a transaction has been rolled back.
    <T extends PersistentDomainObject<T>>
    void
    update(T pdo)
    Updates the lock token.
    The method is invoked from within a transaction after the PDO has been persisted successfully.
  • Method Details

    • getInstance

      static LockManager getInstance()
      The singleton.
      Returns:
      the singleton
    • isEnabled

      boolean isEnabled()
      Returns whether the lock manager is enabled.
      Returns:
      true if server
    • cleanupUserTokens

      void cleanupUserTokens(Db session, long userId)
      Removes all tokens for a given user.
      The method is invoked when a user logs out or its session crashed.
      Parameters:
      session - the session to use
      userId - the user id
    • initialize

      void initialize(Db session)
      Initializes the lockmanager.
      Called once at server startup to remove all locks.
      Parameters:
      session - the session to use
    • getLock

      <T extends PersistentDomainObject<T>> TokenLock getLock(T pdo)
      Gets the token lock for a PDO.
      Type Parameters:
      T - the PDO type
      Parameters:
      pdo - the PDO
      Returns:
      the token lock, null if PDO is not locked
    • getLocks

      Collection<TokenLock> getLocks(long userId)
      Gets the token locks for a user.
      Parameters:
      userId - the user's ID
      Returns:
      the token locks
    • getLocks

      Collection<TokenLock> getLocks()
      Gets all token locks.
      Returns:
      the token locks
    • update

      <T extends PersistentDomainObject<T>> void update(T pdo)
      Updates the lock token.
      The method is invoked from within a transaction after the PDO has been persisted successfully.
      Type Parameters:
      T - the PDO type
      Parameters:
      pdo - the PDO
    • commit

      void commit(Db session, long txNumber)
      Notifies the lockmanager that a transaction has been committed.
      Parameters:
      session - the session
      txNumber - the unique transaction number
    • rollback

      void rollback(Db session, long txNumber)
      Notifies the lockmanager that a transaction has been rolled back.
      Parameters:
      session - the session
      txNumber - the unique transaction number