Class ReadOnlyAndReadWriteTransactionConversionTemplate<T>

java.lang.Object
com.atlassian.confluence.impl.transaction.ReadOnlyAndReadWriteTransactionConversionTemplate<T>

public class ReadOnlyAndReadWriteTransactionConversionTemplate<T> extends Object
Provides methods for changing between read/write and readonly transactions.
Since:
9.0
  • Constructor Details

    • ReadOnlyAndReadWriteTransactionConversionTemplate

      public ReadOnlyAndReadWriteTransactionConversionTemplate(org.springframework.transaction.PlatformTransactionManager transactionManager)
  • Method Details

    • executeInReadOnly

      public T executeInReadOnly(Supplier<T> callback)
      Since:
      9.1
    • executeInReadOnly

      public T executeInReadOnly(Supplier<T> inReadOnlyCallback, Supplier<T> notInReadOnlyCallback)
      Checks if the current transaction is in readonly mode, and creates a new transaction in readonly mode if not.
      Parameters:
      inReadOnlyCallback - To be executed if the current transaction is in readonly mode.
      notInReadOnlyCallback - To be executed in a new read only transaction if the current transaction is not in readonly mode.
      Returns:
      the result of the callback.
    • executeInReadWrite

      public T executeInReadWrite(Supplier<T> callback)
      Checks if the current transaction is in read/write mode, and creates a new transaction in read/write mode if not.
      Parameters:
      callback - to be executed in the transaction.
      Returns:
      the result of the callback.