RESOLVED - issue BATCH-788: Remove flush/clear from ItemWriter

Done
This commit is contained in:
dsyer
2008-08-20 09:59:51 +00:00
parent 9e1d35a546
commit 42a9b97d1f
40 changed files with 94 additions and 244 deletions

View File

@@ -70,11 +70,9 @@ public class ItemWriterChunkHandler<T> implements ChunkHandler<T> {
}
}
}
itemWriter.flush();
}
catch (Exception e) {
logger.debug("Failed chunk", e);
itemWriter.clear();
// TODO: need to force rollback as well
return new ChunkResponse(ExitStatus.FAILED.addExitDescription(e.getClass().getName() + ": "
+ e.getMessage()), chunk.getJobId(), skipCount);

View File

@@ -17,7 +17,7 @@ package org.springframework.batch.integration.item;
import java.util.List;
import org.springframework.batch.item.support.AbstractItemWriter;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.GenericMessage;
@@ -26,7 +26,7 @@ import org.springframework.integration.message.GenericMessage;
* @author Dave Syer
*
*/
public class MessageChannelItemWriter<T> extends AbstractItemWriter<T> {
public class MessageChannelItemWriter<T> implements ItemWriter<T> {
private MessageChannel channel;

View File

@@ -8,7 +8,7 @@ import org.junit.Test;
import org.springframework.batch.core.SkipListener;
import org.springframework.batch.core.listener.SkipListenerSupport;
import org.springframework.batch.core.step.skip.AlwaysSkipItemSkipPolicy;
import org.springframework.batch.item.support.AbstractItemWriter;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.util.StringUtils;
@@ -28,7 +28,7 @@ public class ItemWriterChunkHandlerTests {
@SuppressWarnings("unchecked")
@Test
public void testVanillaHandleChunk() {
handler.setItemWriter(new AbstractItemWriter<Object>() {
handler.setItemWriter(new ItemWriter<Object>() {
public void write(List<? extends Object> items) throws Exception {
count+=items.size();
}
@@ -44,7 +44,7 @@ public class ItemWriterChunkHandlerTests {
@SuppressWarnings("unchecked")
@Test
public void testSetItemSkipPolicy() {
handler.setItemWriter(new AbstractItemWriter<Object>() {
handler.setItemWriter(new ItemWriter<Object>() {
public void write(List<? extends Object> items) throws Exception {
count+=items.size();
throw new RuntimeException("Planned failure");
@@ -62,7 +62,7 @@ public class ItemWriterChunkHandlerTests {
@SuppressWarnings("unchecked")
@Test
public void testRegisterSkipListener() {
handler.setItemWriter(new AbstractItemWriter<Object>() {
handler.setItemWriter(new ItemWriter<Object>() {
public void write(List<? extends Object> items) throws Exception {
count+=items.size();
throw new RuntimeException("Planned failure");

View File

@@ -4,11 +4,11 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.item.support.AbstractItemWriter;
import org.springframework.batch.item.ItemWriter;
import org.springframework.stereotype.Component;
@Component
public class TestItemWriter<T> extends AbstractItemWriter<T> {
public class TestItemWriter<T> implements ItemWriter<T> {
private static final Log logger = LogFactory.getLog(TestItemWriter.class);