|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
public abstract class AbstractItemCountingItemStreamItemReader<T>
Abstract superclass for ItemReaders that supports restart by storing
item count in the ExecutionContext (therefore requires item ordering
to be preserved between runs).
Subclasses are inherently *not* thread-safe.
| Constructor Summary | |
|---|---|
AbstractItemCountingItemStreamItemReader()
|
|
| Method Summary | |
|---|---|
void |
close()
If any resources are needed for the stream to operate they need to be destroyed here. |
protected abstract void |
doClose()
Close the resources opened in doOpen(). |
protected abstract void |
doOpen()
Open resources necessary to start reading input. |
protected abstract T |
doRead()
Read next item from input. |
protected int |
getCurrentItemCount()
|
protected void |
jumpToItem(int itemIndex)
Move to the given item index. |
void |
open(ExecutionContext executionContext)
Open the stream for the provided ExecutionContext. |
T |
read()
Reads a piece of input data and advance to the next one. |
void |
setCurrentItemCount(int count)
The index of the item to start reading from. |
void |
setMaxItemCount(int count)
The maximum index of the items to be read. |
void |
setName(java.lang.String name)
The name of the component which will be used as a stem for keys in the ExecutionContext. |
void |
setSaveState(boolean saveState)
Set the flag that determines whether to save internal data for ExecutionContext. |
void |
update(ExecutionContext executionContext)
Indicates that the execution context provided during open is about to be saved. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractItemCountingItemStreamItemReader()
| Method Detail |
|---|
protected abstract T doRead()
throws java.lang.Exception
java.lang.Exception
protected abstract void doOpen()
throws java.lang.Exception
java.lang.Exception
protected abstract void doClose()
throws java.lang.Exception
doOpen().
java.lang.Exception
protected void jumpToItem(int itemIndex)
throws java.lang.Exception
doRead().
java.lang.Exception
public final T read()
throws java.lang.Exception,
UnexpectedInputException,
ParseException
ItemReadernull at the end of the input
data set. In a transactional setting, caller might get the same item
twice from successive calls (or otherwise), if the first call was in a
transaction that rolled back.
read in interface ItemReader<T>java.lang.Exception - if an underlying resource is unavailable.
UnexpectedInputException
ParseExceptionprotected int getCurrentItemCount()
public void setCurrentItemCount(int count)
ExecutionContext contains a key [name].read.count
(where [name] is the name of this component) the value from
the ExecutionContext will be used in preference.
count - the value of the current item countsetName(String)public void setMaxItemCount(int count)
ExecutionContext contains a key [name].read.count.max
(where [name] is the name of this component) the value from
the ExecutionContext will be used in preference.
count - the value of the maximum item countsetName(String)
public void close()
throws ItemStreamException
ItemStream
close in interface ItemStreamItemStreamException
public void open(ExecutionContext executionContext)
throws ItemStreamException
ItemStreamExecutionContext.
open in interface ItemStreamItemStreamException
public void update(ExecutionContext executionContext)
throws ItemStreamException
ItemStream
update in interface ItemStreamexecutionContext - to be updated
ItemStreamExceptionpublic void setName(java.lang.String name)
ExecutionContext. Subclasses should provide a default value, e.g.
the short form of the class name.
name - the name for the componentpublic void setSaveState(boolean saveState)
ExecutionContext. Only switch this to false if you don't want to
save any state from this stream, and you don't need it to be restartable.
saveState - flag value (default true).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||