List of usage examples for org.springframework.batch.core.step.item SimpleChunkProcessor SimpleChunkProcessor
public SimpleChunkProcessor(@Nullable ItemProcessor<? super I, ? extends O> itemProcessor, ItemWriter<? super O> itemWriter)
From source file:es.fcs.batch.integration.chunk.SerializableChunkProcessor.java
@SuppressWarnings("unchecked") private void doInit() throws JobExecutionException { if (delegate != null) { // Delegate is already initialized return;/*from w ww . j a v a 2s. co m*/ } // Initializing processor and writer if (itemWriter == null && itemWriterSerializable == null) { throw new JobExecutionException("No itemWriter defined"); } if (itemProcessor == null && itemProcessorSerializable == null) { throw new JobExecutionException("No itemWriter defined"); } if (itemWriter == null) itemWriter = (ItemWriter) itemWriterSerializable; if (itemProcessor == null) itemProcessor = (ItemProcessor) itemProcessorSerializable; // Initializing delegate delegate = new SimpleChunkProcessor<I, O>(itemProcessor, itemWriter); }
From source file:es.fcs.batch.integration.chunk.MyRemoteChunkHandlerFactoryBean.java
/** * Replace the chunk processor in the tasklet provided with one that can act as a master in the Remote Chunking * pattern./*from w w w . j av a2s . c o m*/ * * @param tasklet a ChunkOrientedTasklet * @param chunkWriter an ItemWriter that can send the chunks to remote workers * @param stepContributionSource a StepContributionSource used to gather results from the workers */ private void replaceChunkProcessor(ChunkOrientedTasklet<?> tasklet, ItemWriter<T> chunkWriter, final StepContributionSource stepContributionSource) { setField(tasklet, "chunkProcessor", new SimpleChunkProcessor<T, T>(new PassThroughItemProcessor<T>(), chunkWriter) { /** * */ private static final long serialVersionUID = -8914556774351841413L; @Override protected void write(StepContribution contribution, Chunk<T> inputs, Chunk<T> outputs) throws Exception { doWrite(outputs.getItems()); // Do not update the step contribution until the chunks are // actually processed updateStepContribution(contribution, stepContributionSource); } }); }
From source file:org.springframework.batch.core.step.item.SimpleStepFactoryBean.java
/** * Extension point for creating appropriate {@link ChunkProcessor}. Return * value must subclass {@link SimpleChunkProcessor} due to listener * registration.//www . j av a2 s . com */ protected SimpleChunkProcessor<T, S> configureChunkProcessor() { return new SimpleChunkProcessor<T, S>(itemProcessor, itemWriter); }
From source file:org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean.java
/** * Replace the chunk processor in the tasklet provided with one that can act as a master in the Remote Chunking * pattern./*from ww w . j a v a 2 s .c o m*/ * * @param tasklet a ChunkOrientedTasklet * @param chunkWriter an ItemWriter that can send the chunks to remote workers * @param stepContributionSource a StepContributionSource used to gather results from the workers */ private void replaceChunkProcessor(ChunkOrientedTasklet<?> tasklet, ItemWriter<T> chunkWriter, final StepContributionSource stepContributionSource) { setField(tasklet, "chunkProcessor", new SimpleChunkProcessor<T, T>(new PassThroughItemProcessor<T>(), chunkWriter) { @Override protected void write(StepContribution contribution, Chunk<T> inputs, Chunk<T> outputs) throws Exception { doWrite(outputs.getItems()); // Do not update the step contribution until the chunks are // actually processed updateStepContribution(contribution, stepContributionSource); } }); }