Package tigase.db.util.locker
Class ConnectionLock
java.lang.Object
tigase.db.util.locker.ConnectionLock
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()protected booleanexecuteQuery(Connection connection, String query) static Optional<ConnectionLock> getConnectionLocker(String db_conn) booleanisLocked()booleanlock()protected abstract booleanlockDatabase(Connection connection) protected voidbooleanunlock()protected abstract booleanunlockDatabase(Connection connection)
-
Field Details
-
isLocked
protected boolean isLocked -
jdbcConnection
-
lockAttemptDelay
protected int lockAttemptDelay -
lockAttemptsLimit
protected int lockAttemptsLimit
-
-
Constructor Details
-
ConnectionLock
-
-
Method Details
-
getConnectionLocker
public static Optional<ConnectionLock> getConnectionLocker(String db_conn) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
lock
public boolean lock() -
unlock
public boolean unlock() -
cleanup
public void cleanup() -
isLocked
public boolean isLocked() -
lockDatabase
- Parameters:
connection-Connectionwhich should hold the lock- Returns:
trueif the locking was successful orfalseif it wasn't
-
release
-
unlockDatabase
- Parameters:
connection-Connectionwhich holds the lock and which should be unlocked- Returns:
trueif the unlocking was successful orfalseif it wasn't and the lock is still hold
-
executeQuery
-