Package ghidra.util.database

# Interface DomainObjectLockHold

All Superinterfaces:
  `AutoCloseable`

All Known Implementing Classes:
  `DomainObjectLockHold.DefaultHold`

public interface DomainObjectLockHold extends AutoCloseable
A hold on the lock for a domain object, obtained via `lock(DomainObject, String)` or `forceLock(DomainObject, boolean, String)`

This is designed for use in a `try-with-resources` block to ensure the timely release of the lock even in exceptional conditions, as in:

     try (DomainObjectLockHold hold = DomainObjectLockHold.lock("Demonstration")) {
            // Do stuff while holding the lock
     }

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `DomainObjectLockHold.DefaultHold`

- ## Method Summary

  Static Methods
  Modifier and Type
  Method
  Description
  `static DomainObjectLockHold`
  `forceLock(DomainObject object, boolean rollback, String reason)`
  Wrapper for `DomainObject.forceLock(boolean, String)`
  `static DomainObjectLockHold`
  `lock(DomainObject object, String reason)`
  Wrapper for `DomainObject.lock(String)`

  ### Methods inherited from interface java.lang.AutoCloseable

  `close`

- ## Method Details

  - ### lock

    static DomainObjectLockHold lock(DomainObject object, String reason)
    Wrapper for `DomainObject.lock(String)`
    Parameters:
      `object` - the object
      `reason` - as in `DomainObject.lock(String)`
    Returns:
      the hold, which should be used in a `try-with-resources` block
    Throws:
      `DomainObjectLockedException` - if the lock could not be obtained

  - ### forceLock

    static DomainObjectLockHold forceLock(DomainObject object, boolean rollback, String reason)
    Wrapper for `DomainObject.forceLock(boolean, String)`
    Parameters:
      `object` - the object
      `rollback` - as in `DomainObject.forceLock(boolean, String)`
      `reason` - as in `DomainObject.forceLock(boolean, String)`
    Returns:
      the hold, which should be used in a `try-with-resources` block