List of usage examples for org.springframework.batch.core.scope.context ChunkContext getAttribute
@Override
@Nullable
public Object getAttribute(String name)
From source file:org.springframework.batch.core.step.item.ChunkOrientedTasklet.java
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { @SuppressWarnings("unchecked") Chunk<I> inputs = (Chunk<I>) chunkContext.getAttribute(INPUTS_KEY); if (inputs == null) { inputs = chunkProvider.provide(contribution); if (buffering) { chunkContext.setAttribute(INPUTS_KEY, inputs); }// w w w . ja v a2s. co m } chunkProcessor.process(contribution, inputs); chunkProvider.postProcess(contribution, inputs); // Allow a message coming back from the processor to say that we // are not done yet if (inputs.isBusy()) { logger.debug("Inputs still busy"); return RepeatStatus.CONTINUABLE; } chunkContext.removeAttribute(INPUTS_KEY); chunkContext.setComplete(); if (logger.isDebugEnabled()) { logger.debug("Inputs not busy, ended: " + inputs.isEnd()); } return RepeatStatus.continueIf(!inputs.isEnd()); }
From source file:org.springframework.xd.dirt.plugins.job.support.listener.SimpleXdChunkListener.java
private ChunkContextInfo convertChunkContext(ChunkContext context) { final ChunkContextInfo chunkContextInfo = new ChunkContextInfo(); chunkContextInfo.setComplete(context.isComplete()); chunkContextInfo.setStepExecution(context.getStepContext().getStepExecution()); final String[] attributeNames = context.attributeNames(); for (String attributeName : attributeNames) { final Object attribute = context.getAttribute(attributeName); chunkContextInfo.getAttributes().put(attributeName, attribute); }// www. j a v a 2s . c o m return chunkContextInfo; }