类 ResourcesItemReader
- java.lang.Object
- org.springframework.batch.item.ItemStreamSupport
- org.springframework.batch.item.support.AbstractItemStreamItemReader<org.springframework.core.io.Resource>
- org.springframework.batch.item.file.ResourcesItemReader
- 所有已实现的接口:
ItemReader<org.springframework.core.io.Resource>
,ItemStream
,ItemStreamReader<org.springframework.core.io.Resource>
public class ResourcesItemReader extends AbstractItemStreamItemReader<org.springframework.core.io.Resource>
ItemReader
which producesResource
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 toopen(ExecutionContext)
. TheExecutionContext
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).- 从以下版本开始:
- 2.1
- 作者:
- Dave Syer, Mahmoud Ben Hassine
- 另请参阅:
ResourceArrayPropertyEditor
构造器概要
构造器 构造器 说明 ResourcesItemReader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
open(ExecutionContext executionContext)
No-op.org.springframework.core.io.Resource
read()
Increments a counter and returns the nextResource
instance from the input, ornull
if none remain.void
setResources(org.springframework.core.io.Resource[] resources)
The resources to serve up as items.void
update(ExecutionContext executionContext)
Return emptyExecutionContext
.从类继承的方法 org.springframework.batch.item.ItemStreamSupport
close, getExecutionContextKey, setExecutionContextName, setName
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.batch.item.ItemStream
close
构造器详细资料
ResourcesItemReader
public ResourcesItemReader()
方法详细资料
setResources
public void setResources(org.springframework.core.io.Resource[] resources)
The resources to serve up as items. Hint: use a pattern to configure.- 参数:
resources
- the resources
read
@Nullable public org.springframework.core.io.Resource read() throws java.lang.Exception
Increments a counter and returns the nextResource
instance from the input, ornull
if none remain.- 返回:
- T the item to be processed or
null
if the data source is exhausted - 抛出:
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.java.lang.Exception
- if an there is a non-specific error.
open
public void open(ExecutionContext executionContext) throws ItemStreamException
从类复制的说明:ItemStreamSupport
No-op.- 指定者:
open
在接口中ItemStream
- 覆盖:
open
在类中ItemStreamSupport
- 参数:
executionContext
- current step'sExecutionContext
. Will be the executionContext from the last run of the step on a restart.- 抛出:
ItemStreamException
- 另请参阅:
ItemStream.open(ExecutionContext)
update
public void update(ExecutionContext executionContext) throws ItemStreamException
从类复制的说明:ItemStreamSupport
Return emptyExecutionContext
.- 指定者:
update
在接口中ItemStream
- 覆盖:
update
在类中ItemStreamSupport
- 参数:
executionContext
- to be updated- 抛出:
ItemStreamException
- 另请参阅:
ItemStream.update(ExecutionContext)