View Javadoc

1   package com.atlassian.sal.api.transaction;
2   
3   /**
4    * A simple callback that needs to be provided with an action to run in the doInTransaction method.
5    * It is assumed that if anything goes wrong, doInTransaction will throw a RuntimeException if anything goes
6    * wrong, and the calling transactionTemplate will roll back the transaction.
7    *
8    * @since 2.0
9    */
10  public interface TransactionCallback<T>
11  {
12      /**
13       * Runs an action in a transaction and returns a optional value.
14       *
15       * @return Optional result of the operation. May be null
16       * @throws RuntimeException if anything went wrong.  The caller will be responsible for rolling back.
17       */
18      T doInTransaction();
19  }