Refine search
Object suspendedResources = suspend(transaction); boolean newSynchronization = (getTransactionSynchronization() == SYNCHRONIZATION_ALWAYS); return prepareTransactionStatus( definition, null, false, newSynchronization, debugEnabled, suspendedResources); SuspendedResourcesHolder suspendedResources = suspend(transaction); try { boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); DefaultTransactionStatus status = newTransactionStatus( definition, transaction, true, newSynchronization, debugEnabled, suspendedResources); doBegin(transaction, definition); prepareSynchronization(status, definition); return status; resumeAfterBeginException(transaction, suspendedResources, beginEx); throw beginEx; if (!isNestedTransactionAllowed()) { throw new NestedTransactionNotSupportedException( "Transaction manager does not allow nested transactions by default - " + if (useSavepointForNestedTransaction()) { prepareTransactionStatus(definition, transaction, false, false, debugEnabled, null); status.createAndHoldSavepoint(); return status; boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); DefaultTransactionStatus status = newTransactionStatus(
/** * Clean up after completion, clearing synchronization if necessary, * and invoking doCleanupAfterCompletion. * @param status object representing the transaction * @see #doCleanupAfterCompletion */ private void cleanupAfterCompletion(DefaultTransactionStatus status) { status.setCompleted(); if (status.isNewSynchronization()) { TransactionSynchronizationManager.clear(); } if (status.isNewTransaction()) { doCleanupAfterCompletion(status.getTransaction()); } if (status.getSuspendedResources() != null) { if (status.isDebug()) { logger.debug("Resuming suspended transaction after completion of inner transaction"); } Object transaction = (status.hasTransaction() ? status.getTransaction() : null); resume(transaction, (SuspendedResourcesHolder) status.getSuspendedResources()); } }
prepareForCommit(status); triggerBeforeCommit(status); triggerBeforeCompletion(status); beforeCompletionInvoked = true; doCommit(status); else if (isFailEarlyOnGlobalRollbackOnly()) { unexpectedRollback = status.isGlobalRollbackOnly(); triggerAfterCompletion(status, TransactionSynchronization.STATUS_ROLLED_BACK); throw ex; if (isRollbackOnCommitFailure()) { doRollbackOnCommitException(status, ex); triggerAfterCompletion(status, TransactionSynchronization.STATUS_UNKNOWN); triggerBeforeCompletion(status); doRollbackOnCommitException(status, ex); throw ex; triggerAfterCommit(status); triggerAfterCompletion(status, TransactionSynchronization.STATUS_COMMITTED); cleanupAfterCompletion(status);
/** * Resume the given transaction. Delegates to the {@code doResume} * template method first, then resuming transaction synchronization. * @param transaction the current transaction object * @param resourcesHolder the object that holds suspended resources, * as returned by {@code suspend} (or {@code null} to just * resume synchronizations, if any) * @see #doResume * @see #suspend */ protected final void resume(@Nullable Object transaction, @Nullable SuspendedResourcesHolder resourcesHolder) throws TransactionException { if (resourcesHolder != null) { Object suspendedResources = resourcesHolder.suspendedResources; if (suspendedResources != null) { doResume(transaction, suspendedResources); } List<TransactionSynchronization> suspendedSynchronizations = resourcesHolder.suspendedSynchronizations; if (suspendedSynchronizations != null) { TransactionSynchronizationManager.setActualTransactionActive(resourcesHolder.wasActive); TransactionSynchronizationManager.setCurrentTransactionIsolationLevel(resourcesHolder.isolationLevel); TransactionSynchronizationManager.setCurrentTransactionReadOnly(resourcesHolder.readOnly); TransactionSynchronizationManager.setCurrentTransactionName(resourcesHolder.name); doResumeSynchronization(suspendedSynchronizations); } } }
public void rollback(boolean transactionOwner) { try { if (transactionOwner) { this.ptm.rollback(currentTransaction); currentTransaction = null; if (TransactionSynchronizationManager.hasResource(KieSpringTransactionManager.RESOURCE_CONTAINER)) { TransactionSynchronizationManager.unbindResource(KieSpringTransactionManager.RESOURCE_CONTAINER); } } } catch (Exception e) { logger.warn("Unable to rollback transaction", e); throw new RuntimeException("Unable to rollback transaction", e); } }
public void commit(boolean transactionOwner) { if (transactionOwner) { try { // if we didn't begin this transaction, then do nothing this.ptm.commit(currentTransaction); currentTransaction = null; if (TransactionSynchronizationManager.hasResource(KieSpringTransactionManager.RESOURCE_CONTAINER)) { TransactionSynchronizationManager.unbindResource(KieSpringTransactionManager.RESOURCE_CONTAINER); } } catch (Exception e) { logger.warn("Unable to commit transaction", e); throw new RuntimeException("Unable to commit transaction", e); } } }
logger.debug( "Current TX name (According to TransactionSynchronizationManager) : " + TransactionSynchronizationManager.getCurrentTransactionName() ); if ( TransactionSynchronizationManager.isActualTransactionActive() ) { TransactionStatus transaction = null; try { if ( currentTransaction == null ) { transaction = ptm.getTransaction( td ); if ( transaction.isNewTransaction() ) { return TransactionManager.STATUS_COMMITTED; ptm.commit( transaction );
/** * Resume the given transaction. Delegates to the <code>doResume</code> * template method first, then resuming transaction synchronization. * @param transaction the current transaction object * @param resourcesHolder the object that holds suspended resources, * as returned by suspend * @see #doResume * @see #suspend */ private void resume(Object transaction, SuspendedResourcesHolder resourcesHolder) throws TransactionException { if (resourcesHolder.getSuspendedSynchronizations() != null) { TransactionSynchronizationManager.setActualTransactionActive(true); TransactionSynchronizationManager.setCurrentTransactionReadOnly(resourcesHolder.isReadOnly()); TransactionSynchronizationManager.setCurrentTransactionName(resourcesHolder.getName()); TransactionSynchronizationManager.initSynchronization(); for (Iterator it = resourcesHolder.getSuspendedSynchronizations().iterator(); it.hasNext();) { TransactionSynchronization synchronization = (TransactionSynchronization) it.next(); synchronization.resume(); TransactionSynchronizationManager.registerSynchronization(synchronization); } } doResume(transaction, resourcesHolder.getSuspendedResources()); }
if ( TransactionSynchronizationManager.isActualTransactionActive() ) { TransactionStatus transaction = null; boolean commitNewTransaction = false; try { if ( currentTransaction.size() == 0 ) { transaction = ptm.getTransaction(td); currentTransaction.push(transaction); commitNewTransaction = true; ptm.commit( transaction );
Object transaction = doGetTransaction(); if (isExistingTransaction(transaction)) { return handleExistingTransaction(definition, transaction, debugEnabled); definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRES_NEW || definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NESTED) { SuspendedResourcesHolder suspendedResources = suspend(null); if (debugEnabled) { logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition); boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); DefaultTransactionStatus status = newTransactionStatus( definition, transaction, true, newSynchronization, debugEnabled, suspendedResources); doBegin(transaction, definition); prepareSynchronization(status, definition); return status; resume(null, suspendedResources); throw ex; "isolation level will effectively be ignored: " + definition); boolean newSynchronization = (getTransactionSynchronization() == SYNCHRONIZATION_ALWAYS); return prepareTransactionStatus(definition, null, true, newSynchronization, debugEnabled, null);
triggerBeforeCompletion(status); logger.debug("Initiating transaction rollback"); doRollback(status); if (status.isLocalRollbackOnly() || isGlobalRollbackOnParticipationFailure()) { if (status.isDebug()) { logger.debug("Participating transaction failed - marking existing transaction as rollback-only"); doSetRollbackOnly(status); if (!isFailEarlyOnGlobalRollbackOnly()) { unexpectedRollback = false; triggerAfterCompletion(status, TransactionSynchronization.STATUS_UNKNOWN); throw ex; triggerAfterCompletion(status, TransactionSynchronization.STATUS_ROLLED_BACK); cleanupAfterCompletion(status);
/** * Clean up after completion, clearing synchronization if necessary, * and invoking doCleanupAfterCompletion. * @param status object representing the transaction * @see #doCleanupAfterCompletion */ private void cleanupAfterCompletion(DefaultTransactionStatus status) { status.setCompleted(); if (status.isNewSynchronization()) { TransactionSynchronizationManager.clearSynchronization(); TransactionSynchronizationManager.setCurrentTransactionName(null); TransactionSynchronizationManager.setCurrentTransactionReadOnly(false); if (status.isNewTransaction()) { TransactionSynchronizationManager.setActualTransactionActive(false); } } if (status.isNewTransaction()) { doCleanupAfterCompletion(status.getTransaction()); } if (status.getSuspendedResources() != null) { if (status.isDebug()) { logger.debug("Resuming suspended transaction"); } resume(status.getTransaction(), (SuspendedResourcesHolder) status.getSuspendedResources()); } }
boolean beforeCompletionInvoked = false; try { triggerBeforeCommit(status); triggerBeforeCompletion(status); beforeCompletionInvoked = true; if (status.hasSavepoint()) { doCommit(status); triggerAfterCompletion(status, TransactionSynchronization.STATUS_ROLLED_BACK); throw ex; if (isRollbackOnCommitFailure()) { doRollbackOnCommitException(status, ex); triggerAfterCompletion(status, TransactionSynchronization.STATUS_UNKNOWN); triggerBeforeCompletion(status); doRollbackOnCommitException(status, ex); throw ex; triggerBeforeCompletion(status); doRollbackOnCommitException(status, err); throw err; triggerAfterCompletion(status, TransactionSynchronization.STATUS_COMMITTED);
logger.debug("Suspending current transaction"); Object suspendedResources = suspend(transaction); boolean newSynchronization = (this.transactionSynchronization == SYNCHRONIZATION_ALWAYS); return newTransactionStatus( definition, null, false, newSynchronization, debugEnabled, suspendedResources); Object suspendedResources = suspend(transaction); doBegin(transaction, definition); boolean newSynchronization = (this.transactionSynchronization != SYNCHRONIZATION_NEVER); return newTransactionStatus( definition, transaction, true, newSynchronization, debugEnabled, suspendedResources); if (!isNestedTransactionAllowed()) { throw new NestedTransactionNotSupportedException( "Transaction manager does not allow nested transactions by default - " + if (useSavepointForNestedTransaction()) { newTransactionStatus(definition, transaction, false, false, debugEnabled, null); status.createAndHoldSavepoint(); return status; doBegin(transaction, definition); boolean newSynchronization = (this.transactionSynchronization != SYNCHRONIZATION_NEVER); return newTransactionStatus(definition, transaction, true, newSynchronization, debugEnabled, null); return newTransactionStatus(definition, transaction, false, newSynchronization, debugEnabled, null);
@Override public void run() { TransactionStatus status = transactionManager.getTransaction(defTransDefinition); log.debug("Attempting to abort to lock process instance for 3 secs "); // getProcessInstance does not lock reliably so let's make a change that actually does something to the entity ksession.abortProcessInstance(processInstance.getId()); // let thread 2 start once we have the transaction txAcquiredSignal.countDown(); try { // keep the lock until thread 2 let's us know it's done pessLockExceptionSignal.await(); } catch (InterruptedException e) { // do nothing } log.debug("Commited process instance aborting after 3 secs"); transactionManager.commit(status); // let main test thread know we're done threadsAreDoneLatch.countDown(); } };
Object transaction = doGetTransaction(); if (isExistingTransaction(transaction)) { return handleExistingTransaction(definition, transaction, debugEnabled); logger.debug("Creating new transaction with name [" + definition.getName() + "]"); doBegin(transaction, definition); boolean newSynchronization = (this.transactionSynchronization != SYNCHRONIZATION_NEVER); return newTransactionStatus(definition, transaction, true, newSynchronization, debugEnabled, null); return newTransactionStatus(definition, null, false, newSynchronization, debugEnabled, null);
@Override public <T> T execute(Command<T> command) { TransactionStatus status = transactionManager.getTransaction(defTransDefinition); try { T result = super.execute(command); transactionManager.commit(status); return result; } catch (Throwable e) { transactionManager.rollback(status); throw new RuntimeException(e); } }
public HumanTaskSpringTransactionManager(AbstractPlatformTransactionManager ptm) { this.ptm = ptm; this.nestedTransactions = ptm.isNestedTransactionAllowed(); }
public boolean begin() { if (nestedTransactions || getStatus() != TransactionManager.STATUS_ACTIVE) { try { currentTransaction.push(this.ptm.getTransaction(td)); return true; } catch (Exception e) { logger.warn("Unable to begin transaction", e); throw new RuntimeException("Unable to begin transaction", e); } } return false; }
public void rollback(boolean transactionOwner) { try { if ( transactionOwner ) { this.ptm.rollback( currentTransaction ); currentTransaction = null; } } catch ( Exception e ) { logger.warn( "Unable to rollback transaction", e ); throw new RuntimeException( "Unable to rollback transaction", e ); } }