Java Code Examples for org.springframework.transaction.support.DefaultTransactionStatus#isNewSynchronization()
The following examples show how to use
org.springframework.transaction.support.DefaultTransactionStatus#isNewSynchronization() .
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: KualiTransactionInterceptor.java From rice with Educational Community License v2.0 | 6 votes |
/** * @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCommitTransactionAfterReturning(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo) */ @Override protected void commitTransactionAfterReturning(TransactionInfo txInfo) { // using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass if (logger.isDebugEnabled()) { if (txInfo != null) { TransactionStatus txStatus = txInfo.getTransactionStatus(); if (txStatus != null) { if (txStatus.isNewTransaction()) { LOG.debug("committing explicit transaction for " + txInfo.getJoinpointIdentification()); } else { if (txStatus instanceof DefaultTransactionStatus) { DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus; if (dtxStatus.isNewSynchronization()) { LOG.debug("committing implicit transaction for " + txInfo.getJoinpointIdentification()); } } } } } } super.commitTransactionAfterReturning(txInfo); }
Example 2
Source File: PostgreSqlTransactionManager.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void doRollback(DefaultTransactionStatus status) { MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction(); if (LOG.isDebugEnabled()) { LOG.debug("Rollback transaction [{}]", transaction.getId()); } DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus( transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()); if (!status.isReadOnly()) { transactionListeners.forEach(j -> j.rollbackTransaction(transaction.getId())); } super.doRollback(jpaTransactionStatus); }
Example 3
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 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: 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 6
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 7
Source File: KualiTransactionInterceptor.java From rice with Educational Community License v2.0 | 5 votes |
/** * @see org.springframework.transaction.interceptor.TransactionAspectSupport#createTransactionIfNecessary(java.lang.reflect.Method, * java.lang.Class) */ @Override protected TransactionInfo createTransactionIfNecessary(Method method, Class targetClass) { TransactionInfo txInfo = super.createTransactionIfNecessary(method, targetClass); // using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass if (logger.isDebugEnabled()) { if (txInfo != null) { TransactionStatus txStatus = txInfo.getTransactionStatus(); if (txStatus != null) { if (txStatus.isNewTransaction()) { LOG.debug("creating explicit transaction for " + txInfo.getJoinpointIdentification()); } else { if (txStatus instanceof DefaultTransactionStatus) { DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus; if (dtxStatus.isNewSynchronization()) { LOG.debug("creating implicit transaction for " + txInfo.getJoinpointIdentification()); } } } } } } return txInfo; }
Example 8
Source File: KualiTransactionInterceptor.java From rice with Educational Community License v2.0 | 5 votes |
/** * @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCloseTransactionAfterThrowing(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo, * java.lang.Throwable) */ @Override protected void completeTransactionAfterThrowing(TransactionInfo txInfo, Throwable ex) { if (txInfo.getTransactionAttribute().rollbackOn(ex)) { LOG.fatal("Exception caught by Transaction Interceptor, this will cause a rollback at the end of the transaction.", ex); } // using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass if (logger.isDebugEnabled()) { if (txInfo != null) { TransactionStatus txStatus = txInfo.getTransactionStatus(); if (txStatus != null) { if (txStatus.isNewTransaction()) { LOG.debug("closing explicit transaction for " + txInfo.getJoinpointIdentification()); } else { if (txStatus instanceof DefaultTransactionStatus) { DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus; if (dtxStatus.isNewSynchronization()) { LOG.debug("closing implicit transaction for " + txInfo.getJoinpointIdentification()); } } } } } } super.completeTransactionAfterThrowing(txInfo, ex); }
Example 9
Source File: PostgreSqlTransactionManager.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void doCommit(DefaultTransactionStatus status) { MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction(); if (LOG.isDebugEnabled()) { LOG.debug("Commit transaction [{}]", transaction.getId()); } DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus( transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()); if (!status.isReadOnly()) { transactionListeners.forEach(j -> j.commitTransaction(transaction.getId())); } try { super.doCommit(jpaTransactionStatus); } catch (TransactionException e) { throw translateTransactionException(e); } if (!status.isReadOnly()) { transactionListeners.forEach(j -> j.afterCommitTransaction(transaction.getId())); } }
Example 10
Source File: PostgreSqlTransactionManager.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void doSetRollbackOnly(DefaultTransactionStatus status) { MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction(); DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus( transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()); super.doSetRollbackOnly(jpaTransactionStatus); }
Example 11
Source File: ContextSourceAndHibernateTransactionManager.java From spring-ldap with Apache License 2.0 | 5 votes |
protected void doCommit(DefaultTransactionStatus status) { ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status .getTransaction(); try { super.doCommit(new DefaultTransactionStatus(actualTransactionObject .getHibernateTransactionObject(), status .isNewTransaction(), status.isNewSynchronization(), status .isReadOnly(), status.isDebug(), status .getSuspendedResources())); } catch (TransactionException ex) { if (isRollbackOnCommitFailure()) { logger.debug("Failed to commit db resource, rethrowing", ex); // If we are to rollback on commit failure, just rethrow the // exception - this will cause a rollback to be performed on // both resources. throw ex; } else { logger .warn("Failed to commit and resource is rollbackOnCommit not set -" + " proceeding to commit ldap resource."); } } ldapManagerDelegate.doCommit(new DefaultTransactionStatus( actualTransactionObject.getLdapTransactionObject(), status .isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status .getSuspendedResources())); }
Example 12
Source File: ContextSourceAndHibernateTransactionManager.java From spring-ldap with Apache License 2.0 | 5 votes |
protected void doRollback(DefaultTransactionStatus status) { ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status .getTransaction(); super.doRollback(new DefaultTransactionStatus(actualTransactionObject .getHibernateTransactionObject(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status .isDebug(), status.getSuspendedResources())); ldapManagerDelegate.doRollback(new DefaultTransactionStatus( actualTransactionObject.getLdapTransactionObject(), status .isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status .getSuspendedResources())); }
Example 13
Source File: ContextSourceAndDataSourceTransactionManager.java From spring-ldap with Apache License 2.0 | 5 votes |
protected void doCommit(DefaultTransactionStatus status) { ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status .getTransaction(); try { super.doCommit(new DefaultTransactionStatus(actualTransactionObject .getDataSourceTransactionObject(), status .isNewTransaction(), status.isNewSynchronization(), status .isReadOnly(), status.isDebug(), status .getSuspendedResources())); } catch (TransactionException ex) { if (isRollbackOnCommitFailure()) { logger.debug("Failed to commit db resource, rethrowing", ex); // If we are to rollback on commit failure, just rethrow the // exception - this will cause a rollback to be performed on // both resources. throw ex; } else { logger .warn("Failed to commit and resource is rollbackOnCommit not set -" + " proceeding to commit ldap resource."); } } ldapManagerDelegate.doCommit(new DefaultTransactionStatus( actualTransactionObject.getLdapTransactionObject(), status .isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status .getSuspendedResources())); }
Example 14
Source File: ContextSourceAndDataSourceTransactionManager.java From spring-ldap with Apache License 2.0 | 5 votes |
protected void doRollback(DefaultTransactionStatus status) { ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status .getTransaction(); super.doRollback(new DefaultTransactionStatus(actualTransactionObject .getDataSourceTransactionObject(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status .isDebug(), status.getSuspendedResources())); ldapManagerDelegate.doRollback(new DefaultTransactionStatus( actualTransactionObject.getLdapTransactionObject(), status .isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status .getSuspendedResources())); }