diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java index fabab92a5..0d4a73a61 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java @@ -25,6 +25,7 @@ import org.hibernate.SessionFactory; import org.hibernate.StatelessSession; import org.springframework.batch.io.Skippable; import org.springframework.batch.item.ItemReader; +import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.StreamContext; import org.springframework.batch.item.reader.AbstractItemStreamItemReader; import org.springframework.beans.factory.DisposableBean; @@ -218,8 +219,10 @@ public class HibernateCursorItemReader extends AbstractItemStreamItemReader impl } /** - * Always true, but only supported through a single processed row count, so - * do not use in an asynchronous setting. + * Mark is supported as long as this {@link ItemStream} is used in a + * single-threaded environment. The state backing the mark is a single + * counter, keeping track of the current position, so multiple threads + * cannot be accommodated. * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java index ca5337495..6e1d0f2ec 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java @@ -223,7 +223,10 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource } /** - * Returns true. + * Mark is supported as long as this {@link ItemStream} is used in a + * single-threaded environment. The state backing the mark is a single + * counter, keeping track of the current position, so multiple threads + * cannot be accommodated. * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java index 6ee490e2b..ad38a71fe 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java @@ -29,10 +29,10 @@ import org.springframework.batch.item.StreamException; /** *
- * This class is a {@link FieldSetItemReader} that supports restart, - * skipping invalid lines and storing statistics. + * This class is a {@link FieldSetItemReader} that supports restart, skipping + * invalid lines and storing statistics. *
- * + * * @author Waseem Malik * @author Tomas Slanina * @author Robert Kasanicky @@ -49,7 +49,7 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen private Set skippedLines = new HashSet(); /** - * Initialize the input source. + * Initialize the input source. */ public void open() { super.open(); @@ -60,15 +60,13 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen * This method initialises the Input Source for Restart. It opens the input * file and position the buffer reader according to information provided by * the restart data - * + * * @param data {@link StreamContext} information */ public void restoreFrom(StreamContext data) { - if (data==null || - data.getProperties() == null || - data.getProperties().getProperty(READ_STATISTICS_NAME) == null || - getReader()==null) { + if (data == null || data.getProperties() == null + || data.getProperties().getProperty(READ_STATISTICS_NAME) == null || getReader() == null) { // do nothing return; } @@ -82,7 +80,7 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen while (reader.getCurrentLineCount() < lineCount && record != null) { record = readLine(); } - + mark(data); } @@ -93,7 +91,7 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen * case of restart. */ public StreamContext getStreamContext() { - if (reader==null) { + if (reader == null) { throw new StreamException("ItemStream not open or already closed."); } StreamContext streamContext = new StreamContext(); @@ -102,21 +100,28 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen return streamContext; } - /* (non-Javadoc) + /** + * Mark is supported as long as this {@link ItemStream} is used in a + * single-threaded environment. The state backing the mark is a single + * counter, keeping track of the current position, so multiple threads + * cannot be accommodated. + * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ public boolean isMarkSupported() { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) */ public void mark(StreamContext streamContext) { getReader().mark(); } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) */ public void reset(StreamContext streamContext) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java index 9abfedb02..2ec00b8a5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java @@ -538,7 +538,11 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements } /** - * Returns true. + * Mark is supported as long as this {@link ItemStream} is used in a + * single-threaded environment. The state backing the mark is a single + * counter, keeping track of the current position, so multiple threads + * cannot be accommodated. + * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ public boolean isMarkSupported() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java index f830eea84..464cb99bb 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java @@ -251,7 +251,12 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade close(); } - /* (non-Javadoc) + /** + * Mark is supported as long as this {@link ItemStream} is used in a + * single-threaded environment. The state backing the mark is a single + * counter, keeping track of the current position, so multiple threads + * cannot be accommodated. + * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ public boolean isMarkSupported() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java index 44853109e..06dd79047 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java @@ -435,7 +435,12 @@ public class StaxEventItemWriter implements ItemWriter, ItemStream, Initializing } - /* (non-Javadoc) + /** + * Mark is supported as long as this {@link ItemStream} is used in a + * single-threaded environment. The state backing the mark is a single + * counter, keeping track of the current position, so multiple threads + * cannot be accommodated. + * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ public boolean isMarkSupported() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java index 0b27ea197..1a2f55d58 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java @@ -104,7 +104,9 @@ public class DelegatingItemReader extends AbstractItemReader implements Skippabl } } - /* (non-Javadoc) + /** + * Delegates the call if the delegate is an {@link ItemStream}. + * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ public boolean isMarkSupported() { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java index 9ff2943c3..ef7c1b041 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java @@ -204,8 +204,11 @@ public class StagingItemReader extends JdbcDaoSupport implements ItemStream, Key } } - /* - * (non-Javadoc) + /** + * Mark is supported in a multi- as well as a single-threaded environment. + * The state backing the mark is a buffer, and access is synchronized, so + * multiple threads cannot be accommodated. + * * @see org.springframework.batch.item.ItemStream#isMarkSupported() */ public boolean isMarkSupported() {