Class SimpleStepFactoryBean<T,S>
java.lang.Object
org.springframework.batch.core.step.factory.SimpleStepFactoryBean<T,S>
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.FactoryBean<Step>
- Direct Known Subclasses:
FaultTolerantStepFactoryBean
public class SimpleStepFactoryBean<T,S>
extends Object
implements org.springframework.beans.factory.FactoryBean<Step>, org.springframework.beans.factory.BeanNameAware
Most common configuration options for simple steps should be found here. Use this
factory bean instead of creating a
Step implementation manually.
This factory does not support configuration of fault-tolerant behavior, use appropriate subclass of this factory bean to configure skip or retry.
- Author:
- Dave Syer, Robert Kasanicky, Mahmoud Ben Hassine
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JobRepositoryprotected final org.apache.commons.logging.Logprotected io.micrometer.observation.ObservationRegistryFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyConfiguration(SimpleStepBuilder<T, S> builder) protected SimpleStepBuilder<T,S> createBuilder(String name) protected RepeatOperationsProtected getter for the chunk operations to make them available in subclasses.protected ExceptionHandlerProtected getter for theExceptionHandler.protected ItemProcessor<? super T,? extends S> Protected getter for theItemProcessorfor subclasses to useprotected ItemReader<? extends T>Protected getter for theItemReaderfor subclasses to use.protected ItemWriter<? super S>Protected getter for theItemWriterfor subclasses to useprotected StepListener[]Protected getter for theStepListeners.getName()Public getter for the name of the step.final StepCreate aStepfrom the configuration provided.protected RepeatOperationsProtected getter for the step operations to make them available in subclasses.protected org.springframework.core.task.TaskExecutorMake theTaskExecutoravailable to subclassesprotected org.springframework.transaction.interceptor.TransactionAttributeGetter for theTransactionAttributefor subclasses only.protected booleanConvenience method for subclasses.booleanReturns true by default, but in most cases aStepshould not be treated as thread-safe.voidsetAllowStartIfComplete(boolean allowStartIfComplete) Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the first time.voidsetBeanName(String name) Set the bean name property, which will become the name of theStepwhen it is created.voidsetChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy) Public setter for theCompletionPolicyapplying to the chunk level.voidsetChunkOperations(RepeatOperations chunkOperations) Public setter for the chunkOperations.voidsetCommitInterval(int commitInterval) Set the commit interval.voidsetExceptionHandler(ExceptionHandler exceptionHandler) Public setter for theExceptionHandler.voidsetIsolation(org.springframework.transaction.annotation.Isolation isolation) voidsetIsReaderTransactionalQueue(boolean isReaderTransactionalQueue) Flag to signal that the reader is transactional (usually a JMS consumer) so that items are re-presented after a rollback.voidsetItemProcessor(ItemProcessor<? super T, ? extends S> itemProcessor) voidsetItemReader(ItemReader<? extends T> itemReader) voidsetItemWriter(ItemWriter<? super S> itemWriter) voidsetJobRepository(JobRepository jobRepository) Public setter forJobRepository.voidsetListeners(StepListener[] listeners) The listeners to inject into theStep.voidsetObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry) Public setter forObservationRegistry.voidsetPropagation(org.springframework.transaction.annotation.Propagation propagation) voidsetSingleton(boolean singleton) Public setter for the singleton flag.voidsetStartLimit(int startLimit) Public setter for the start limit for the step.voidsetStepOperations(RepeatOperations stepOperations) Public setter for the stepOperations.voidsetStreams(ItemStream[] streams) The streams to inject into theStep.voidsetTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor) Public setter for theTaskExecutor.voidsetThrottleLimit(int throttleLimit) Deprecated, for removal: This API element is subject to removal in a future version.since 5.0, scheduled for removal in 6.0.voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) Public setter for thePlatformTransactionManager.voidsetTransactionTimeout(int transactionTimeout) The timeout for an individual transaction in the step.
-
Field Details
-
jobRepository
-
observationRegistry
protected io.micrometer.observation.ObservationRegistry observationRegistry -
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
SimpleStepFactoryBean
public SimpleStepFactoryBean()Default constructor forSimpleStepFactoryBean.
-
-
Method Details
-
setIsReaderTransactionalQueue
public void setIsReaderTransactionalQueue(boolean isReaderTransactionalQueue) Flag to signal that the reader is transactional (usually a JMS consumer) so that items are re-presented after a rollback. The default is false and readers are assumed to be forward-only.- Parameters:
isReaderTransactionalQueue- the value of the flag
-
isReaderTransactionalQueue
protected boolean isReaderTransactionalQueue()Convenience method for subclasses.- Returns:
- true if the flag is set (default false)
-
setBeanName
Set the bean name property, which will become the name of theStepwhen it is created.- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware- See Also:
-
BeanNameAware.setBeanName(java.lang.String)
-
getName
Public getter for the name of the step.- Returns:
- the name
-
setTransactionTimeout
public void setTransactionTimeout(int transactionTimeout) The timeout for an individual transaction in the step.- Parameters:
transactionTimeout- the transaction timeout to set, defaults to infinite
-
setPropagation
public void setPropagation(org.springframework.transaction.annotation.Propagation propagation) - Parameters:
propagation- the propagation to set for business transactions
-
setIsolation
public void setIsolation(org.springframework.transaction.annotation.Isolation isolation) - Parameters:
isolation- the isolation to set for business transactions
-
setStartLimit
public void setStartLimit(int startLimit) Public setter for the start limit for the step.- Parameters:
startLimit- the startLimit to set
-
setAllowStartIfComplete
public void setAllowStartIfComplete(boolean allowStartIfComplete) Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the first time.- Parameters:
allowStartIfComplete- the shouldAllowStartIfComplete to set
-
setItemReader
- Parameters:
itemReader- theItemReaderto set
-
setItemWriter
- Parameters:
itemWriter- theItemWriterto set
-
setItemProcessor
- Parameters:
itemProcessor- theItemProcessorto set
-
setStreams
The streams to inject into theStep. Any instance ofItemStreamcan be used, and will then receive callbacks at the appropriate stage in the step.- Parameters:
streams- an array of listeners
-
setListeners
The listeners to inject into theStep. Any instance ofStepListenercan be used, and will then receive callbacks at the appropriate stage in the step.- Parameters:
listeners- an array of listeners
-
getListeners
Protected getter for theStepListeners.- Returns:
- the listeners
-
getItemReader
Protected getter for theItemReaderfor subclasses to use.- Returns:
- the itemReader
-
getItemWriter
Protected getter for theItemWriterfor subclasses to use- Returns:
- the itemWriter
-
getItemProcessor
Protected getter for theItemProcessorfor subclasses to use- Returns:
- the itemProcessor
-
setJobRepository
Public setter forJobRepository.- Parameters:
jobRepository- is a mandatory dependence (no default).
-
setObservationRegistry
public void setObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry) Public setter forObservationRegistry.- Parameters:
observationRegistry- is an optional dependency (defaults toObservationRegistry.NOOP).
-
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) Public setter for thePlatformTransactionManager.- Parameters:
transactionManager- the transaction manager to set
-
getTransactionAttribute
protected org.springframework.transaction.interceptor.TransactionAttribute getTransactionAttribute()Getter for theTransactionAttributefor subclasses only.- Returns:
- the transactionAttribute
-
getObject
Create aStepfrom the configuration provided. -
createBuilder
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<T>
-
isSingleton
public boolean isSingleton()Returns true by default, but in most cases aStepshould not be treated as thread-safe. Clients are recommended to create a new step for each job execution.- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<T>- See Also:
-
FactoryBean.isSingleton()
-
setSingleton
public void setSingleton(boolean singleton) Public setter for the singleton flag.- Parameters:
singleton- the value to set. Defaults to true.
-
setCommitInterval
public void setCommitInterval(int commitInterval) Set the commit interval. Either set this or the chunkCompletionPolicy but not both.- Parameters:
commitInterval- 1 by default
-
setChunkCompletionPolicy
Public setter for theCompletionPolicyapplying to the chunk level. A transaction will be committed when this policy decides to complete. Defaults to aSimpleCompletionPolicywith chunk size equal to the commitInterval property.- Parameters:
chunkCompletionPolicy- the chunkCompletionPolicy to set
-
getStepOperations
Protected getter for the step operations to make them available in subclasses.- Returns:
- the step operations
-
setStepOperations
Public setter for the stepOperations.- Parameters:
stepOperations- the stepOperations to set
-
setChunkOperations
Public setter for the chunkOperations.- Parameters:
chunkOperations- the chunkOperations to set
-
getChunkOperations
Protected getter for the chunk operations to make them available in subclasses.- Returns:
- the step operations
-
setExceptionHandler
Public setter for theExceptionHandler.- Parameters:
exceptionHandler- the exceptionHandler to set
-
getExceptionHandler
Protected getter for theExceptionHandler.- Returns:
- the
ExceptionHandler
-
setTaskExecutor
public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor) Public setter for theTaskExecutor. If this is set, then it will be used to execute the chunk processing inside theStep.- Parameters:
taskExecutor- the taskExecutor to set
-
getTaskExecutor
protected org.springframework.core.task.TaskExecutor getTaskExecutor()Make theTaskExecutoravailable to subclasses- Returns:
- the taskExecutor to be used to execute chunks
-
setThrottleLimit
Deprecated, for removal: This API element is subject to removal in a future version.since 5.0, scheduled for removal in 6.0. Use a pooledTaskExecutorimplementation with a limited capacity of its task queue instead.Public setter for the throttle limit. This limits the number of tasks queued for concurrent processing to prevent thread pools from being overwhelmed. Defaults toTaskExecutorRepeatTemplate.DEFAULT_THROTTLE_LIMIT.- Parameters:
throttleLimit- the throttle limit to set.
-
applyConfiguration
-