- 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 editedBy-tokens 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:
- If a client session crashes, the locks held by the session's user are removed.
- When the server crashes, all locks are removed at server start.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanupUserTokens(Db session, long userId) Removes all tokens for a given user.
The method is invoked when a user logs out or its session crashed.voidNotifies the lockmanager that a transaction has been committed.static LockManagerThe singleton.<T extends PersistentDomainObject<T>>
TokenLockgetLock(T pdo) Gets the token lock for a PDO.getLocks()Gets all token locks.getLocks(long userId) Gets the token locks for a user.voidinitialize(Db session) Initializes the lockmanager.
Called once at server startup to remove all locks.booleanReturns whether the lock manager is enabled.voidNotifies the lockmanager that a transaction has been rolled back.<T extends PersistentDomainObject<T>>
voidupdate(T pdo) Updates the lock token.
The method is invoked from within a transaction after the PDO has been persisted successfully.
-
Method Details
-
getInstance
The singleton.- Returns:
- the singleton
-
isEnabled
boolean isEnabled()Returns whether the lock manager is enabled.- Returns:
- true if server
-
cleanupUserTokens
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 useuserId- the user id
-
initialize
Initializes the lockmanager.
Called once at server startup to remove all locks.- Parameters:
session- the session to use
-
getLock
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
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
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
Notifies the lockmanager that a transaction has been committed.- Parameters:
session- the sessiontxNumber- the unique transaction number
-
rollback
Notifies the lockmanager that a transaction has been rolled back.- Parameters:
session- the sessiontxNumber- the unique transaction number
-