OPEN - issue BATCH-787: Add write(List) to ItemWriter
Make samples and cli archetype compile again
This commit is contained in:
@@ -64,10 +64,12 @@ public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSuppo
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public void write(T item) throws Exception {
|
||||
public void write(List<? extends T> items) throws Exception {
|
||||
bindTransactionResources();
|
||||
getProcessed().add(item);
|
||||
logger.debug("Added item to chunk: " + item);
|
||||
for (T item : items) {
|
||||
getProcessed().add(item);
|
||||
logger.debug("Added item to chunk: " + item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springframework.batch.integration.chunk;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.SkipListener;
|
||||
@@ -55,7 +57,7 @@ public class ItemWriterChunkHandler<T> implements ChunkHandler<T> {
|
||||
try {
|
||||
for (T item : chunk.getItems()) {
|
||||
try {
|
||||
itemWriter.write(item);
|
||||
itemWriter.write(Collections.singletonList(item));
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (itemSkipPolicy.shouldSkip(e, parentSkipCount + skipCount)) {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.integration.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.item.support.AbstractItemWriter;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
@@ -39,10 +41,13 @@ public class MessageChannelItemWriter<T> extends AbstractItemWriter<T> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.item.ItemWriter#write(java.lang.Object)
|
||||
*/
|
||||
public void write(T item) throws Exception {
|
||||
channel.send(new GenericMessage<T>(item));
|
||||
public void write(List<? extends T> items) throws Exception {
|
||||
for (T item : items) {
|
||||
channel.send(new GenericMessage<T>(item));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user