List of usage examples for org.springframework.transaction.reactive GenericReactiveTransaction isNewSynchronization
public boolean isNewSynchronization()
From source file:org.springframework.transaction.reactive.AbstractReactiveTransactionManager.java
/** * Initialize transaction synchronization as appropriate. *//*from w ww. ja va2 s . co m*/ private void prepareSynchronization(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status, TransactionDefinition definition) { if (status.isNewSynchronization()) { synchronizationManager.setActualTransactionActive(status.hasTransaction()); synchronizationManager.setCurrentTransactionIsolationLevel( definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT ? definition.getIsolationLevel() : null); synchronizationManager.setCurrentTransactionReadOnly(definition.isReadOnly()); synchronizationManager.setCurrentTransactionName(definition.getName()); synchronizationManager.initSynchronization(); } }
From source file:org.springframework.transaction.reactive.AbstractReactiveTransactionManager.java
/** * Trigger {@code beforeCommit} callbacks. * @param synchronizationManager the synchronization manager bound to the current transaction * @param status object representing the transaction *//* www.j a va 2 s .co m*/ private Mono<Void> triggerBeforeCommit(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) { if (status.isNewSynchronization()) { if (status.isDebug()) { logger.trace("Triggering beforeCommit synchronization"); } return TransactionSynchronizationUtils.triggerBeforeCommit(synchronizationManager.getSynchronizations(), status.isReadOnly()); } return Mono.empty(); }
From source file:org.springframework.transaction.reactive.AbstractReactiveTransactionManager.java
/** * Trigger {@code beforeCompletion} callbacks. * @param synchronizationManager the synchronization manager bound to the current transaction * @param status object representing the transaction */// w w w. ja va 2 s .c o m private Mono<Void> triggerBeforeCompletion(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) { if (status.isNewSynchronization()) { if (status.isDebug()) { logger.trace("Triggering beforeCompletion synchronization"); } return TransactionSynchronizationUtils .triggerBeforeCompletion(synchronizationManager.getSynchronizations()); } return Mono.empty(); }
From source file:org.springframework.transaction.reactive.AbstractReactiveTransactionManager.java
/** * Trigger {@code afterCommit} callbacks. * @param synchronizationManager the synchronization manager bound to the current transaction * @param status object representing the transaction *///from w w w. j av a 2s.com private Mono<Void> triggerAfterCommit(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) { if (status.isNewSynchronization()) { if (status.isDebug()) { logger.trace("Triggering afterCommit synchronization"); } return TransactionSynchronizationUtils.invokeAfterCommit(synchronizationManager.getSynchronizations()); } return Mono.empty(); }
From source file:org.springframework.transaction.reactive.AbstractReactiveTransactionManager.java
/** * Trigger {@code afterCompletion} callbacks. * @param synchronizationManager the synchronization manager bound to the current transaction * @param status object representing the transaction * @param completionStatus completion status according to TransactionSynchronization constants *//*from ww w.j ava2 s.c o m*/ private Mono<Void> triggerAfterCompletion(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status, int completionStatus) { if (status.isNewSynchronization()) { List<TransactionSynchronization> synchronizations = synchronizationManager.getSynchronizations(); synchronizationManager.clearSynchronization(); if (!status.hasTransaction() || status.isNewTransaction()) { if (status.isDebug()) { logger.trace("Triggering afterCompletion synchronization"); } // No transaction or new transaction for the current scope -> // invoke the afterCompletion callbacks immediately return invokeAfterCompletion(synchronizationManager, synchronizations, completionStatus); } else if (!synchronizations.isEmpty()) { // Existing transaction that we participate in, controlled outside // of the scope of this Spring transaction manager -> try to register // an afterCompletion callback with the existing (JTA) transaction. return registerAfterCompletionWithExistingTransaction(synchronizationManager, status.getTransaction(), synchronizations); } } return Mono.empty(); }
From source file:org.springframework.transaction.reactive.AbstractReactiveTransactionManager.java
/** * Clean up after completion, clearing synchronization if necessary, * and invoking doCleanupAfterCompletion. * @param synchronizationManager the synchronization manager bound to the current transaction * @param status object representing the transaction * @see #doCleanupAfterCompletion//from w w w . j av a 2 s. co m */ private Mono<Void> cleanupAfterCompletion(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) { return Mono.defer(() -> { status.setCompleted(); if (status.isNewSynchronization()) { synchronizationManager.clear(); } Mono<Void> cleanup = Mono.empty(); if (status.isNewTransaction()) { cleanup = doCleanupAfterCompletion(synchronizationManager, 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); return cleanup.then(resume(synchronizationManager, transaction, (SuspendedResourcesHolder) status.getSuspendedResources())); } return cleanup; }); }