Class DefaultLockManager

    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultLockManager()
      Creates the lock manager.
      Enabled only if running within a server application.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanupUserTokens​(org.tentackle.dbms.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​(org.tentackle.dbms.Db session, long txNumber)
      Notifies the lockmanager that a transaction has been committed.
      protected DbTokenLock createTokenLock​(org.tentackle.dbms.Db session)
      Creates a tokenlock persistent object.
      <T extends org.tentackle.pdo.PersistentDomainObject<T>>
      TokenLock
      getLock​(T pdo)
      Gets the token lock for a PDO.
      java.util.Collection<TokenLock> getLocks()
      Gets all token locks.
      java.util.Collection<TokenLock> getLocks​(long userId)
      Gets the token locks for a user.
      void initialize​(org.tentackle.dbms.Db session)
      Initializes the lockmanager.
      Called once at server startup to remove all locks.
      boolean isEnabled()
      Returns whether the lock manager is enabled.
      protected void reloadLocks​(org.tentackle.dbms.Db session)
      Reloads locks from the database into the internal map.
      There must be no transactions running!
      protected void remove​(DbTokenLock lock, org.tentackle.pdo.DomainContext context)
      Removes a token lock from the lock table and the PDO.
      void rollback​(org.tentackle.dbms.Db session, long txNumber)
      Notifies the lockmanager that a transaction has been rolled back.
      <T extends org.tentackle.pdo.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(org.tentackle.dbms.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​(org.tentackle.dbms.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 org.tentackle.pdo.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 java.util.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
      • getLocks

        public java.util.Collection<TokenLock> getLocks()
        Description copied from interface: LockManager
        Gets all token locks.
        Specified by:
        getLocks in interface LockManager
        Returns:
        the token locks
      • update

        public <T extends org.tentackle.pdo.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​(org.tentackle.dbms.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​(org.tentackle.dbms.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,
                              org.tentackle.pdo.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​(org.tentackle.dbms.Db session)
        Creates a tokenlock persistent object.
        Parameters:
        session - the session
        Returns:
        the PO
      • reloadLocks

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