Java Code Examples for org.springframework.transaction.support.TransactionSynchronizationManager#clear()
The following examples show how to use
org.springframework.transaction.support.TransactionSynchronizationManager#clear() .
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: ChainedTransactionManager.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * * {@inheritDoc} */ public void rollback( TransactionStatus status ) { for ( PlatformTransactionManager dataSourceManager : _transactionManagers ) { try { dataSourceManager.rollback( ( ( (MultiTransactionStatus) status ).getTransactionStatus( dataSourceManager ) ) ); } catch( Exception ex ) { _log.error( ex.getMessage( ), ex ); } } if ( ( (MultiTransactionStatus) status ).isNewSynchonization( ) ) { TransactionSynchronizationManager.clear( ); } }
Example 2
Source File: WebSphereUowTransactionManager.java From spring-analysis-note with MIT License | 5 votes |
@Override public void run() { UOWManager uowManager = obtainUOWManager(); DefaultTransactionStatus status = prepareTransactionStatus( this.definition, (this.actualTransaction ? this : null), this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status); } catch (Throwable ex) { this.exception = ex; if (status.isDebug()) { logger.debug("Rolling back on application exception from transaction callback", ex); } uowManager.setRollbackOnly(); } finally { if (status.isLocalRollbackOnly()) { if (status.isDebug()) { logger.debug("Transaction callback has explicitly requested rollback"); } uowManager.setRollbackOnly(); } triggerBeforeCompletion(status); if (status.isNewSynchronization()) { List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations(); TransactionSynchronizationManager.clear(); if (!synchronizations.isEmpty()) { uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations)); } } } }
Example 3
Source File: AbstractDatabaseInitializationTests.java From spring-analysis-note with MIT License | 5 votes |
@After public void shutDown() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clear(); TransactionSynchronizationManager.unbindResource(db); } db.shutdown(); }
Example 4
Source File: WebSphereUowTransactionManager.java From java-technology-stack with MIT License | 5 votes |
@Override public void run() { UOWManager uowManager = obtainUOWManager(); DefaultTransactionStatus status = prepareTransactionStatus( this.definition, (this.actualTransaction ? this : null), this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status); } catch (Throwable ex) { this.exception = ex; if (status.isDebug()) { logger.debug("Rolling back on application exception from transaction callback", ex); } uowManager.setRollbackOnly(); } finally { if (status.isLocalRollbackOnly()) { if (status.isDebug()) { logger.debug("Transaction callback has explicitly requested rollback"); } uowManager.setRollbackOnly(); } triggerBeforeCompletion(status); if (status.isNewSynchronization()) { List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations(); TransactionSynchronizationManager.clear(); if (!synchronizations.isEmpty()) { uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations)); } } } }
Example 5
Source File: AbstractDatabaseInitializationTests.java From java-technology-stack with MIT License | 5 votes |
@After public void shutDown() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clear(); TransactionSynchronizationManager.unbindResource(db); } db.shutdown(); }
Example 6
Source File: WebSphereUowTransactionManager.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void run() { DefaultTransactionStatus status = prepareTransactionStatus( this.definition, (this.actualTransaction ? this : null), this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status); } catch (Throwable ex) { this.exception = ex; uowManager.setRollbackOnly(); } finally { if (status.isLocalRollbackOnly()) { if (status.isDebug()) { logger.debug("Transactional code has requested rollback"); } uowManager.setRollbackOnly(); } triggerBeforeCompletion(status); if (status.isNewSynchronization()) { List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations(); TransactionSynchronizationManager.clear(); if (!synchronizations.isEmpty()) { uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations)); } } } }
Example 7
Source File: WebSphereUowTransactionManager.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void run() { DefaultTransactionStatus status = prepareTransactionStatus( this.definition, (this.actualTransaction ? this : null), this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status); } catch (Throwable ex) { this.exception = ex; uowManager.setRollbackOnly(); } finally { if (status.isLocalRollbackOnly()) { if (status.isDebug()) { logger.debug("Transactional code has requested rollback"); } uowManager.setRollbackOnly(); } triggerBeforeCompletion(status); if (status.isNewSynchronization()) { List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations(); TransactionSynchronizationManager.clear(); if (!synchronizations.isEmpty()) { uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations)); } } } }
Example 8
Source File: AbstractDatabaseInitializationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@After public void shutDown() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clear(); TransactionSynchronizationManager.unbindResource(db); } db.shutdown(); }
Example 9
Source File: ChainedTransactionManager.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * * {@inheritDoc} */ public void commit( TransactionStatus status ) { for ( PlatformTransactionManager transactionManager : _transactionManagers ) { TransactionStatus transactionStatus = null; try { transactionStatus = ( (MultiTransactionStatus) status ).getTransactionStatus( transactionManager ); transactionManager.commit( transactionStatus ); } catch( Exception e ) { _log.error( e.getMessage( ), e ); } } if ( _log.isDebugEnabled( ) ) { _log.debug( "Ending transaction : " + status.toString( ) ); } if ( ( (MultiTransactionStatus) status ).isNewSynchonization( ) ) { TransactionSynchronizationManager.clear( ); } }
Example 10
Source File: RoutingSynchronizationManager.java From easyooo-framework with Apache License 2.0 | 5 votes |
public static void clearSynchronization() throws IllegalStateException { if (!isSynchronizationActive()) { throw new IllegalStateException("Cannot deactivate transaction synchronization - not active"); } if(logger.isDebugEnabled()){ logger.debug("Transaction cleaning."); } try{ Map<DataSource,ConnectionHolder> synchs = synchronizations.get(); List<SQLException> exceptions = new ArrayList<SQLException>(); for (ConnectionHolder connection : synchs.values()) { try { connection.close(); } catch (SQLException e) { exceptions.add(e); } } if(!exceptions.isEmpty()){ for (SQLException sqlException : exceptions) { logger.error("Close the connection error", sqlException); } } }finally{ synchronizations.remove(); definitions.remove(); // Clean up the Spring transaction synch TransactionSynchronizationManager.clear(); } }
Example 11
Source File: AbstractDatabaseInitializationTests.java From effectivejava with Apache License 2.0 | 5 votes |
@After public void shutDown() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clear(); TransactionSynchronizationManager.unbindResource(db); } db.shutdown(); }