Class ResourcesItemReader
java.lang.Object
org.springframework.batch.infrastructure.item.ItemStreamSupport
org.springframework.batch.infrastructure.item.support.AbstractItemStreamItemReader<org.springframework.core.io.Resource>
org.springframework.batch.infrastructure.item.file.ResourcesItemReader
- All Implemented Interfaces:
ItemReader<org.springframework.core.io.Resource>, ItemStream, ItemStreamReader<org.springframework.core.io.Resource>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware
public class ResourcesItemReader
extends AbstractItemStreamItemReader<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.
Thread-safe between calls to
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).- Since:
- 2.1
- Author:
- Dave Syer, Mahmoud Ben Hassine, Jimmy Praet
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidopen(ExecutionContext executionContext) Open the stream for the providedExecutionContext.@Nullable org.springframework.core.io.Resourceread()Increments a counter and returns the nextResourceinstance from the input, ornullif none remain.voidsetResources(org.springframework.core.io.Resource[] resources) The resources to serve up as items.voidupdate(ExecutionContext executionContext) Indicates that the execution context provided during open is about to be saved.Methods inherited from class ItemStreamSupport
getExecutionContextKey, getName, setBeanName, setExecutionContextName, setNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ItemStream
close
-
Constructor Details
-
ResourcesItemReader
public ResourcesItemReader()
-
-
Method Details
-
setResources
public void setResources(org.springframework.core.io.Resource[] resources) The resources to serve up as items. Hint: use a pattern to configure.- Parameters:
resources- the resources
-
read
-
open
Description copied from interface:ItemStreamOpen the stream for the providedExecutionContext.- Parameters:
executionContext- current step'sExecutionContext. Will be the executionContext from the last run of the step on a restart.- Throws:
ItemStreamException
-
update
Description copied from interface:ItemStreamIndicates that the execution context provided during open is about to be saved. If any state is remaining, but has not been put in the context, it should be added here.- Parameters:
executionContext- to be updated- Throws:
ItemStreamException
-