OPEN - issue BATCH-789: Remove mark/reset from ItemReader
This commit is contained in:
@@ -48,33 +48,4 @@ public interface ItemReader<T> {
|
||||
*/
|
||||
T read() throws Exception, UnexpectedInputException, NoWorkFoundException, ParseException;
|
||||
|
||||
/**
|
||||
* Mark the stream so that it can be reset later and the items backed
|
||||
* out.<br/>
|
||||
*
|
||||
* Mark is called before reading a new chunk of items - in case of rollback
|
||||
* mark will not be called again before re-processing the chunk.<br/>
|
||||
*
|
||||
* @throws MarkFailedException if there is a problem with the mark. If a
|
||||
* mark fails inside a transaction, it would be worrying, but not normally
|
||||
* fatal.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
void mark() throws MarkFailedException;
|
||||
|
||||
/**
|
||||
* Reset the stream to the last mark. After a reset the stream state will be
|
||||
* such that changes (items read or written) since the last call to mark
|
||||
* will not be visible after a call to close.<br/>
|
||||
*
|
||||
* @throws ResetFailedException if there is a problem with the reset. If a
|
||||
* reset fails inside a transaction, it would normally be fatal, and would
|
||||
* leave the stream in an inconsistent state. So while this is an unchecked
|
||||
* exception, it may be important for a client to catch it explicitly.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
void reset() throws ResetFailedException;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package org.springframework.batch.item.adapter;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.MarkFailedException;
|
||||
import org.springframework.batch.item.ResetFailedException;
|
||||
|
||||
/**
|
||||
* Invokes a custom method on a delegate plain old Java object which itself
|
||||
@@ -35,15 +33,4 @@ public class ItemReaderAdapter<T> extends AbstractMethodInvokingDelegator<T> imp
|
||||
return invokeDelegateMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
public void mark() throws MarkFailedException {
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
public void reset() throws ResetFailedException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,12 +169,6 @@ public class DrivingQueryItemReader<T> implements ItemReader<T>, InitializingBea
|
||||
this.keyCollector = keyCollector;
|
||||
}
|
||||
|
||||
public void mark() {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
public void setSaveState(boolean saveState) {
|
||||
this.saveState = saveState;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@ import org.hibernate.ScrollableResults;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.StatelessSession;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.support.AbstractItemReaderItemStream;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -121,15 +123,11 @@ public class HibernateCursorItemReader<T> extends AbstractItemReaderItemStream<T
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Clears the session if not stateful and delegates to super class.
|
||||
*/
|
||||
public void mark() {
|
||||
|
||||
super.mark();
|
||||
|
||||
@Override
|
||||
public void update(ExecutionContext executionContext) throws ItemStreamException {
|
||||
super.update(executionContext);
|
||||
if (!useStatelessSession) {
|
||||
statefulSession.clear();
|
||||
}
|
||||
@@ -161,7 +159,7 @@ public class HibernateCursorItemReader<T> extends AbstractItemReaderItemStream<T
|
||||
item = data[0];
|
||||
}
|
||||
|
||||
return (T)item;
|
||||
return (T) item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ import org.springframework.util.ClassUtils;
|
||||
*
|
||||
* <p>
|
||||
* Transactions: The same ResultSet is held open regardless of commits or roll
|
||||
* backs in a surrounding transaction. This means that when such a transaction
|
||||
* is committed, the reader is notified through the {@link #mark()} and
|
||||
* {@link #reset()} so that it can save it's current row number. Later, if the
|
||||
* transaction is rolled back, the current row can be moved back to the same row
|
||||
* number as it was on when commit was called.
|
||||
* backs in a surrounding transaction. When a transaction is committed, the
|
||||
* reader will be notified through the {@link #update(ExecutionContext)} so that
|
||||
* it can save it's current row number. Clients of this reader are responsible
|
||||
* for buffering the items in the case that they need to be re-presented on a
|
||||
* rollback.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
@@ -259,7 +259,7 @@ public class JdbcCursorItemReader<T> extends AbstractItemReaderItemStream<T> imp
|
||||
private void moveCursorToRow(int row) {
|
||||
try {
|
||||
int count = 0;
|
||||
while (row!=count && rs.next()) {
|
||||
while (row != count && rs.next()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -294,9 +294,8 @@ public class JdbcCursorItemReader<T> extends AbstractItemReaderItemStream<T> imp
|
||||
|
||||
/**
|
||||
* Sets the number of seconds the driver will wait for a
|
||||
* <code>Statement</code> object to execute to the given number of
|
||||
* seconds. If the limit is exceeded, an <code>SQLException</code> is
|
||||
* thrown.
|
||||
* <code>Statement</code> object to execute to the given number of seconds.
|
||||
* If the limit is exceeded, an <code>SQLException</code> is thrown.
|
||||
*
|
||||
* @param queryTimeout seconds the new query timeout limit in seconds; zero
|
||||
* means there is no limit
|
||||
@@ -359,9 +358,9 @@ public class JdbcCursorItemReader<T> extends AbstractItemReaderItemStream<T> imp
|
||||
/**
|
||||
* Indicate whether the JDBC driver supports setting the absolute row on a
|
||||
* {@link ResultSet}. It is recommended that this is set to
|
||||
* <code>true</code> for JDBC drivers that supports ResultSet.absolute()
|
||||
* as it may improve performance, especially if a step fails while working
|
||||
* with a large data set.
|
||||
* <code>true</code> for JDBC drivers that supports ResultSet.absolute() as
|
||||
* it may improve performance, especially if a step fails while working with
|
||||
* a large data set.
|
||||
*
|
||||
* @see ResultSet#absolute(int)
|
||||
*
|
||||
|
||||
@@ -99,15 +99,8 @@ public class JpaPagingItemReader<T> extends AbstractItemReaderItemStream<T> impl
|
||||
this.queryString = queryString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark() {
|
||||
|
||||
super.mark();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of entities to retreive at a time.
|
||||
* The number of entities to retrieve at a time.
|
||||
*
|
||||
* @param pageSize the number of rows to fetch, 10 by default
|
||||
* @see javax.persistence.Query#setMaxResults(int)
|
||||
|
||||
@@ -7,10 +7,8 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.MarkFailedException;
|
||||
import org.springframework.batch.item.NoWorkFoundException;
|
||||
import org.springframework.batch.item.ParseException;
|
||||
import org.springframework.batch.item.ResetFailedException;
|
||||
import org.springframework.batch.item.UnexpectedInputException;
|
||||
import org.springframework.batch.item.util.ExecutionContextUserSupport;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -96,19 +94,6 @@ public class MultiResourceItemReader<T> implements ItemReader<T>, ItemStream {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the longer needed items from buffer, mark the index position and
|
||||
* call mark() on delegate so that it clears its buffers.
|
||||
*/
|
||||
public void mark() throws MarkFailedException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches to 'read from buffer' state.
|
||||
*/
|
||||
public void reset() throws ResetFailedException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the {@link #setDelegate(ResourceAwareItemReaderItemStream)} reader
|
||||
* and reset instance variable values.
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package org.springframework.batch.item.support;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.MarkFailedException;
|
||||
import org.springframework.batch.item.ResetFailedException;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,9 +26,4 @@ import org.springframework.batch.item.ResetFailedException;
|
||||
*/
|
||||
public abstract class AbstractItemReader<T> implements ItemReader<T> {
|
||||
|
||||
public void mark() throws MarkFailedException {
|
||||
}
|
||||
|
||||
public void reset() throws ResetFailedException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,18 +63,6 @@ public abstract class AbstractItemReaderItemStream<T> implements ItemReader<T>,
|
||||
return doRead();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void mark() {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
protected int getCurrentItemCount() {
|
||||
return currentItemCount;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ import java.util.List;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.MarkFailedException;
|
||||
import org.springframework.batch.item.ResetFailedException;
|
||||
|
||||
/**
|
||||
* An {@link ItemReader} that delivers a list as its item, storing up objects
|
||||
@@ -96,12 +94,6 @@ public class AggregateItemReader<T> implements ItemReader<List<T>> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void mark() throws MarkFailedException {
|
||||
}
|
||||
|
||||
public void reset() throws ResetFailedException {
|
||||
}
|
||||
|
||||
public void setItemReader(ItemReader<AggregateItem<T>> itemReader) {
|
||||
this.itemReader = itemReader;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user