public class ResourcesItemReader extends ExecutionContextUserSupport implements ItemStreamReader<org.springframework.core.io.Resource>
ItemReader
which produces Resource
instances from an array.
This can be used conveniently with a configuration entry that injects a
pattern (e.g. mydir/*.txt
, which can then be converted by Spring
to an array of Resources by the ApplicationContext.
open(ExecutionContext)
. The
ExecutionContext
is not accurate in a multi-threaded environment, so
do not rely on that data for restart (i.e. always open with a fresh context).ResourceArrayPropertyEditor
Constructor and Description |
---|
ResourcesItemReader() |
Modifier and Type | Method and Description |
---|---|
void |
close()
If any resources are needed for the stream to operate they need to be destroyed here.
|
void |
open(ExecutionContext executionContext)
Open the stream for the provided
ExecutionContext . |
org.springframework.core.io.Resource |
read()
Increments a counter and returns the next
Resource instance from
the input, or null if none remain. |
void |
setResources(org.springframework.core.io.Resource[] resources)
The resources to serve up as items.
|
void |
update(ExecutionContext executionContext)
Indicates that the execution context provided during open is about to be saved.
|
getKey, getName, setName
public void setResources(org.springframework.core.io.Resource[] resources)
resources
- the resourcespublic org.springframework.core.io.Resource read() throws Exception
Resource
instance from
the input, or null if none remain.read
in interface ItemReader<org.springframework.core.io.Resource>
ParseException
- if there is a problem parsing the current record
(but the next one may still be valid)NonTransientResourceException
- if there is a fatal exception in
the underlying resource. After throwing this exception implementations
should endeavour to return null from subsequent calls to read.UnexpectedInputException
- if there is an uncategorised problem
with the input data. Assume potentially transient, so subsequent calls to
read might succeed.Exception
- if an there is a non-specific error.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 updatedItemStreamException
Copyright © 2013 SpringSource. All rights reserved.