return threadTransaction.get();
}
public void resume(Transaction tx) throws InvalidTransactionException {
if (tx == null) {
throw new InvalidTransactionException("Transaction is null");
}
if (!(tx instanceof MyTransaction)) {
throw new InvalidTransactionException("Unknown transaction type " + tx.getClass().getName());
}
MyTransaction myTransaction = (MyTransaction) tx;
if (threadTransaction.get() != null) {
throw new IllegalStateException("A transaction is already active");
}
int status = myTransaction.getStatus();
if (status != Status.STATUS_ACTIVE && status != Status.STATUS_MARKED_ROLLBACK) {
throw new InvalidTransactionException("Expected transaction to be STATUS_ACTIVE or STATUS_MARKED_ROLLBACK, but was " + status);
}
threadTransaction.set(myTransaction);
}