@Override protected void doCleanupAfterCompletion(Object txObj) { JTransaction.setCurrent(null); super.doCleanupAfterCompletion(txObj); }
@Override public void afterCompletion(boolean committed) { final JTransaction current; try { current = JTransaction.getCurrent(); } catch (IllegalStateException e) { return; } if (current == this.jtx) JTransaction.setCurrent(null); }
/** * Resume a previously suspended transaction. */ @Override protected void doResume(Object txObj, Object suspendedResources) { // Sanity check if (this.getCurrent() != null) throw new TransactionUsageException("there is already a transaction associated with the current thread"); // Resume transaction final JTransaction jtx = (JTransaction)suspendedResources; if (this.logger.isTraceEnabled()) this.logger.trace("resuming Permazen transaction " + jtx); JTransaction.setCurrent(jtx); }
/** * Suspend the current transaction. */ @Override protected Object doSuspend(Object txObj) { // Sanity check final JTransaction jtx = ((TxWrapper)txObj).getJTransaction(); if (jtx == null) throw new TransactionUsageException("no JTransaction exists in the provided transaction object"); if (jtx != this.getCurrent()) throw new TransactionUsageException("the provided transaction object contains the wrong JTransaction"); // Suspend it if (this.logger.isTraceEnabled()) this.logger.trace("suspending current Permazen transaction " + jtx); JTransaction.setCurrent(null); // Done return jtx; }
try { this.configureTransaction(jtx, txDef); JTransaction.setCurrent(jtx); succeeded = true; } catch (DatabaseException e) { } finally { if (!succeeded) { JTransaction.setCurrent(null); try { jtx.rollback();
@Override protected void doRollback(DefaultTransactionStatus status) { // Is there a transaction? if (!status.hasTransaction()) return; // Get transaction final JTransaction jtx = ((TxWrapper)status.getTransaction()).getJTransaction(); if (jtx == null) throw new NoTransactionException("no current JTransaction exists"); // Rollback try { if (this.logger.isTraceEnabled()) this.logger.trace("rolling back Permazen transaction " + jtx); jtx.rollback(); } catch (StaleTransactionException e) { throw new TransactionTimedOutException("transaction is no longer usable", e); } catch (DatabaseException e) { throw new TransactionSystemException("error committing transaction", e); } finally { JTransaction.setCurrent(null); // transaction is no longer usable } }
@Override protected void doCommit(DefaultTransactionStatus status) { // Is there a transaction? if (!status.hasTransaction()) return; // Get transaction final JTransaction jtx = ((TxWrapper)status.getTransaction()).getJTransaction(); if (jtx == null) throw new NoTransactionException("no current JTransaction exists"); // Commit try { if (this.logger.isTraceEnabled()) this.logger.trace("committing Permazen transaction " + jtx); jtx.commit(); } catch (RetryTransactionException e) { throw new PessimisticLockingFailureException("transaction must be retried", e); } catch (StaleTransactionException e) { throw new TransactionTimedOutException("transaction is no longer usable", e); } catch (DatabaseException e) { throw new TransactionSystemException("error committing transaction", e); } finally { JTransaction.setCurrent(null); // transaction is no longer usable } }
private void cleanupTx(SessionMode mode) { if (mode.compareTo(SessionMode.PERMAZEN) >= 0) { try { JTransaction.getCurrent().rollback(); } catch (IllegalStateException e) { // ignore } JTransaction.setCurrent(null); } if (mode.compareTo(SessionMode.CORE_API) >= 0) { if (this.tx != null) this.tx.rollback(); this.tx = null; } if (mode.compareTo(SessionMode.KEY_VALUE) >= 0) { if (this.kvt != null) this.kvt.rollback(); this.kvt = null; } }
JTransaction.setCurrent(jtx); filterChain.doFilter(request, response); success = true; throw new RuntimeException(t); } finally { JTransaction.setCurrent(null); if (success) { if (jtx.getTransaction().isRollbackOnly())
final JTransaction jtx = this.jdb.createTransaction(this.allowNewSchema, this.validationMode != null ? this.validationMode : ValidationMode.AUTOMATIC, options); JTransaction.setCurrent(jtx); this.tx = jtx.getTransaction(); this.kvt = this.tx.getKVTransaction();