类 SimpleStepBuilder<I,O>
- java.lang.Object
- org.springframework.batch.core.step.builder.StepBuilderHelper<AbstractTaskletStepBuilder<B>>
- org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>
- org.springframework.batch.core.step.builder.SimpleStepBuilder<I,O>
public class SimpleStepBuilder<I,O> extends AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>
Step builder for simple item processing (chunk oriented) steps. Items are read and cached in chunks, and then processed (transformed) and written (optionally either the processor or the writer can be omitted) all in the same transaction.- 从以下版本开始:
- 2.2
- 作者:
- Dave Syer, Mahmoud Ben Hassine
- 另请参阅:
for a step that handles retry and skip of failed items
嵌套类概要
从类继承的嵌套类/接口 org.springframework.batch.core.step.builder.StepBuilderHelper
StepBuilderHelper.CommonStepProperties
字段概要
从类继承的字段 org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder
chunkListeners
从类继承的字段 org.springframework.batch.core.step.builder.StepBuilderHelper
logger, properties
构造器概要
构造器 限定符 构造器 说明 protected
SimpleStepBuilder(SimpleStepBuilder<I,O> parent)
Create a new builder initialized with any properties in the parent.SimpleStepBuilder(StepBuilderHelper<?> parent)
Create a new builder initialized with any properties in the parent.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 TaskletStep
build()
Build a step with the reader, writer, processor as provided.SimpleStepBuilder<I,O>
chunk(int chunkSize)
Sets the chunk size or commit interval for this step.SimpleStepBuilder<I,O>
chunk(CompletionPolicy completionPolicy)
Sets a completion policy for the chunk processing.SimpleStepBuilder<I,O>
chunkOperations(RepeatOperations repeatTemplate)
Instead of achunk size
orcompletion policy
you can provide a complete repeat operations instance that handles the iteration over the item reader.protected RepeatOperations
createChunkOperations()
protected Tasklet
createTasklet()
FaultTolerantStepBuilder<I,O>
faultTolerant()
protected CompletionPolicy
getChunkCompletionPolicy()
protected int
getChunkSize()
protected java.util.Set<StepListener>
getItemListeners()
protected ItemProcessor<? super I,? extends O>
getProcessor()
protected ItemReader<? extends I>
getReader()
protected ItemWriter<? super O>
getWriter()
protected boolean
isReaderTransactionalQueue()
SimpleStepBuilder<I,O>
listener(java.lang.Object listener)
Registers objects using the annotation based listener configuration.SimpleStepBuilder<I,O>
listener(ItemProcessListener<? super I,? super O> listener)
Register an item processor listener.SimpleStepBuilder<I,O>
listener(ItemReadListener<? super I> listener)
Register an item reader listener.SimpleStepBuilder<I,O>
listener(ItemWriteListener<? super O> listener)
Register an item writer listener.SimpleStepBuilder<I,O>
processor(java.util.function.Function<? super I,? extends O> function)
AFunction
to be delegated to as anItemProcessor
.SimpleStepBuilder<I,O>
processor(ItemProcessor<? super I,? extends O> processor)
An item processor that processes or transforms a stream of items.SimpleStepBuilder<I,O>
reader(ItemReader<? extends I> reader)
An item reader that provides a stream of items.SimpleStepBuilder<I,O>
readerIsTransactionalQueue()
Sets a flag to say that the reader is transactional (usually a queue), which is to say that failed items might be rolled back and re-presented in a subsequent transaction.protected void
registerAsStreamsAndListeners(ItemReader<? extends I> itemReader, ItemProcessor<? super I,? extends O> itemProcessor, ItemWriter<? super O> itemWriter)
protected void
registerStepListenerAsItemListener()
SimpleStepBuilder<I,O>
writer(ItemWriter<? super O> writer)
An item writer that writes a chunk of items.从类继承的方法 org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder
concurrent, exceptionHandler, getExceptionHandler, getStepOperations, getStreams, getTaskExecutor, getThrottleLimit, getTransactionAttribute, listener, registerStepListenerAsChunkListener, stepOperations, stream, taskExecutor, throttleLimit, transactionAttribute
从类继承的方法 org.springframework.batch.core.step.builder.StepBuilderHelper
allowStartIfComplete, enhance, getJobRepository, getName, getTransactionManager, isAllowStartIfComplete, listener, repository, startLimit, transactionManager
构造器详细资料
SimpleStepBuilder
public SimpleStepBuilder(StepBuilderHelper<?> parent)
Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used.- 参数:
parent
- a parent helper containing common step properties
SimpleStepBuilder
protected SimpleStepBuilder(SimpleStepBuilder<I,O> parent)
Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used.- 参数:
parent
- a parent helper containing common step properties
方法详细资料
faultTolerant
public FaultTolerantStepBuilder<I,O> faultTolerant()
build
public TaskletStep build()
Build a step with the reader, writer, processor as provided.- 覆盖:
build
在类中AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>
- 返回:
- a tasklet step fully configured and ready to execute
- 另请参阅:
AbstractTaskletStepBuilder.build()
registerStepListenerAsItemListener
protected void registerStepListenerAsItemListener()
createTasklet
protected Tasklet createTasklet()
- 指定者:
createTasklet
在类中AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>
chunk
public SimpleStepBuilder<I,O> chunk(int chunkSize)
Sets the chunk size or commit interval for this step. This is the maximum number of items that will be read before processing starts in a single transaction. Not compatible withcompletionPolicy
.- 参数:
chunkSize
- the chunk size (a.k.a commit interval)- 返回:
- this for fluent chaining
chunk
public SimpleStepBuilder<I,O> chunk(CompletionPolicy completionPolicy)
Sets a completion policy for the chunk processing. Items are read until this policy determines that a chunk is complete, giving more control than with just thechunk size
(or commit interval).- 参数:
completionPolicy
- a completion policy for the chunk- 返回:
- this for fluent chaining
reader
public SimpleStepBuilder<I,O> reader(ItemReader<? extends I> reader)
An item reader that provides a stream of items. Will be automatically registered as aAbstractTaskletStepBuilder.stream(ItemStream)
or listener if it implements the corresponding interface. By default assumed to be non-transactional.- 参数:
reader
- an item reader- 返回:
- this for fluent chaining
- 另请参阅:
readerTransactionalQueue
writer
public SimpleStepBuilder<I,O> writer(ItemWriter<? super O> writer)
An item writer that writes a chunk of items. Will be automatically registered as aAbstractTaskletStepBuilder.stream(ItemStream)
or listener if it implements the corresponding interface.- 参数:
writer
- an item writer- 返回:
- this for fluent chaining
processor
public SimpleStepBuilder<I,O> processor(ItemProcessor<? super I,? extends O> processor)
An item processor that processes or transforms a stream of items. Will be automatically registered as aAbstractTaskletStepBuilder.stream(ItemStream)
or listener if it implements the corresponding interface.- 参数:
processor
- an item processor- 返回:
- this for fluent chaining
processor
public SimpleStepBuilder<I,O> processor(java.util.function.Function<? super I,? extends O> function)
AFunction
to be delegated to as anItemProcessor
. If this is set, it will take precedence over anyItemProcessor
configured viaprocessor(ItemProcessor)
.- 参数:
function
- the function to delegate item processing to- 返回:
- this for fluent chaining
readerIsTransactionalQueue
public SimpleStepBuilder<I,O> readerIsTransactionalQueue()
Sets a flag to say that the reader is transactional (usually a queue), which is to say that failed items might be rolled back and re-presented in a subsequent transaction. Default is false, meaning that the items are read outside a transaction and possibly cached.- 返回:
- this for fluent chaining
listener
public SimpleStepBuilder<I,O> listener(java.lang.Object listener)
Registers objects using the annotation based listener configuration.- 覆盖:
listener
在类中AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>
- 参数:
listener
- the object that has a method configured with listener annotation- 返回:
- this for fluent chaining
listener
public SimpleStepBuilder<I,O> listener(ItemReadListener<? super I> listener)
Register an item reader listener.- 参数:
listener
- the listener to register- 返回:
- this for fluent chaining
listener
public SimpleStepBuilder<I,O> listener(ItemWriteListener<? super O> listener)
Register an item writer listener.- 参数:
listener
- the listener to register- 返回:
- this for fluent chaining
listener
public SimpleStepBuilder<I,O> listener(ItemProcessListener<? super I,? super O> listener)
Register an item processor listener.- 参数:
listener
- the listener to register- 返回:
- this for fluent chaining
chunkOperations
public SimpleStepBuilder<I,O> chunkOperations(RepeatOperations repeatTemplate)
Instead of achunk size
orcompletion policy
you can provide a complete repeat operations instance that handles the iteration over the item reader.- 参数:
repeatTemplate
- a complete repeat template for the chunk- 返回:
- this for fluent chaining
createChunkOperations
protected RepeatOperations createChunkOperations()
getReader
protected ItemReader<? extends I> getReader()
getWriter
protected ItemWriter<? super O> getWriter()
getProcessor
protected ItemProcessor<? super I,? extends O> getProcessor()
getChunkSize
protected int getChunkSize()
isReaderTransactionalQueue
protected boolean isReaderTransactionalQueue()
getItemListeners
protected java.util.Set<StepListener> getItemListeners()
getChunkCompletionPolicy
protected CompletionPolicy getChunkCompletionPolicy()
- 返回:
- a
CompletionPolicy
consistent with the chunk size and injected policy (if present).
registerAsStreamsAndListeners
protected void registerAsStreamsAndListeners(ItemReader<? extends I> itemReader, ItemProcessor<? super I,? extends O> itemProcessor, ItemWriter<? super O> itemWriter)