/** * Run all registered Synchronizations' beforeCompletion() method. Be aware that this method can change the * transaction status to mark it as rollback only for instance. * @throws bitronix.tm.internal.BitronixSystemException if status changing due to a synchronization throwing an * exception fails. */ private void fireBeforeCompletionEvent() throws BitronixSystemException { if (log.isDebugEnabled()) log.debug("before completion, " + synchronizationScheduler.size() + " synchronization(s) to execute"); Iterator it = synchronizationScheduler.reverseIterator(); while (it.hasNext()) { Synchronization synchronization = (Synchronization) it.next(); try { if (log.isDebugEnabled()) log.debug("executing synchronization " + synchronization); synchronization.beforeCompletion(); } catch (RuntimeException ex) { if (log.isDebugEnabled()) log.debug("Synchronization.beforeCompletion() call failed for " + synchronization + ", marking transaction as rollback only - " + ex); setStatus(Status.STATUS_MARKED_ROLLBACK); throw ex; } } }
/** * Run all registered Synchronizations' beforeCompletion() method. Be aware that this method can change the * transaction status to mark it as rollback only for instance. * @throws bitronix.tm.internal.BitronixSystemException if status changing due to a synchronization throwing an * exception fails. */ private void fireBeforeCompletionEvent() throws BitronixSystemException { if (log.isDebugEnabled()) { log.debug("before completion, " + synchronizationScheduler.size() + " synchronization(s) to execute"); } Iterator<Synchronization> it = synchronizationScheduler.reverseIterator(); while (it.hasNext()) { Synchronization synchronization = it.next(); try { if (log.isDebugEnabled()) { log.debug("executing synchronization " + synchronization); } synchronization.beforeCompletion(); } catch (RuntimeException ex) { if (log.isDebugEnabled()) { log.debug("Synchronization.beforeCompletion() call failed for " + synchronization + ", marking transaction as rollback only - " + ex); } setStatus(Status.STATUS_MARKED_ROLLBACK); throw ex; } } }
/** * Run all registered Synchronizations' beforeCompletion() method. Be aware that this method can change the * transaction status to mark it as rollback only for instance. * @throws bitronix.tm.internal.BitronixSystemException if status changing due to a synchronization throwing an * exception fails. */ private void fireBeforeCompletionEvent() throws BitronixSystemException { if (log.isDebugEnabled()) { log.debug("before completion, " + synchronizationScheduler.size() + " synchronization(s) to execute"); } Iterator<Synchronization> it = synchronizationScheduler.reverseIterator(); while (it.hasNext()) { Synchronization synchronization = it.next(); try { if (log.isDebugEnabled()) { log.debug("executing synchronization " + synchronization); } synchronization.beforeCompletion(); } catch (RuntimeException ex) { if (log.isDebugEnabled()) { log.debug("Synchronization.beforeCompletion() call failed for " + synchronization + ", marking transaction as rollback only - " + ex); } setStatus(Status.STATUS_MARKED_ROLLBACK); throw ex; } } }
/** * Run all registered Synchronizations' beforeCompletion() method. Be aware that this method can change the * transaction status to mark it as rollback only for instance. * @throws bitronix.tm.internal.BitronixSystemException if status changing due to a synchronization throwing an * exception fails. */ private void fireBeforeCompletionEvent() throws BitronixSystemException { if (log.isDebugEnabled()) log.debug("before completion, " + synchronizationScheduler.size() + " synchronization(s) to execute"); Iterator it = synchronizationScheduler.reverseIterator(); while (it.hasNext()) { Synchronization synchronization = (Synchronization) it.next(); try { if (log.isDebugEnabled()) log.debug("executing synchronization " + synchronization); synchronization.beforeCompletion(); } catch (RuntimeException ex) { if (log.isDebugEnabled()) log.debug("Synchronization.beforeCompletion() call failed for " + synchronization + ", marking transaction as rollback only - " + ex); setStatus(Status.STATUS_MARKED_ROLLBACK); throw ex; } } }
public void testReverseRemove() { Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.remove(xarhs0); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); Iterator<XAResourceHolderState> it = resourceScheduler.reverseIterator(); assertTrue(it.hasNext()); assertTrue(xarhs1 == it.next()); it.remove(); assertTrue(xarhs0 == it.next()); it.remove(); }
public void testReverseRemove() { Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.remove(xarhs0); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); Iterator<XAResourceHolderState> it = resourceScheduler.reverseIterator(); assertTrue(it.hasNext()); assertTrue(xarhs1 == it.next()); it.remove(); assertTrue(xarhs0 == it.next()); it.remove(); }
public void testReverseIterator() { Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition()); assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString()); Iterator it = resourceScheduler.reverseIterator(); assertTrue(it.hasNext()); assertTrue(xarhs4 == it.next()); assertTrue(xarhs0 == it.next()); assertTrue(xarhs1 == it.next()); assertTrue(xarhs2 == it.next()); assertTrue(xarhs3 == it.next()); assertFalse(it.hasNext()); }
public void testReverseIterator() { Scheduler<XAResourceHolderState> resourceScheduler = new Scheduler<XAResourceHolderState>(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition()); assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString()); Iterator it = resourceScheduler.reverseIterator(); assertTrue(it.hasNext()); assertTrue(xarhs4 == it.next()); assertTrue(xarhs0 == it.next()); assertTrue(xarhs1 == it.next()); assertTrue(xarhs2 == it.next()); assertTrue(xarhs3 == it.next()); assertFalse(it.hasNext()); }