/** * Call listener's writerError method. * @param e exception that occurred. * @param items list of items that failed to be written. */ protected final void doOnWriteError(Exception e, List<O> items) { listener.onWriteError(e, items); }
/** * Test method for * {@link org.springframework.batch.core.listener.MulticasterBatchListener#onWriteError(Exception, java.util.List)} * . */ @Test public void testOnWriteError() { multicast.onWriteError(new RuntimeException("foo"), 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#onWriteError(Exception, java.util.List)} * . */ @Test public void testOnWriteErrorFails() { error = true; try { multicast.onWriteError(new RuntimeException("foo"), null); fail("Expected StepListenerFailedException"); } catch (StepListenerFailedException e) { // expected String message = e.getCause().getMessage(); assertEquals("Wrong message: " + message, "listener error", message); } assertEquals(1, count); }
/** * Call listener's writerError method. * @param e exception that occurred. * @param items list of items that failed to be written. */ protected final void doOnWriteError(Exception e, List<O> items) { listener.onWriteError(e, items); }
/** * Call listener's writerError method. * @param e exception that occurred. * @param items list of items that failed to be written. */ protected final void doOnWriteError(Exception e, List<O> items) { listener.onWriteError(e, items); }
protected final void doOnWriteError(Exception e, List<O> items) { listener.onWriteError(e, items); }
/** * Surrounds the actual write call with listener callbacks. * * @param items * @throws Exception */ protected final void doWrite(List<O> items) throws Exception { if (itemWriter==null) { return; } try { listener.beforeWrite(items); writeItems(items); doAfterWrite(items); } catch (Exception e) { listener.onWriteError(e, items); 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; } } }
/** * 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; } } }