Package tigase.db.util.locker
Class ConnectionLock
java.lang.Object
tigase.db.util.locker.ConnectionLock
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
protected boolean
executeQuery
(Connection connection, String query) static Optional<ConnectionLock>
getConnectionLocker
(String db_conn) boolean
isLocked()
boolean
lock()
protected abstract boolean
lockDatabase
(Connection connection) protected void
boolean
unlock()
protected abstract boolean
unlockDatabase
(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
-Connection
which should hold the lock- Returns:
true
if the locking was successful orfalse
if it wasn't
-
release
-
unlockDatabase
- Parameters:
connection
-Connection
which holds the lock and which should be unlocked- Returns:
true
if the unlocking was successful orfalse
if it wasn't and the lock is still hold
-
executeQuery
-