/** * Call the listener's after write method. * * @param items list of items that were just written. */ protected final void doAfterWrite(List<O> items) { listener.afterWrite(items); }
/** * Test method for * {@link org.springframework.batch.core.listener.MulticasterBatchListener#afterWrite(java.util.List)} * . */ @Test public void testAfterWrite() { multicast.afterWrite(null); assertEquals(1, count); }
/** * Implements writing and all related listener calls * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @throws Exception thrown if error occurs during the writing portion of the chunking loop. */ protected final void doPersist(final StepContribution contribution, final Chunk<O> chunk) throws Exception { try { List<O> items = chunk.getItems(); listener.beforeWrite(items); itemWriter.write(items); listener.afterWrite(items); } catch (Exception e) { listener.onWriteError(e, chunk.getItems()); throw e; } } }
/** * Test method for * {@link org.springframework.batch.core.listener.MulticasterBatchListener#afterWrite(java.util.List)} * . */ @Test public void testAfterWriteFails() { error = true; try { multicast.afterWrite(null); fail("Expected StepListenerFailedException"); } catch (StepListenerFailedException e) { // expected String message = e.getCause().getMessage(); assertEquals("Wrong message: " + message, "listener error", message); } assertEquals(1, count); }
@Test public void testAfterWriteFails_withAnnotatedListener() { StepListener listener = StepListenerFactoryBean.getListener(new AnnotationBasedStepListener()); multicast.register(listener); try { multicast.afterWrite(null); fail("Expected StepListenerFailedException"); } catch (StepListenerFailedException e) { // expected Throwable cause = e.getCause(); String message = cause.getMessage(); assertTrue(cause instanceof IllegalStateException); assertEquals("Wrong message: " + message, "listener error", message); } }
/** * Call the listener's after write method. * * @param items list of items that were just written. */ protected final void doAfterWrite(List<O> items) { listener.afterWrite(items); }
/** * Call the listener's after write method. * * @param items */ protected final void doAfterWrite(List<O> items) { listener.afterWrite(items); }
/** * Call the listener's after write method. * * @param items */ protected final void doAfterWrite(List<O> items) { listener.afterWrite(items); } protected final void doOnWriteError(Exception e, List<O> items) {
/** * Call the listener's after write method. * * @param items list of items that were just written. */ protected final void doAfterWrite(List<O> items) { listener.afterWrite(items); }
/** * Implements writing and all related listener calls * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @throws Exception thrown if error occurs during the writing portion of the chunking loop. */ protected final void doPersist(final StepContribution contribution, final Chunk<O> chunk) throws Exception { try { List<O> items = chunk.getItems(); listener.beforeWrite(items); itemWriter.write(items); listener.afterWrite(items); } catch (Exception e) { listener.onWriteError(e, chunk.getItems()); throw e; } } }
/** * Implements writing and all related listener calls * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @throws Exception */ protected final void doPersist(final StepContribution contribution, final Chunk<O> chunk) throws Exception { try { List<O> items = chunk.getItems(); listener.beforeWrite(items); itemWriter.write(items); listener.afterWrite(items); } catch (Exception e) { listener.onWriteError(e, chunk.getItems()); throw e; } } }
/** * Implements writing and all related listener calls * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @throws Exception thrown if error occurs during the writing portion of the chunking loop. */ protected final void doPersist(final StepContribution contribution, final Chunk<O> chunk) throws Exception { try { List<O> items = chunk.getItems(); listener.beforeWrite(items); itemWriter.write(items); listener.afterWrite(items); } catch (Exception e) { listener.onWriteError(e, chunk.getItems()); throw e; } } }