Class AbstractTaskletStepBuilder<B extends AbstractTaskletStepBuilder<B>>
java.lang.Object
org.springframework.batch.core.step.builder.StepBuilderHelper<B>
org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder<B>
- Type Parameters:
B
- the type of builder represented
- Direct Known Subclasses:
SimpleStepBuilder
,TaskletStepBuilder
public abstract class AbstractTaskletStepBuilder<B extends AbstractTaskletStepBuilder<B>>
extends StepBuilderHelper<B>
Base class for step builders that want to build a
TaskletStep
. Handles common
concerns across all tasklet step variants, which are mostly to do with the type of
tasklet they carry.- Since:
- 2.2
- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
StepBuilderHelper.CommonStepProperties
-
Field Summary
FieldsFields inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
logger, properties
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the step from the components collected by the fluent setters.protected boolean
Convenience method for subclasses to determine if the step is concurrent.protected abstract Tasklet
exceptionHandler
(ExceptionHandler exceptionHandler) Sets the exception handler to use in the case of tasklet failures.protected ExceptionHandler
Convenience method for subclasses to access the exception handler that was injected by user.protected RepeatOperations
Convenience method for subclasses to access the step operations that were injected by user.protected Set<ItemStream>
protected org.springframework.core.task.TaskExecutor
protected int
Deprecated, for removal: This API element is subject to removal in a future version.protected org.springframework.transaction.interceptor.TransactionAttribute
protected org.springframework.transaction.PlatformTransactionManager
Registers objects using the annotation based listener configuration.listener
(ChunkListener listener) Register a chunk listener.protected void
stepOperations
(RepeatOperations repeatTemplate) Sets the repeat template used for iterating the tasklet execution.stream
(ItemStream stream) Register a stream for callbacks that manage restart data.taskExecutor
(org.springframework.core.task.TaskExecutor taskExecutor) Provide a task executor to use when executing the tasklet.throttleLimit
(int throttleLimit) Deprecated, for removal: This API element is subject to removal in a future version.with no replacement since 5.0, scheduled for removal in 6.0.transactionAttribute
(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute) Sets the transaction attributes for the tasklet execution.transactionManager
(org.springframework.transaction.PlatformTransactionManager transactionManager) Set the transaction manager to use for the step.Methods inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
allowStartIfComplete, enhance, getJobRepository, getName, isAllowStartIfComplete, listener, meterRegistry, observationRegistry, repository, self, startLimit
-
Field Details
-
chunkListeners
-
-
Constructor Details
-
AbstractTaskletStepBuilder
-
-
Method Details
-
createTasklet
-
build
Build the step from the components collected by the fluent setters. Delegates first toStepBuilderHelper.enhance(AbstractStep)
and then tocreateTasklet()
in subclasses to create the actual tasklet.- Returns:
- a tasklet step fully configured and ready to execute
-
registerStepListenerAsChunkListener
protected void registerStepListenerAsChunkListener() -
listener
Register a chunk listener.- Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
listener
Registers objects using the annotation based listener configuration.- Overrides:
listener
in classStepBuilderHelper<B extends AbstractTaskletStepBuilder<B>>
- Parameters:
listener
- the object that has a method configured with listener annotation- Returns:
- this for fluent chaining
-
stream
Register a stream for callbacks that manage restart data.- Parameters:
stream
- the stream to register- Returns:
- this for fluent chaining
-
taskExecutor
Provide a task executor to use when executing the tasklet. Default is to use a single-threaded (synchronous) executor.- Parameters:
taskExecutor
- the task executor to register- Returns:
- this for fluent chaining
-
throttleLimit
Deprecated, for removal: This API element is subject to removal in a future version.with no replacement since 5.0, scheduled for removal in 6.0. Use a customRepeatOperations
implementation (based on aTaskExecutor
with a bounded task queue) and set it on the step withstepOperations(RepeatOperations)
.In the case of an asynchronoustaskExecutor(TaskExecutor)
the number of concurrent tasklet executions can be throttled (beyond any throttling provided by a thread pool). The throttle limit should be less than the data source pool size used in the job repository for this step.- Parameters:
throttleLimit
- maximum number of concurrent tasklet executions allowed- Returns:
- this for fluent chaining
-
exceptionHandler
Sets the exception handler to use in the case of tasklet failures. Default is to rethrow everything.- Parameters:
exceptionHandler
- the exception handler- Returns:
- this for fluent chaining
-
stepOperations
Sets the repeat template used for iterating the tasklet execution. By default it will terminate only when the tasklet returns FINISHED (or null).- Parameters:
repeatTemplate
- a repeat template with rules for iterating- Returns:
- this for fluent chaining
-
transactionManager
public B transactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) Set the transaction manager to use for the step.- Parameters:
transactionManager
- a transaction manager- Returns:
- this for fluent chaining
-
transactionAttribute
public B transactionAttribute(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute) Sets the transaction attributes for the tasklet execution. Defaults to the default values for the transaction manager, but can be manipulated to provide longer timeouts for instance.- Parameters:
transactionAttribute
- a transaction attribute set- Returns:
- this for fluent chaining
-
getStepOperations
Convenience method for subclasses to access the step operations that were injected by user.- Returns:
- the repeat operations used to iterate the tasklet executions
-
getExceptionHandler
Convenience method for subclasses to access the exception handler that was injected by user.- Returns:
- the exception handler
-
concurrent
protected boolean concurrent()Convenience method for subclasses to determine if the step is concurrent.- Returns:
- true if the tasklet is going to be run in multiple threads
-
getTaskExecutor
protected org.springframework.core.task.TaskExecutor getTaskExecutor() -
getThrottleLimit
Deprecated, for removal: This API element is subject to removal in a future version. -
getTransactionAttribute
protected org.springframework.transaction.interceptor.TransactionAttribute getTransactionAttribute() -
getStreams
-
getTransactionManager
protected org.springframework.transaction.PlatformTransactionManager getTransactionManager()
-