List of usage examples for org.springframework.batch.core.step.item Chunk setEnd
public void setEnd()
From source file:org.springframework.batch.core.jsr.step.item.JsrChunkProcessor.java
/** * Implements reading as well as any related listener calls required. * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk}//from www . j a v a 2 s .co m * @return an item * @throws Exception */ protected final I doProvide(final StepContribution contribution, final Chunk<I> chunk) throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if (item != null) { listener.afterRead(item); } else { chunk.setEnd(); } return item; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); } listener.onReadError(e); throw e; } }
From source file:org.springframework.batch.core.step.item.SimpleChunkProvider.java
@Override public Chunk<I> provide(final StepContribution contribution) throws Exception { final Chunk<I> inputs = new Chunk<I>(); repeatOperations.iterate(new RepeatCallback() { @Override// w w w . j a v a 2 s.co m public RepeatStatus doInIteration(final RepeatContext context) throws Exception { I item = null; try { item = read(contribution, inputs); } catch (SkipOverflowException e) { // read() tells us about an excess of skips by throwing an // exception return RepeatStatus.FINISHED; } if (item == null) { inputs.setEnd(); return RepeatStatus.FINISHED; } inputs.add(item); contribution.incrementReadCount(); return RepeatStatus.CONTINUABLE; } }); return inputs; }