Class ConnectionLock


  • public abstract class ConnectionLock
    extends java.lang.Object
    • Field Detail

      • isLocked

        protected boolean isLocked
      • jdbcConnection

        protected java.lang.String jdbcConnection
      • lockAttemptDelay

        protected int lockAttemptDelay
      • lockAttemptsLimit

        protected int lockAttemptsLimit
    • Constructor Detail

      • ConnectionLock

        protected ConnectionLock​(java.lang.String db_conn)
    • Method Detail

      • getConnectionLocker

        public static java.util.Optional<ConnectionLock> getConnectionLocker​(java.lang.String db_conn)
                                                                      throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • lock

        public boolean lock()
      • unlock

        public boolean unlock()
      • cleanup

        public void cleanup()
      • isLocked

        public boolean isLocked()
      • lockDatabase

        protected abstract boolean lockDatabase​(java.sql.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​(java.sql.Statement statement,
                               java.sql.ResultSet resultSet)
      • unlockDatabase

        protected abstract boolean unlockDatabase​(java.sql.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​(java.sql.Connection connection,
                                       java.lang.String query)