public boolean acquire ( final Lock lock ) { lock . setUniqueId ( this . uniqueId ) ; if ( this . lockTimeout > 0 ) { lock . setExpirationDate ( ZonedDateTime . now ( ZoneOffset . UTC ) . plusSeconds ( this . lockTimeout ) ) ; } else { lock . setExpirationDate ( null ) ; } var success = false ; try { if ( lock . getApplicationId ( ) != null ) { this . entityManager . merge ( lock ) ; } else { lock . setApplicationId ( this . applicationId ) ; this . entityManager . persist ( lock ) ; } success = true ; } catch ( final Exception e ) { success = false ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "[{}] could not obtain [{}] lock." , this . uniqueId , this . applicationId , e ) ; } else { LOGGER . info ( "[{}] could not obtain [{}] lock." , this . uniqueId , this . applicationId ) ; } } return success ; }
Acquire the lock object .