BitronixTransaction currentTx = getCurrentTransaction();
if (currentTx != null)
throw new NotSupportedException("nested transactions not supported");
currentTx = createTransaction();
ThreadContext threadContext = ThreadContext.getThreadContext();
ClearContextSynchronization clearContextSynchronization = new ClearContextSynchronization(currentTx, threadContext);
try {
currentTx.getSynchronizationScheduler().add(clearContextSynchronization, Scheduler.ALWAYS_LAST_POSITION -1);
currentTx.setActive(threadContext.getTimeout());
inFlightTransactions.put(currentTx, clearContextSynchronization);
if (log.isDebugEnabled()) { log.debug("begun new transaction at " + new Date(currentTx.getResourceManager().getGtrid().extractTimestamp())); }
} catch (RuntimeException ex) {
clearContextSynchronization.afterCompletion(Status.STATUS_NO_TRANSACTION);
throw ex;