|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.file.MultiResourceItemReader<T>
public class MultiResourceItemReader<T>
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()
Close the setDelegate(ResourceAwareItemReaderItemStream) reader
and reset instance variable values. |
Resource |
getCurrentResource()
|
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. |
T |
read()
Reads the next item, jumping to next resource if necessary. |
void |
setComparator(Comparator<Resource> comparator)
|
void |
setDelegate(ResourceAwareItemReaderItemStream<? extends T> 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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultiResourceItemReader()
Method Detail |
---|
public T read() throws Exception, UnexpectedInputException, ParseException
read
in interface ItemReader<T>
Exception
- if an underlying resource is unavailable.
UnexpectedInputException
ParseException
public void close() throws ItemStreamException
setDelegate(ResourceAwareItemReaderItemStream)
reader
and reset instance variable values.
close
in interface ItemStream
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<? extends T> delegate)
delegate
- reads items from single Resource
.public void setSaveState(boolean saveState)
ExecutionContext
during the ItemStream
call to
update.
saveState
- public void setComparator(Comparator<Resource> comparator)
comparator
- used to order the injected resources, by default
compares Resource.getFilename()
values.public void setResources(Resource[] resources)
resources
- input resourcespublic Resource getCurrentResource()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |