IN PROGRESS - issue BATCH-7: Remove transaction synchronization and state management from input/output sources (formerly buffering)

http://jira.springframework.org/browse/BATCH-7

Added mark()/reset() to ItemStream, and implementations.
This commit is contained in:
dsyer
2008-01-31 16:31:31 +00:00
parent 4a10c64b2e
commit 74d4ec612c
18 changed files with 388 additions and 81 deletions

View File

@@ -50,5 +50,27 @@ class FooItemReader extends AbstractItemReader implements ItemStream, ItemReader
};
public void close() {
}
/**
* True.
* @see org.springframework.batch.item.ItemStream#isMarkSupported()
*/
public boolean isMarkSupported() {
return true;
}
/* (non-Javadoc)
* @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext)
*/
public void mark(StreamContext streamContext) {
inputSource.mark(streamContext);
}
/* (non-Javadoc)
* @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext)
*/
public void reset(StreamContext streamContext) {
inputSource.reset(streamContext);
};
}

View File

@@ -20,6 +20,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.item.StreamContext;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.transaction.support.TransactionSynchronizationUtils;
@@ -102,12 +103,12 @@ public class AbstractTransactionalIoSourceTests extends TestCase {
private boolean commitCalled = false;
private boolean rollbackCalled = false;
protected void transactionCommitted() {
public void mark(StreamContext streamContext) {
Assert.isTrue(!commitCalled, "Commit aleady called");
commitCalled = true;
}
protected void transactionRolledBack() {
public void reset(StreamContext streamContext) {
Assert.isTrue(!rollbackCalled, "Rollback aleady called");
rollbackCalled = true;
}

View File

@@ -126,6 +126,16 @@ public class DelegatingItemReaderTests extends TestCase {
value = "after skip";
}
public boolean isMarkSupported() {
return false;
}
public void mark(StreamContext streamContext) {
}
public void reset(StreamContext streamContext) {
}
}
}

View File

@@ -22,7 +22,6 @@ import java.util.Properties;
import junit.framework.TestCase;
import org.springframework.batch.io.Skippable;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.stream.GenericStreamContext;
@@ -128,7 +127,7 @@ public class ItemWriterItemProcessorTests extends TestCase {
* @author Dave Syer
*
*/
public class MockOutputSource implements ItemWriter, ItemStream, Skippable {
public class MockOutputSource extends AbstractItemStreamItemWriter implements Skippable {
private String value;