|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.item.support.AbstractBufferedItemReaderItemStream
public abstract class AbstractBufferedItemReaderItemStream
Abstract superclass for ItemReaders which use item buffering to
support reset/rollback. 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 | |
|---|---|
AbstractBufferedItemReaderItemStream()
|
|
| Method Summary | |
|---|---|
void |
close(ExecutionContext executionContext)
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 Object |
doRead()
Read next item from input. |
protected int |
getCurrentItemCount()
|
protected void |
jumpToItem(int itemIndex)
Move to the given item index. |
void |
mark()
Mark is supported as long as this ItemStream is used in a
single-threaded environment. |
void |
open(ExecutionContext executionContext)
Open the stream for the provided ExecutionContext. |
Object |
read()
Reads a piece of input data and advance to the next one. |
void |
reset()
Reset the stream to the last mark. |
protected void |
setCurrentItemCount(int count)
|
void |
setName(String name)
|
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 AbstractBufferedItemReaderItemStream()
| Method Detail |
|---|
protected abstract Object 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 Object read()
throws Exception,
UnexpectedInputException,
NoWorkFoundException,
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 ItemReaderException - if an underlying resource is unavailable.
UnexpectedInputException
NoWorkFoundException
ParseException
public void mark()
throws MarkFailedException
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.
mark in interface ItemReaderMarkFailedException - if there is a problem with the mark. If a
mark fails inside a transaction, it would be worrying, but not normally
fatal.AbstractItemReader.mark()
public void reset()
throws ResetFailedException
ItemReader
reset in interface ItemReaderResetFailedException - 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.protected int getCurrentItemCount()
protected void setCurrentItemCount(int count)
public void close(ExecutionContext executionContext)
throws ItemStreamException
ItemStream
close in interface ItemStreamexecutionContext - the current execution context in case it is needed
ItemStreamException
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(String name)
public 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 | |||||||||