Class DefaultLockManager

    • Constructor Detail

      • DefaultLockManager

        public DefaultLockManager()
        Creates the lock manager.
        Enabled only if running within a server application.
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Description copied from interface: LockManager
        Returns whether the lock manager is enabled.
        Specified by:
        isEnabled in interface LockManager
        Returns:
        true if server
      • cleanupUserTokens

        public void cleanupUserTokens​(Db session,
                                      long userId)
        Description copied from interface: LockManager
        Removes all tokens for a given user.
        The method is invoked when a user logs out or its session crashed.
        Specified by:
        cleanupUserTokens in interface LockManager
        Parameters:
        session - the session to use
        userId - the user id
      • initialize

        public void initialize​(Db session)
        Description copied from interface: LockManager
        Initializes the lockmanager.
        Called once at server startup to remove all locks.
        Specified by:
        initialize in interface LockManager
        Parameters:
        session - the session to use
      • getLock

        public <T extends PersistentDomainObject<T>> TokenLock getLock​(T pdo)
        Description copied from interface: LockManager
        Gets the token lock for a PDO.
        Specified by:
        getLock in interface LockManager
        Type Parameters:
        T - the PDO type
        Parameters:
        pdo - the PDO
        Returns:
        the token lock, null if PDO is not locked
      • getLocks

        public Collection<TokenLock> getLocks​(long userId)
        Description copied from interface: LockManager
        Gets the token locks for a user.
        Specified by:
        getLocks in interface LockManager
        Parameters:
        userId - the user's ID
        Returns:
        the token locks
      • update

        public <T extends PersistentDomainObject<T>> void update​(T pdo)
        Description copied from interface: LockManager
        Updates the lock token.
        The method is invoked from within a transaction after the PDO has been persisted successfully.
        Specified by:
        update in interface LockManager
        Type Parameters:
        T - the PDO type
        Parameters:
        pdo - the PDO
      • rollback

        public void rollback​(Db session,
                             long txNumber)
        Description copied from interface: LockManager
        Notifies the lockmanager that a transaction has been rolled back.
        Specified by:
        rollback in interface LockManager
        Parameters:
        session - the session
        txNumber - the unique transaction number
      • commit

        public void commit​(Db session,
                           long txNumber)
        Description copied from interface: LockManager
        Notifies the lockmanager that a transaction has been committed.
        Specified by:
        commit in interface LockManager
        Parameters:
        session - the session
        txNumber - the unique transaction number
      • remove

        protected void remove​(DbTokenLock lock,
                              DomainContext context)
        Removes a token lock from the lock table and the PDO.
        Parameters:
        lock - the token lock
        context - the application's domain context
      • createTokenLock

        protected DbTokenLock createTokenLock​(Db session)
        Creates a tokenlock persistent object.
        Parameters:
        session - the session
        Returns:
        the PO
      • reloadLocks

        protected void reloadLocks​(Db session)
        Reloads locks from the database into the internal map.
        There must be no transactions running!
        Parameters:
        session - the session