Package tigase.db.util.locker

# Class ConnectionLock

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

public abstract class ConnectionLock extends Object

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected boolean`
  `isLocked`
  `protected String`
  `jdbcConnection`
  `protected int`
  `lockAttemptDelay`
  `protected int`
  `lockAttemptsLimit`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `ConnectionLock(String db_conn)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `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`
  `release(Statement statement, ResultSet resultSet)`
  `boolean`
  `unlock()`
  `protected abstract boolean`
  `unlockDatabase(Connection connection)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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)