|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
public abstract class AbstractItemCountingItemStreamItemReader<T>
Abstract superclass for ItemReader
s 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(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 Exception
Exception
protected abstract void doOpen() throws Exception
Exception
protected abstract void doClose() throws Exception
doOpen()
.
Exception
protected void jumpToItem(int itemIndex) throws Exception
doRead()
.
Exception
public final T read() throws Exception, UnexpectedInputException, ParseException
ItemReader
null
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>
Exception
- if an underlying resource is unavailable.
UnexpectedInputException
ParseException
protected 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 ItemStream
ItemStreamException
public void open(ExecutionContext executionContext) throws ItemStreamException
ItemStream
ExecutionContext
.
open
in interface ItemStream
ItemStreamException
public void update(ExecutionContext executionContext) throws ItemStreamException
ItemStream
update
in interface ItemStream
executionContext
- to be updated
ItemStreamException
public void setName(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 |