Java Code Examples for javax.transaction.Status#STATUS_ROLLEDBACK
The following examples show how to use
javax.transaction.Status#STATUS_ROLLEDBACK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserTransactionImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = registry.getTransaction(); if (tx == null) throw new SystemException(); if (tx.getStatus() == Status.STATUS_ROLLING_BACK || tx.getStatus() == Status.STATUS_ROLLEDBACK || tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) throw new RollbackException(); registry.commitTransaction(); }
Example 2
Source File: TransactionRecoveryImpl.java From ByteJTA with GNU Lesser General Public License v3.0 | 6 votes |
protected void recoverParticipant(Transaction transaction) throws CommitRequiredException, RollbackRequiredException, SystemException { TransactionImpl transactionImpl = (TransactionImpl) transaction; switch (transaction.getTransactionStatus()) { case Status.STATUS_PREPARED: case Status.STATUS_COMMITTING: break; case Status.STATUS_COMMITTED: case Status.STATUS_ROLLEDBACK: break; case Status.STATUS_ACTIVE: case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARING: case Status.STATUS_UNKNOWN: case Status.STATUS_ROLLING_BACK: default: transactionImpl.recoveryRollback(); transactionImpl.forgetQuietly(); } }
Example 3
Source File: JtaAfterCompletionSynchronization.java From spring-analysis-note with MIT License | 6 votes |
@Override public void afterCompletion(int status) { switch (status) { case Status.STATUS_COMMITTED: try { TransactionSynchronizationUtils.invokeAfterCommit(this.synchronizations); } finally { TransactionSynchronizationUtils.invokeAfterCompletion( this.synchronizations, TransactionSynchronization.STATUS_COMMITTED); } break; case Status.STATUS_ROLLEDBACK: TransactionSynchronizationUtils.invokeAfterCompletion( this.synchronizations, TransactionSynchronization.STATUS_ROLLED_BACK); break; default: TransactionSynchronizationUtils.invokeAfterCompletion( this.synchronizations, TransactionSynchronization.STATUS_UNKNOWN); } }
Example 4
Source File: JackRabbitUserTransaction.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
/** * @see javax.transaction.UserTransaction#rollback */ @Override public void rollback() throws IllegalStateException, SecurityException, SystemException { if (status != Status.STATUS_ACTIVE && status != Status.STATUS_MARKED_ROLLBACK) { throw new IllegalStateException("Transaction not active"); } try { xares.end(xid, XAResource.TMFAIL); status = Status.STATUS_ROLLING_BACK; xares.rollback(xid); status = Status.STATUS_ROLLEDBACK; } catch (XAException e) { final SystemException systemException = new SystemException("Unable to commit transaction: " + "XA_ERR=" + e.errorCode); systemException.initCause(e); throw systemException; } }
Example 5
Source File: SpringJtaSynchronizationAdapter.java From java-technology-stack with MIT License | 6 votes |
/** * 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. * @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); } }
Example 6
Source File: MithraRemoteTransactionProxy.java From reladomo with Apache License 2.0 | 6 votes |
public void rollback() throws MithraTransactionException { if (this.proxyStatus == Status.STATUS_ACTIVE) { this.proxyStatus = Status.STATUS_ROLLING_BACK; this.delistAll(XAResource.TMFAIL); this.rollbackAllXaResources(); this.handleCacheRollback(); this.proxyStatus = Status.STATUS_ROLLEDBACK; this.notificationEvents.clear(); afterCompletion(); } else { throw new MithraTransactionException("Cannot rollback with proxyStatus " + getJtaTransactionStatusDescription(this.proxyStatus)); } }
Example 7
Source File: TransactionImpl.java From ByteJTA with GNU Lesser General Public License v3.0 | 6 votes |
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException { if (this.transactionStatus == Status.STATUS_ACTIVE) { this.fireCommit(); } else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) { this.fireRollback(); throw new HeuristicRollbackException(); } else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ { throw new RollbackException(); } else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ { logger.debug("Current transaction has already been committed."); } else { throw new IllegalStateException(); } }
Example 8
Source File: DefaultTransaction.java From piranha with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Commit the transaction. * * @throws RollbackException when a rollback error occurs. * @throws HeuristicMixedException when the heuristics were mixed. * @throws HeuristicRollbackException when a rollback error occurs. * @throws SecurityException when a security error occurs. * @throws IllegalStateException when the transaction is not active. * @throws SystemException when a serious error occurs. */ @Override public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { handleBeforeCompletion(); try { switch (status) { case Status.STATUS_COMMITTED: break; case Status.STATUS_MARKED_ROLLBACK: { rollback(); throw new HeuristicRollbackException(); } case Status.STATUS_ROLLEDBACK: { throw new RollbackException(); } default: { status = Status.STATUS_COMMITTED; } } } finally { handleAfterCompletion(); } }
Example 9
Source File: PseudoTransactionService.java From tomee with Apache License 2.0 | 5 votes |
public void rollback() { try { doXAResources(Status.STATUS_ROLLEDBACK); doAfterCompletion(Status.STATUS_ROLLEDBACK); status = Status.STATUS_ROLLEDBACK; registeredSynchronizations.clear(); } finally { threadTransaction.set(null); } }
Example 10
Source File: DocumentLinkServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void tearDown() throws Exception { try { if (txn.getStatus() != Status.STATUS_ROLLEDBACK && txn.getStatus() != Status.STATUS_COMMITTED) { txn.rollback(); } } catch (Throwable e) { e.printStackTrace(); } }
Example 11
Source File: MockTransactionManagerService.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public void setRollbackOnly() { switch (txStatus) { case Status.STATUS_ACTIVE: case Status.STATUS_MARKED_ROLLBACK: txStatus = Status.STATUS_MARKED_ROLLBACK; break; case Status.STATUS_ROLLEDBACK: break; default : throw new TransactionManagementException(new IllegalStateException("no mock-tx on current thread")); } }
Example 12
Source File: CompensableTransactionImpl.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public synchronized void rollback() throws IllegalStateException, SystemException { if (this.transactionStatus == Status.STATUS_UNKNOWN) { throw new IllegalStateException(); } else if (this.transactionStatus == Status.STATUS_NO_TRANSACTION) { throw new IllegalStateException(); } else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ { throw new IllegalStateException(); } else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ { logger.debug("Current transaction has already been rolled back."); } else { this.fireRollback(); } }
Example 13
Source File: JtaTransactionContext.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void afterCompletion(int status) { if(Status.STATUS_ROLLEDBACK == status && TransactionState.ROLLED_BACK.equals(transactionState)) { transactionListener.execute(commandContext); } else if(Status.STATUS_COMMITTED == status && TransactionState.COMMITTED.equals(transactionState)) { transactionListener.execute(commandContext); } }
Example 14
Source File: JtaTransactionObject.java From spring-analysis-note with MIT License | 5 votes |
/** * This implementation checks the UserTransaction's rollback-only flag. */ @Override public boolean isRollbackOnly() { try { int jtaStatus = this.userTransaction.getStatus(); return (jtaStatus == Status.STATUS_MARKED_ROLLBACK || jtaStatus == Status.STATUS_ROLLEDBACK); } catch (SystemException ex) { throw new TransactionSystemException("JTA failure on getStatus", ex); } }
Example 15
Source File: JtaTransactionObject.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * This implementation checks the UserTransaction's rollback-only flag. */ @Override public boolean isRollbackOnly() { if (this.userTransaction == null) { return false; } try { int jtaStatus = this.userTransaction.getStatus(); return (jtaStatus == Status.STATUS_MARKED_ROLLBACK || jtaStatus == Status.STATUS_ROLLEDBACK); } catch (SystemException ex) { throw new TransactionSystemException("JTA failure on getStatus", ex); } }
Example 16
Source File: AbstractTransactionalConnectionListener.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public void afterCompletion(int status) { if (!cancel) { log.tracef("afterCompletion(%s): %s", status, AbstractTransactionalConnectionListener.this); // "Delist" transactionSynchronization = null; enlisted = false; if (connectionHandles.isEmpty()) { if (Tracer.isEnabled() && status == Status.STATUS_ROLLEDBACK) Tracer.delistConnectionListener(cm.getPool().getConfiguration().getId(), getManagedConnectionPool(), AbstractTransactionalConnectionListener.this, "", true, true, false); cm.returnConnectionListener(AbstractTransactionalConnectionListener.this, false); } else { if (cm.getConnectionManagerConfiguration().isTracking() == null || cm.getConnectionManagerConfiguration().isTracking().booleanValue()) { log.activeHandles(cm.getPool().getConfiguration().getId(), connectionHandles.size()); if (connectionTraces != null) { Iterator<Map.Entry<Object, Exception>> it = connectionTraces.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Object, Exception> entry = it.next(); log.activeHandle(entry.getKey(), entry.getValue()); } log.txConnectionListenerBoundary(new Exception()); } if (Tracer.isEnabled()) { for (Object c : connectionHandles) { Tracer.clearConnection(cm.getPool().getConfiguration().getId(), getManagedConnectionPool(), AbstractTransactionalConnectionListener.this, c); } } cm.returnConnectionListener(AbstractTransactionalConnectionListener.this, true); } else { log.tracef(new Exception("Connection across boundary"), "ConnectionListener=%s", AbstractTransactionalConnectionListener.this); } } } }
Example 17
Source File: SpringAwareUserTransaction.java From alfresco-core with GNU Lesser General Public License v3.0 | 4 votes |
public synchronized void rollback() throws IllegalStateException, SecurityException, SystemException { // perform checks TransactionInfo txnInfo = getTransactionInfo(); int status = getStatus(); // check the status if (status == Status.STATUS_ROLLING_BACK || status == Status.STATUS_ROLLEDBACK) { throw new IllegalStateException("The transaction has already been rolled back"); } else if (status == Status.STATUS_COMMITTING || status == Status.STATUS_COMMITTED) { throw new IllegalStateException("The transaction has already been committed"); } else if (txnInfo == null) { throw new IllegalStateException("No user transaction is active"); } if (!finalized) { try { // force a rollback by generating an exception that will trigger a rollback completeTransactionAfterThrowing(txnInfo, new Exception()); } finally { // make sure that we clean up the stack cleanupTransactionInfo(txnInfo); finalized = true; // clean up leaked transaction logging isBeginMatched = true; beginCallStack = null; } } // the internal status notes that we were specifically rolled back internalStatus = Status.STATUS_ROLLEDBACK; // done if (logger.isDebugEnabled()) { logger.debug("Rolled back user transaction: " + this); } }
Example 18
Source File: SpringAwareUserTransactionTest.java From alfresco-core with GNU Lesser General Public License v3.0 | 4 votes |
protected void doRollback(DefaultTransactionStatus arg0) { status = Status.STATUS_ROLLEDBACK; }
Example 19
Source File: SpringAwareUserTransaction.java From alfresco-core with GNU Lesser General Public License v3.0 | 4 votes |
/** * @throws IllegalStateException if a transaction was not started */ public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { // perform checks TransactionInfo txnInfo = getTransactionInfo(); int status = getStatus(); // check the status if (status == Status.STATUS_NO_TRANSACTION) { throw new IllegalStateException("The transaction has not yet begun"); } else if (status == Status.STATUS_ROLLING_BACK || status == Status.STATUS_ROLLEDBACK) { throw new RollbackException("The transaction has already been rolled back"); } else if (status == Status.STATUS_MARKED_ROLLBACK) { throw new RollbackException("The transaction has already been marked for rollback"); } else if (status == Status.STATUS_COMMITTING || status == Status.STATUS_COMMITTED) { throw new IllegalStateException("The transaction has already been committed"); } else if (status != Status.STATUS_ACTIVE || txnInfo == null) { throw new IllegalStateException("No user transaction is active"); } if (!finalized) { try { // the status seems correct - we can try a commit commitTransactionAfterReturning(txnInfo); } catch (Throwable e) { if (logger.isDebugEnabled()) { logger.debug("Transaction didn't commit", e); } // commit failed internalStatus = Status.STATUS_ROLLEDBACK; RollbackException re = new RollbackException("Transaction didn't commit: " + e.getMessage()); // Stick the originating reason for failure into the exception. re.initCause(e); throw re; } finally { // make sure that we clean up the stack cleanupTransactionInfo(txnInfo); finalized = true; // clean up leaked transaction logging isBeginMatched = true; beginCallStack = null; } } // regardless of whether the transaction was finally committed or not, the status // as far as UserTransaction is concerned should be 'committed' // keep track that this UserTransaction was explicitly committed internalStatus = Status.STATUS_COMMITTED; // done if (logger.isDebugEnabled()) { logger.debug("Committed user transaction: " + this); } }
Example 20
Source File: CompensableTransactionImpl.java From ByteTCC with GNU Lesser General Public License v3.0 | 3 votes |
public synchronized void participantRollback() throws IllegalStateException, SystemException { // Recover if transaction is recovered from tx-log. this.recoverIfNecessary(); if (this.transactionStatus != Status.STATUS_ROLLEDBACK) { this.fireRollback(); // TODO } }