@Override public void afterCompletion(int status) { try { super.afterCompletion(status); if (status != STATUS_COMMITTED) { // Haven't had an afterCommit call: trigger a rollback. try { this.entityManager.getTransaction().rollback(); } catch (RuntimeException ex) { throw convertException(ex); } } } finally { if (this.closeOnCompletion) { EntityManagerFactoryUtils.closeEntityManager(this.entityManager); } } }
@Override public void afterCommit() { super.afterCommit(); // Trigger commit here to let exceptions propagate to the caller. try { this.entityManager.getTransaction().commit(); } catch (RuntimeException ex) { throw convertException(ex); } }
@Override public void afterCommit() { if (!shouldReleaseBeforeCompletion()) { processResourceAfterCommit(this.resourceHolder); } }
@Override public void beforeCompletion() { if (shouldUnbindAtCompletion()) { TransactionSynchronizationManager.unbindResource(this.resourceKey); this.holderActive = false; if (shouldReleaseBeforeCompletion()) { releaseResource(this.resourceHolder, this.resourceKey); } } }
@Override public void afterCompletion(int status) { if (shouldUnbindAtCompletion()) { boolean releaseNecessary = false; if (this.holderActive) { // The thread-bound resource holder might not be available anymore, // since afterCompletion might get called from a different thread. this.holderActive = false; TransactionSynchronizationManager.unbindResourceIfPossible(this.resourceKey); this.resourceHolder.unbound(); releaseNecessary = true; } else { releaseNecessary = shouldReleaseAfterCompletion(this.resourceHolder); } if (releaseNecessary) { releaseResource(this.resourceHolder, this.resourceKey); } } else { // Probably a pre-bound resource... cleanupResource(this.resourceHolder, this.resourceKey, (status == STATUS_COMMITTED)); } this.resourceHolder.reset(); }
/** * Return whether this holder's resource should be released after * transaction completion ({@code true}). * <p>The default implementation returns {@code !shouldReleaseBeforeCompletion()}, * releasing after completion if no attempt was made before completion. * @see #releaseResource */ protected boolean shouldReleaseAfterCompletion(H resourceHolder) { return !shouldReleaseBeforeCompletion(); }
@Override public void flush() { flushResource(this.resourceHolder); }
@Override protected void processResourceAfterCommit( HazelcastMQContextHolder resourceHolder) { log.finest("In HazelcastMQTransactionSynchronization::" + "processResourceAfterCommit"); super.processResourceAfterCommit(resourceHolder); resourceHolder.getHazelcastMQContext().commit(); resourceHolder.clear(); }
@Override protected void releaseResource( HazelcastMQContextHolder resourceHolder, HazelcastMQInstance resourceKey) { log.finest("In HazelcastMQTransactionSynchronization::" + "releaseResource"); super.releaseResource(resourceHolder, resourceKey); if (resourceHolder.isTransactionActive()) { resourceHolder.getHazelcastMQContext().rollback(); } resourceHolder.clear(); } }
@Override public void afterCompletion(int status) { if (shouldUnbindAtCompletion()) { boolean releaseNecessary = false; if (this.holderActive) { // The thread-bound resource holder might not be available anymore, // since afterCompletion might get called from a different thread. this.holderActive = false; TransactionSynchronizationManager.unbindResourceIfPossible(this.resourceKey); this.resourceHolder.unbound(); releaseNecessary = true; } else { releaseNecessary = shouldReleaseAfterCompletion(this.resourceHolder); } if (releaseNecessary) { releaseResource(this.resourceHolder, this.resourceKey); } } else { // Probably a pre-bound resource... cleanupResource(this.resourceHolder, this.resourceKey, (status == STATUS_COMMITTED)); } this.resourceHolder.reset(); }
@Override public void beforeCompletion() { if (shouldUnbindAtCompletion()) { TransactionSynchronizationManager.unbindResource(this.resourceKey); this.holderActive = false; if (shouldReleaseBeforeCompletion()) { releaseResource(this.resourceHolder, this.resourceKey); } } }
/** * Return whether this holder's resource should be released after * transaction completion ({@code true}). * <p>The default implementation returns {@code !shouldReleaseBeforeCompletion()}, * releasing after completion if no attempt was made before completion. * @see #releaseResource */ protected boolean shouldReleaseAfterCompletion(H resourceHolder) { return !shouldReleaseBeforeCompletion(); }
@Override public void flush() { flushResource(this.resourceHolder); }
@Override protected void processResourceAfterCommit( HazelcastTransactionContextHolder resourceHolder) { log.finest("In HazelcastTransactionSynchronization::" + "processResourceAfterCommit"); super.processResourceAfterCommit(resourceHolder); resourceHolder.getTransactionContext().commitTransaction(); resourceHolder.clear(); }
@Override protected void releaseResource( HazelcastTransactionContextHolder resourceHolder, HazelcastInstance resourceKey) { log.finest("In HazelcastTransactionSynchronization::" + "releaseResource"); super.releaseResource(resourceHolder, resourceKey); if (resourceHolder.isTransactionActive()) { resourceHolder.getTransactionContext().rollbackTransaction(); } resourceHolder.clear(); } }
@Override public void afterCompletion(int status) { try { super.afterCompletion(status); if (status != STATUS_COMMITTED) { // Haven't had an afterCommit call: trigger a rollback. try { this.entityManager.getTransaction().rollback(); } catch (RuntimeException ex) { throw convertException(ex); } } } finally { if (this.closeOnCompletion) { EntityManagerFactoryUtils.closeEntityManager(this.entityManager); } } }
@Override public void afterCompletion(int status) { if (shouldUnbindAtCompletion()) { boolean releaseNecessary = false; if (this.holderActive) { // The thread-bound resource holder might not be available anymore, // since afterCompletion might get called from a different thread. this.holderActive = false; TransactionSynchronizationManager.unbindResourceIfPossible(this.resourceKey); this.resourceHolder.unbound(); releaseNecessary = true; } else { releaseNecessary = shouldReleaseAfterCompletion(this.resourceHolder); } if (releaseNecessary) { releaseResource(this.resourceHolder, this.resourceKey); } } else { // Probably a pre-bound resource... cleanupResource(this.resourceHolder, this.resourceKey, (status == STATUS_COMMITTED)); } this.resourceHolder.reset(); }
@Override public void beforeCompletion() { if (shouldUnbindAtCompletion()) { TransactionSynchronizationManager.unbindResource(this.resourceKey); this.holderActive = false; if (shouldReleaseBeforeCompletion()) { releaseResource(this.resourceHolder, this.resourceKey); } } }
@Override public void afterCommit() { if (!shouldReleaseBeforeCompletion()) { processResourceAfterCommit(this.resourceHolder); } }
@Override public void afterCommit() { super.afterCommit(); // Trigger commit here to let exceptions propagate to the caller. try { this.entityManager.getTransaction().commit(); } catch (RuntimeException ex) { throw convertException(ex); } }