org.springframework.transaction.support.TransactionSynchronizationUtils Java Examples
The following examples show how to use
org.springframework.transaction.support.TransactionSynchronizationUtils.
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: 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 #2
Source File: AbstractPollingMessageListenerContainer.java From spring-analysis-note with MIT License | 6 votes |
@Override public void initialize() { // Set sessionTransacted=true in case of a non-JTA transaction manager. if (!this.sessionTransactedCalled && this.transactionManager instanceof ResourceTransactionManager && !TransactionSynchronizationUtils.sameResourceFactory( (ResourceTransactionManager) this.transactionManager, obtainConnectionFactory())) { super.setSessionTransacted(true); } // Use bean name as default transaction name. if (this.transactionDefinition.getName() == null) { String beanName = getBeanName(); if (beanName != null) { this.transactionDefinition.setName(beanName); } } // Proceed with superclass initialization. super.initialize(); }
Example #3
Source File: JtaAfterCompletionSynchronization.java From java-technology-stack 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: AbstractPollingMessageListenerContainer.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public void initialize() { // Set sessionTransacted=true in case of a non-JTA transaction manager. if (!this.sessionTransactedCalled && this.transactionManager instanceof ResourceTransactionManager && !TransactionSynchronizationUtils.sameResourceFactory( (ResourceTransactionManager) this.transactionManager, getConnectionFactory())) { super.setSessionTransacted(true); } // Use bean name as default transaction name. if (this.transactionDefinition.getName() == null) { this.transactionDefinition.setName(getBeanName()); } // Proceed with superclass initialization. super.initialize(); }
Example #5
Source File: AbstractPollingMessageListenerContainer.java From java-technology-stack with MIT License | 6 votes |
@Override public void initialize() { // Set sessionTransacted=true in case of a non-JTA transaction manager. if (!this.sessionTransactedCalled && this.transactionManager instanceof ResourceTransactionManager && !TransactionSynchronizationUtils.sameResourceFactory( (ResourceTransactionManager) this.transactionManager, obtainConnectionFactory())) { super.setSessionTransacted(true); } // Use bean name as default transaction name. if (this.transactionDefinition.getName() == null) { String beanName = getBeanName(); if (beanName != null) { this.transactionDefinition.setName(beanName); } } // Proceed with superclass initialization. super.initialize(); }
Example #6
Source File: JtaAfterCompletionSynchronization.java From spring4-understanding with Apache License 2.0 | 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 #7
Source File: JtaAfterCompletionSynchronization.java From lams with GNU General Public License v2.0 | 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 #8
Source File: BatchMetricsImplTest.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
@Test public void submitTransactional() throws Exception { // Given TransactionSynchronizationManager.initSynchronization(); // When batchMetrics.submit("counter.test", 1L); TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED); // Then TransactionSynchronizationManager.clearSynchronization(); }
Example #9
Source File: BatchMetricsImplTest.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
@Test public void decrementBy1Transactional() throws Exception { // Given TransactionSynchronizationManager.initSynchronization(); // When batchMetrics.decrement("counter.test", 1L); TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED); // Then TransactionSynchronizationManager.clearSynchronization(); }
Example #10
Source File: BatchMetricsImplTest.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
@Test public void incrementBy1Transactional() throws Exception { // Given TransactionSynchronizationManager.initSynchronization(); // When batchMetrics.increment("counter.test", 1L); TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED); // Then TransactionSynchronizationManager.clearSynchronization(); }
Example #11
Source File: ChainedTransactionManager.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public void rollback(TransactionStatus status) throws TransactionException { if(logger.isWarnEnabled()){ logger.warn("Rollback all connected transactions."); } try{ TransactionSynchronizationUtils.triggerBeforeCompletion(); Map<DataSource, ConnectionHolder> connSet = RoutingSynchronizationManager.getSynchronizations(); Exception rollbackException = null; ConnectionHolder rollbackExceptionConnection = null; for (ConnectionHolder connection:connSet.values()) { try { connection.rollback(); if (logger.isDebugEnabled()) { logger.debug("Connection["+ connection +"] has been rolled back."); } } catch (Exception ex) { if (rollbackException == null) { rollbackException = ex; rollbackExceptionConnection = connection; } else { logger.warn("Rollback exception (" + rollbackExceptionConnection + ") " + ex.getMessage(), ex); } } } if (rollbackException != null) { throw new UnexpectedRollbackException("Rollback exception, originated at ("+rollbackExceptionConnection+") "+ rollbackException.getMessage(), rollbackException); } }finally{ RoutingSynchronizationManager .invokeAfterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK); RoutingSynchronizationManager.clearSynchronization(); } }
Example #12
Source File: Neo4jTransactionManager.java From sdn-rx with Apache License 2.0 | 4 votes |
@Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #13
Source File: RoutingSynchronizationManager.java From easyooo-framework with Apache License 2.0 | 4 votes |
public static void invokeAfterCompletion(int completionStatus) { List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager .getSynchronizations(); TransactionSynchronizationUtils.invokeAfterCompletion(synchronizations, completionStatus); }
Example #14
Source File: WebSphereUowTransactionManager.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #15
Source File: DataSourceTransactionManager.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void flush() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationUtils.triggerFlush(); } }
Example #16
Source File: WebSphereUowTransactionManager.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #17
Source File: DataSourceTransactionManager.java From java-technology-stack with MIT License | 4 votes |
@Override public void flush() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationUtils.triggerFlush(); } }
Example #18
Source File: WebSphereUowTransactionManager.java From java-technology-stack with MIT License | 4 votes |
@Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #19
Source File: DataSourceTransactionManager.java From spring-analysis-note with MIT License | 4 votes |
@Override public void flush() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationUtils.triggerFlush(); } }
Example #20
Source File: WebSphereUowTransactionManager.java From spring-analysis-note with MIT License | 4 votes |
@Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #21
Source File: ReactiveNeo4jTransactionManager.java From sdn-rx with Apache License 2.0 | 4 votes |
@Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #22
Source File: JtaTransactionObject.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * This implementation triggers flush callbacks, * assuming that they will flush all affected ORM sessions. * @see org.springframework.transaction.support.TransactionSynchronization#flush() */ @Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #23
Source File: JtaTransactionObject.java From lams with GNU General Public License v2.0 | 2 votes |
/** * This implementation triggers flush callbacks, * assuming that they will flush all affected ORM sessions. * @see org.springframework.transaction.support.TransactionSynchronization#flush() */ @Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #24
Source File: JtaTransactionObject.java From java-technology-stack with MIT License | 2 votes |
/** * This implementation triggers flush callbacks, * assuming that they will flush all affected ORM sessions. * @see org.springframework.transaction.support.TransactionSynchronization#flush() */ @Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }
Example #25
Source File: JtaTransactionObject.java From spring-analysis-note with MIT License | 2 votes |
/** * This implementation triggers flush callbacks, * assuming that they will flush all affected ORM sessions. * @see org.springframework.transaction.support.TransactionSynchronization#flush() */ @Override public void flush() { TransactionSynchronizationUtils.triggerFlush(); }