List of usage examples for javax.transaction Status STATUS_ROLLEDBACK
int STATUS_ROLLEDBACK
To view the source code for javax.transaction Status STATUS_ROLLEDBACK.
Click Source Link
From source file:org.exolab.castor.jdo.engine.GlobalDatabaseImpl.java
/** * @inheritDoc//from w w w . j ava2s.c om * @see javax.transaction.Synchronization#afterCompletion(int) */ public void afterCompletion(final int status) { try { // XXX [SMH]: Find another test for txNotInProgress if (_transaction == null || _ctx == null) { throw new IllegalStateException(Messages.message("jdo.txNotInProgress")); } if (_ctx.getStatus() == Status.STATUS_ROLLEDBACK) { return; } if (_ctx.getStatus() != Status.STATUS_PREPARED && status != Status.STATUS_ROLLEDBACK) { throw new IllegalStateException( "Unexpected state: afterCompletion called at status " + _ctx.getStatus()); } switch (status) { case Status.STATUS_COMMITTED: try { _ctx.commit(); } catch (TransactionAbortedException except) { _log.fatal(Messages.format("jdo.fatalException", except)); _ctx.rollback(); } return; case Status.STATUS_ROLLEDBACK: _ctx.rollback(); return; case Status.STATUS_UNKNOWN: _ctx.rollback(); try { DatabaseContext context = DatabaseRegistry.getDatabaseContext(_dbName); TransactionManager transactionManager = context.getTransactionManager(); if (AtomikosTransactionManagerFactory.MANAGER_CLASS_NAME .equals(transactionManager.getClass().getName())) { // Accept 'unknown' as legal state for Atomikos as this state // is returned for read-only transactions. As nothing has changed // during the transaction it doesn't matter if we do a commit or // rollback. The handling of 'unknown' does not comply to J2EE spec. return; } } catch (Exception ex) { _log.fatal(Messages.format("jdo.fatalException", ex)); } throw new IllegalStateException("Unexpected state: afterCompletion called with status " + status); default: _ctx.rollback(); throw new IllegalStateException("Unexpected state: afterCompletion called with status " + status); } } finally { unregisterSynchronizables(); if (_txMap != null && _transaction != null) { _txMap.remove(_transaction); _txMap = null; } } }
From source file:org.firstopen.singularity.util.TransactionManager.java
public void rollback() { log.debug("rollback()"); try {//from ww w . j a va 2 s. co m UserTransaction userTransaction = TransactionUtil.getUserTransaction(); int status = userTransaction.getStatus(); if (status != Status.STATUS_COMMITTED && status != Status.STATUS_ROLLEDBACK) { userTransaction.rollback(); } } catch (Exception e) { log.error("rollback failed!"); throw new InfrastructureException(e); } }
From source file:org.j2free.jpa.Controller.java
/** * Ends the contatiner managed <tt>UserTransaction</tt>, committing * or rolling back as necessary./*ww w .j a v a 2 s.co m*/ * * @throws SystemException * @throws RollbackException * @throws HeuristicMixedException * @throws HeuristicRollbackException */ public void end() throws SystemException, RollbackException, HeuristicMixedException, HeuristicRollbackException { try { switch (tx.getStatus()) { case Status.STATUS_MARKED_ROLLBACK: tx.rollback(); break; case Status.STATUS_ACTIVE: tx.commit(); break; case Status.STATUS_COMMITTED: // somebody called end() twice break; case Status.STATUS_COMMITTING: log.warn("uh oh, concurrency problem! end() called when transaction already committing"); break; case Status.STATUS_ROLLEDBACK: // somebody called end() twice break; case Status.STATUS_ROLLING_BACK: log.warn("uh oh, concurrency problem! end() called when transaction already rolling back"); break; default: throw new IllegalStateException("Unknown status in endTransaction: " + getTransactionStatus()); } problem = null; errors = null; } catch (InvalidStateException ise) { problem = ise; this.errors = ise.getInvalidValues(); } }
From source file:org.j2free.jpa.Controller.java
/** * // w w w.ja v a 2 s .c om * @return * @throws SystemException */ public String getTransactionStatus() throws SystemException { if (tx == null) { return "Null transaction"; } switch (tx.getStatus()) { case Status.STATUS_ACTIVE: return "Active"; case Status.STATUS_COMMITTED: return "Committed"; case Status.STATUS_COMMITTING: return "Committing"; case Status.STATUS_MARKED_ROLLBACK: return "Marked for rollback"; case Status.STATUS_NO_TRANSACTION: return "No Transaction"; case Status.STATUS_PREPARED: return "Prepared"; case Status.STATUS_ROLLEDBACK: return "Rolledback"; case Status.STATUS_ROLLING_BACK: return "Rolling back"; case Status.STATUS_UNKNOWN: return "Declared Unknown"; default: return "Undeclared Unknown Status"; } }
From source file:org.mule.util.xa.AbstractResourceManager.java
public void rollbackTransaction(AbstractTransactionContext context) throws ResourceManagerException { assureReady();//from w w w . j a v a2 s. c o m synchronized (context) { if (logger.isDebugEnabled()) { logger.debug("Rolling back transaction " + context); } try { context.status = Status.STATUS_ROLLING_BACK; doRollback(context); context.status = Status.STATUS_ROLLEDBACK; } catch (Error e) { setDirty(context, e); throw e; } catch (RuntimeException e) { setDirty(context, e); throw e; } catch (ResourceManagerSystemException e) { setDirty(context, e); throw e; } finally { globalTransactions.remove(context); context.finalCleanUp(); // tell shutdown thread this tx is finished context.notifyFinish(); } if (logger.isDebugEnabled()) { logger.debug("Rolled back transaction " + context); } } }
From source file:org.nuxeo.ecm.core.event.impl.EventServiceImpl.java
@Override public void afterCompletion(int status) { if (status == Status.STATUS_COMMITTED) { handleTxCommited();/* w w w . j av a2 s.c om*/ } else if (status == Status.STATUS_ROLLEDBACK) { handleTxRollbacked(); } else { log.error("Unexpected afterCompletion status: " + status); } }
From source file:org.nuxeo.ecm.core.management.jtajca.internal.DefaultTransactionMonitor.java
@Override public void afterCompletion(int code) { DefaultTransactionStatistics stats = thisStatistics(); if (stats == null) { return;//from w w w . j a v a2 s . c o m } stats.endTimestamp = System.currentTimeMillis(); stats.status = TransactionStatistics.Status.fromCode(code); switch (code) { case Status.STATUS_COMMITTED: lastCommittedStatistics = stats; break; case Status.STATUS_ROLLEDBACK: lastRollbackedStatistics = stats; stats.endCapturedContext = new Throwable("** rollback context **"); break; } }
From source file:org.nuxeo.elasticsearch.listener.ElasticSearchInlineListener.java
@Override public void afterCompletion(int status) { if (getAllCommands().isEmpty()) { return;/*from ww w .j a va 2 s . co m*/ } try { if (Status.STATUS_MARKED_ROLLBACK == status || Status.STATUS_ROLLEDBACK == status) { return; } List<IndexingCommand> commandList = new ArrayList<>(); for (IndexingCommands cmds : getAllCommands().values()) { for (IndexingCommand cmd : cmds.getCommands()) { commandList.add(cmd); } } ElasticSearchIndexing esi = Framework.getLocalService(ElasticSearchIndexing.class); esi.runIndexingWorker(commandList); } finally { isEnlisted.set(false); getAllCommands().clear(); useSyncIndexing.set(null); } }
From source file:org.springframework.transaction.jta.SpringJtaSynchronizationAdapter.java
/** * JTA {@code afterCompletion} callback: invoked after commit/rollback. * <p>Needs to invoke the Spring synchronization's {@code beforeCompletion} * at this late stage in case of a rollback, since there is no corresponding * callback with JTA./*from ww w.ja v a 2s .c o m*/ * @see org.springframework.transaction.support.TransactionSynchronization#beforeCompletion * @see org.springframework.transaction.support.TransactionSynchronization#afterCompletion */ @Override public void afterCompletion(int status) { if (!this.beforeCompletionCalled) { // beforeCompletion not called before (probably because of JTA rollback). // Perform the cleanup here. this.springSynchronization.beforeCompletion(); } // Call afterCompletion with the appropriate status indication. switch (status) { case Status.STATUS_COMMITTED: this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_COMMITTED); break; case Status.STATUS_ROLLEDBACK: this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK); break; default: this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_UNKNOWN); } }