@Override protected ThreadContext initialValue() { return new ThreadContext(); } };
@Override protected ThreadContext initialValue() { return new ThreadContext(); } };
/** * Get the context attached to the current thread. If there is no current context, a new one is created. * @return the context. */ private ThreadContext getOrCreateCurrentContext() { ThreadContext threadContext = contexts.get(Thread.currentThread()); if (threadContext == null) { if (log.isDebugEnabled()) log.debug("creating new thread context"); threadContext = new ThreadContext(); setCurrentContext(threadContext); } return threadContext; }
/** * Get the context attached to the current thread. If there is no current context, a new one is created. * @return the context. */ private ThreadContext getOrCreateCurrentContext() { ThreadContext threadContext = contexts.get(Thread.currentThread()); if (threadContext == null) { if (log.isDebugEnabled()) log.debug("creating new thread context"); threadContext = new ThreadContext(); setCurrentContext(threadContext); } return threadContext; }
public void resume(Transaction transaction) throws InvalidTransactionException, IllegalStateException, SystemException { if (log.isDebugEnabled()) log.debug("resuming " + transaction); if (transaction == null) throw new InvalidTransactionException("resumed transaction cannot be null"); if (!(transaction instanceof BitronixTransaction)) throw new InvalidTransactionException("resumed transaction must be an instance of BitronixTransaction"); BitronixTransaction tx = (BitronixTransaction) transaction; BitronixTransaction currentTx = getCurrentTransaction(); if (currentTx != null) throw new IllegalStateException("a transaction is already running on this thread"); try { XAResourceManager resourceManager = tx.getResourceManager(); resourceManager.resume(); ThreadContext ctx = new ThreadContext(); ctx.setTransaction(tx); setCurrentContext(ctx); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); throw new BitronixSystemException("cannot resume " + tx + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } }
public void resume(Transaction transaction) throws InvalidTransactionException, IllegalStateException, SystemException { if (log.isDebugEnabled()) log.debug("resuming " + transaction); if (transaction == null) throw new InvalidTransactionException("resumed transaction cannot be null"); if (!(transaction instanceof BitronixTransaction)) throw new InvalidTransactionException("resumed transaction must be an instance of BitronixTransaction"); BitronixTransaction tx = (BitronixTransaction) transaction; BitronixTransaction currentTx = getCurrentTransaction(); if (currentTx != null) throw new IllegalStateException("a transaction is already running on this thread"); try { XAResourceManager resourceManager = tx.getResourceManager(); resourceManager.resume(); ThreadContext ctx = new ThreadContext(); ctx.setTransaction(tx); setCurrentContext(ctx); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); throw new BitronixSystemException("cannot resume " + tx + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } }