Class ConnectionLock

java.lang.Object
tigase.db.util.locker.ConnectionLock

public abstract class ConnectionLock extends Object
  • Field Details

    • isLocked

      protected boolean isLocked
    • jdbcConnection

      protected String jdbcConnection
    • lockAttemptDelay

      protected int lockAttemptDelay
    • lockAttemptsLimit

      protected int lockAttemptsLimit
  • Constructor Details

    • ConnectionLock

      protected ConnectionLock(String db_conn)
  • 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

      protected abstract boolean lockDatabase(Connection connection)
      Parameters:
      connection - Connection which should hold the lock
      Returns:
      true if the locking was successful or false if it wasn't
    • release

      protected void release(Statement statement, ResultSet resultSet)
    • unlockDatabase

      protected abstract boolean unlockDatabase(Connection connection)
      Parameters:
      connection - Connection which holds the lock and which should be unlocked
      Returns:
      true if the unlocking was successful or false if it wasn't and the lock is still hold
    • executeQuery

      protected boolean executeQuery(Connection connection, String query)