I have a need to store a variable in ChunkContext. The variable is available after the Processor and I want to get it's value in my Writer.
Processor:
public class MyProcessor implements
ItemProcessor<ModelItem, ModelItem> {
private Logger logger = LoggerFactory.getLogger(MyProcessor.class);
private long averageWeightInChunk;
...
Writer:
public class MyWriter implements ItemWriter<PatentWrapper> {
private static final Logger logger = LoggerFactory
.getLogger(MyWriter .class);
private long averageWeightInChunk;
...
But then I have no idea if I need to use the afterChunk() or beforeChunk() of a ChunkListener and/or if it's possible to just inject the value in the xml like this:
<bean id="MyWriter" scope="step">
<property name="averageWeightInChunk" value="#{chunkContext[awic]}" />
</bean>