Skip to content

Commit

Permalink
Provider transaction import operation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Jan 25, 2017
1 parent 5e5b59d commit fa8aa3d
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.PrivilegedAction;
import java.util.function.Supplier;

import javax.transaction.NotSupportedException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.xa.XAException;
Expand Down Expand Up @@ -131,6 +132,26 @@ public ImportResult<LocalTransaction> findOrImportTransaction(Xid xid, int timeo
return new ImportResult<LocalTransaction>(transaction, result.getControl(), result.isNew());
}

/**
* Attempt to import a provider's current transaction as a local transaction.
*
* @return {@code true} if the transaction was associated, {@code false} if the provider had no current transaction
* @throws SystemException if an error occurred acquiring the current transaction from the provider
* @throws NotSupportedException if the thread is already associated with a transaction
*/
public boolean importProviderTransaction() throws SystemException, NotSupportedException {
final ContextTransactionManager.State state = ContextTransactionManager.INSTANCE.getStateRef().get();
if (state.transaction != null) {
throw Log.log.nestedNotSupported();
}
final Transaction transaction = provider.getTransactionManager().getTransaction();
if (transaction == null) {
return false;
}
state.transaction = new LocalTransaction(this, transaction, null);
return true;
}

/**
* Get the recovery interface for this context. The recovery interface can be used to recover transactions which
* were imported into this context via {@link #findOrImportTransaction(Xid, int)}.
Expand Down

0 comments on commit fa8aa3d

Please # to comment.