|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.util.ExecutionContextUserSupport org.springframework.batch.item.file.MultiResourceItemReader
public class MultiResourceItemReader
Reads items from multiple resources sequentially - resource list is given by
setResources(Resource[])
, the actual reading is delegated to
setDelegate(ResourceAwareItemReaderItemStream)
.
Input resources are ordered using setComparator(Comparator)
to make
sure resource ordering is preserved between job runs in restart scenario.
Reset (rollback) capability is implemented by item buffering.
Constructor Summary | |
---|---|
MultiResourceItemReader()
|
Method Summary | |
---|---|
void |
close(ExecutionContext executionContext)
Close the setDelegate(ResourceAwareItemReaderItemStream) reader
and reset instance variable values. |
void |
mark()
Remove the longer needed items from buffer, mark the index position and call mark() on delegate so that it clears its buffers. |
void |
open(ExecutionContext executionContext)
Figure out which resource to start with in case of restart, open the delegate and restore delegate's position in the resource. |
Object |
read()
Reads the next item, jumping to next resource if necessary. |
void |
reset()
Switches to 'read from buffer' state. |
void |
setComparator(Comparator comparator)
|
void |
setDelegate(ResourceAwareItemReaderItemStream delegate)
|
void |
setResources(Resource[] resources)
|
void |
setSaveState(boolean saveState)
Set the boolean indicating whether or not state should be saved in the provided ExecutionContext during the ItemStream call to
update. |
void |
update(ExecutionContext executionContext)
Store the current resource index and position in the resource. |
Methods inherited from class org.springframework.batch.item.util.ExecutionContextUserSupport |
---|
getKey, setName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultiResourceItemReader()
Method Detail |
---|
public Object read() throws Exception, UnexpectedInputException, NoWorkFoundException, ParseException
read
in interface ItemReader
Exception
- if an underlying resource is unavailable.
UnexpectedInputException
NoWorkFoundException
ParseException
public void mark() throws MarkFailedException
mark
in interface ItemReader
MarkFailedException
- if there is a problem with the mark. If a
mark fails inside a transaction, it would be worrying, but not normally
fatal.public void reset() throws ResetFailedException
reset
in interface ItemReader
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.ItemReader.reset()
public void close(ExecutionContext executionContext) throws ItemStreamException
setDelegate(ResourceAwareItemReaderItemStream)
reader
and reset instance variable values.
close
in interface ItemStream
executionContext
- the current execution context in case it is needed
ItemStreamException
public void open(ExecutionContext executionContext) throws ItemStreamException
open
in interface ItemStream
ItemStreamException
public void update(ExecutionContext executionContext) throws ItemStreamException
update
in interface ItemStream
executionContext
- to be updated
ItemStreamException
public void setDelegate(ResourceAwareItemReaderItemStream delegate)
delegate
- reads items from single Resource
.public void setSaveState(boolean saveState)
ExecutionContext
during the ItemStream
call to
update.
saveState
- public void setComparator(Comparator comparator)
comparator
- used to order the injected resources, by default
compares Resource.getFilename()
values.public void setResources(Resource[] resources)
resources
- input resources
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |