-
- All Known Implementing Classes:
DefaultLockManager
public interface LockManagerManager 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:
DefaultLockManager
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcleanupUserTokens(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.voidcommit(org.tentackle.dbms.Db session, long txNumber)Notifies the lockmanager that a transaction has been committed.static LockManagergetInstance()The singleton.<T extends org.tentackle.pdo.PersistentDomainObject<T>>
TokenLockgetLock(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.voidinitialize(org.tentackle.dbms.Db session)Initializes the lockmanager.
Called once at server startup to remove all locks.booleanisEnabled()Returns whether the lock manager is enabled.voidrollback(org.tentackle.dbms.Db session, long txNumber)Notifies the lockmanager that a transaction has been rolled back.<T extends org.tentackle.pdo.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 Detail
-
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(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.- Parameters:
session- the session to useuserId- the user id
-
initialize
void initialize(org.tentackle.dbms.Db session)
Initializes the lockmanager.
Called once at server startup to remove all locks.- Parameters:
session- the session to use
-
getLock
<T extends org.tentackle.pdo.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
java.util.Collection<TokenLock> getLocks(long userId)
Gets the token locks for a user.- Parameters:
userId- the user's ID- Returns:
- the token locks
-
getLocks
java.util.Collection<TokenLock> getLocks()
Gets all token locks.- Returns:
- the token locks
-
update
<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.- Type Parameters:
T- the PDO type- Parameters:
pdo- the PDO
-
commit
void commit(org.tentackle.dbms.Db session, long txNumber)Notifies the lockmanager that a transaction has been committed.- Parameters:
session- the sessiontxNumber- the unique transaction number
-
rollback
void rollback(org.tentackle.dbms.Db session, long txNumber)Notifies the lockmanager that a transaction has been rolled back.- Parameters:
session- the sessiontxNumber- the unique transaction number
-
-