Class StepParserStepFactoryBean<I,O>
java.lang.Object
org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean<I,O>
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.FactoryBean<Step>
public class StepParserStepFactoryBean<I,O>
extends Object
implements org.springframework.beans.factory.FactoryBean<Step>, org.springframework.beans.factory.BeanNameAware
This
FactoryBean is used by the batch namespace parser to create Step objects. Stores all of the
properties that are configurable on the <step/> (and its inner <tasklet/>). Based on which properties are
configured, the getObject() method will delegate to the appropriate class for generating the Step.- Since:
- 2.0
- Author:
- Dan Garrette, Josh Long, Michael Minella, Chris Schaefer, Mahmoud Ben Hassine
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stepprotected Stepprotected Stepprotected Stepprotected TaskletStepprotected voidenhanceCommonStep(StepBuilderHelper<?> builder) protected voidenhanceTaskletStepBuilder(AbstractTaskletStepBuilder<?> builder) protected Integerprotected CompletionPolicyprotected FaultTolerantStepBuilder<I,O> getFaultTolerantStepBuilder(String stepName) getName()Create aStepfrom the configuration provided.protected PartitionHandlerprotected SimpleStepBuilder<I,O> getSimpleStepBuilder(String stepName) protected StepExecutionAggregatorprotected Taskletorg.springframework.transaction.PlatformTransactionManagerprotected booleanprotected booleanprotected booleanprotected booleanbooleanprotected voidregisterItemListeners(SimpleStepBuilder<I, O> builder) booleanvoidsetAllowStartIfComplete(boolean allowStartIfComplete) Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the first time.voidsetBackOffPolicy(org.springframework.retry.backoff.BackOffPolicy backOffPolicy) A backoff policy to be applied to retry process.voidsetBeanName(String name) Set the bean name property, which will become the name of theStepwhen it is created.voidsetCacheCapacity(int cacheCapacity) Public setter for the capacity of the cache in the retry policy.protected voidsetChunk(SimpleStepBuilder<I, O> builder) voidsetChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy) Public setter for theCompletionPolicyapplying to the chunk level.voidsetCommitInterval(int commitInterval) Set the commit interval.voidvoidsetGridSize(int gridSize) voidsetHasChunkElement(boolean hasChunkElement) 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 I, ? extends O> itemProcessor) voidsetItemReader(ItemReader<? extends I> itemReader) voidsetItemWriter(ItemWriter<? super O> itemWriter) voidvoidsetJobLauncher(JobLauncher jobLauncher) voidsetJobParametersExtractor(JobParametersExtractor jobParametersExtractor) voidsetJobRepository(JobRepository jobRepository) Public setter forJobRepository.voidsetKeyGenerator(KeyGenerator keyGenerator) A key generator that can be used to compare items with previously recorded items in a retry.voidsetListeners(Object[] listeners) The listeners to inject into theStep.voidvoidsetNoRollbackExceptionClasses(Collection<Class<? extends Throwable>> noRollbackExceptionClasses) Exception classes that may not cause a rollback if encountered in the right place.voidsetPartitioner(Partitioner partitioner) voidsetPartitionHandler(PartitionHandler partitionHandler) voidsetProcessorTransactional(Boolean processorTransactional) Flag to signal that the processor is transactional, in which case it should be called for every item in every transaction.voidsetPropagation(org.springframework.transaction.annotation.Propagation propagation) voidsetRetryableExceptionClasses(Map<Class<? extends Throwable>, Boolean> retryableExceptionClasses) Public setter for exception classes that will retry the item when raised.voidsetRetryContextCache(org.springframework.retry.policy.RetryContextCache retryContextCache) voidsetRetryLimit(int retryLimit) Public setter for the retry limit.voidsetRetryListeners(org.springframework.retry.RetryListener... retryListeners) Public setter for theRetryListeners.voidsetRetryPolicy(org.springframework.retry.RetryPolicy retryPolicy) A retry policy to apply when exceptions occur.voidsetSkipLimit(int skipLimit) Public setter for a limit that determines skip policy.voidsetSkippableExceptionClasses(Map<Class<? extends Throwable>, Boolean> exceptionClasses) Public setter for exception classes that when raised won't crash the job but will result in transaction rollback and the item which handling caused the exception will be skipped.voidsetSkipPolicy(SkipPolicy skipPolicy) Public setter for a skip policy.voidsetStartLimit(int startLimit) The number of times that the step should be allowed to startvoidvoidsetStepExecutionAggregator(StepExecutionAggregator stepExecutionAggregator) voidsetStreams(ItemStream[] streams) The streams to inject into theStep.voidsetTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor) Public setter for theTaskExecutor.voidsetTasklet(Tasklet tasklet) A preconfiguredTaskletto use.voidsetThrottleLimit(Integer throttleLimit) Public setter for the throttle limit.voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) voidsetTransactionTimeout(int transactionTimeout) protected voidValidates that all components required to build a fault tolerant step are set
-
Constructor Details
-
StepParserStepFactoryBean
public StepParserStepFactoryBean()
-
-
Method Details
-
getObject
Create aStepfrom the configuration provided. -
requiresTransactionManager
public boolean requiresTransactionManager() -
enhanceCommonStep
- Parameters:
builder-StepBuilderHelperrepresenting the step to be enhanced
-
createPartitionStep
-
createFaultTolerantStep
-
getFaultTolerantStepBuilder
-
registerItemListeners
-
createSimpleStep
-
setChunk
-
getCompletionPolicy
-
getSimpleStepBuilder
-
createTaskletStep
- Returns:
- a new
TaskletStep
-
enhanceTaskletStepBuilder
-
createFlowStep
-
validateFaultTolerantSettings
protected void validateFaultTolerantSettings()Validates that all components required to build a fault tolerant step are set -
isFaultTolerant
protected boolean isFaultTolerant()- Returns:
- true if the step is configured with any components that require fault tolerance
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<I>
-
isSingleton
public boolean isSingleton()- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<I>
-
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)
-
setName
- Parameters:
name- the name to set
-
getName
-
setFlow
- Parameters:
flow- the flow to set
-
setJob
-
setJobParametersExtractor
-
setJobLauncher
-
setPartitioner
- Parameters:
partitioner- the partitioner to set
-
setStepExecutionAggregator
- Parameters:
stepExecutionAggregator- the stepExecutionAggregator to set
-
getStepExecutionAggergator
- Returns:
- stepExecutionAggregator the current step's
StepExecutionAggregator
-
setPartitionHandler
- Parameters:
partitionHandler- the partitionHandler to set
-
getPartitionHandler
- Returns:
- partitionHandler the current step's
PartitionHandler
-
setGridSize
public void setGridSize(int gridSize) - Parameters:
gridSize- the gridSize to set
-
setStep
- Parameters:
step- the step 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
-
getJobRepository
- Returns:
- jobRepository
-
setJobRepository
Public setter forJobRepository.- Parameters:
jobRepository-JobRepositoryinstance to be used by the step.
-
setStartLimit
public void setStartLimit(int startLimit) The number of times that the step should be allowed to start- Parameters:
startLimit- int containing the number of times a step should be allowed to start.
-
setTasklet
A preconfiguredTaskletto use.- Parameters:
tasklet-Taskletinstance to be used by step.
-
getTasklet
-
getTransactionManager
public org.springframework.transaction.PlatformTransactionManager getTransactionManager()- Returns:
- transactionManager instance of
PlatformTransactionManagerused by the step.
-
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) - Parameters:
transactionManager- the transaction manager to set
-
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
-
setNoRollbackExceptionClasses
public void setNoRollbackExceptionClasses(Collection<Class<? extends Throwable>> noRollbackExceptionClasses) Exception classes that may not cause a rollback if encountered in the right place.- Parameters:
noRollbackExceptionClasses- the noRollbackExceptionClasses to set
-
setTransactionTimeout
public void setTransactionTimeout(int transactionTimeout) - Parameters:
transactionTimeout- the transactionTimeout to set
-
setIsolation
public void setIsolation(org.springframework.transaction.annotation.Isolation isolation) - Parameters:
isolation- the isolation to set
-
setPropagation
public void setPropagation(org.springframework.transaction.annotation.Propagation propagation) - Parameters:
propagation- the propagation to set
-
setBackOffPolicy
public void setBackOffPolicy(org.springframework.retry.backoff.BackOffPolicy backOffPolicy) A backoff policy to be applied to retry process.- Parameters:
backOffPolicy- theBackOffPolicyto set
-
setRetryPolicy
public void setRetryPolicy(org.springframework.retry.RetryPolicy retryPolicy) A retry policy to apply when exceptions occur. If this is specified then the retry limit and retryable exceptions will be ignored.- Parameters:
retryPolicy- theRetryPolicyto set
-
setRetryContextCache
public void setRetryContextCache(org.springframework.retry.policy.RetryContextCache retryContextCache) - Parameters:
retryContextCache- theRetryContextCacheto set
-
setKeyGenerator
A key generator that can be used to compare items with previously recorded items in a retry. Only used if the reader is a transactional queue.- Parameters:
keyGenerator- theKeyGeneratorto set
-
setCacheCapacity
public void setCacheCapacity(int cacheCapacity) Public setter for the capacity of the cache in the retry policy. If more items than this fail without being skipped or recovered an exception will be thrown. This is to guard against inadvertent infinite loops generated by item identity problems.
The default value should be high enough and more for most purposes. To breach the limit in a single-threaded step typically you have to have this many failures in a single transaction. Defaults to the value in theMapRetryContextCache.- Parameters:
cacheCapacity- the cache capacity to set (greater than 0 else ignored)
-
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
-
setCommitInterval
public void setCommitInterval(int commitInterval) Set the commit interval. Either set this or the chunkCompletionPolicy but not both.- Parameters:
commitInterval- 1 by default
-
getCommitInterval
-
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
-
setProcessorTransactional
Flag to signal that the processor is transactional, in which case it should be called for every item in every transaction. If false then we can cache the processor results between transactions in the case of a rollback.- Parameters:
processorTransactional- the value to set
-
setRetryLimit
public void setRetryLimit(int retryLimit) Public setter for the retry limit. Each item can be retried up to this limit. Note this limit includes the initial attempt to process the item, thereforeretryLimit == 1by default.- Parameters:
retryLimit- the retry limit to set, must be greater or equal to 1.
-
setSkipLimit
public void setSkipLimit(int skipLimit) Public setter for a limit that determines skip policy. If this value is positive then an exception in chunk processing will cause the item to be skipped and no exception propagated until the limit is reached. If it is zero then all exceptions will be propagated from the chunk and cause the step to abort.- Parameters:
skipLimit- the value to set. Default is 0 (never skip).
-
setSkipPolicy
Public setter for a skip policy. If this value is set then the skip limit and skippable exceptions are ignored.- Parameters:
skipPolicy- theSkipPolicyto set
-
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
-
setThrottleLimit
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.
-
setItemReader
- Parameters:
itemReader- theItemReaderto set
-
setItemProcessor
- Parameters:
itemProcessor- theItemProcessorto set
-
setItemWriter
- Parameters:
itemWriter- theItemWriterto set
-
setRetryListeners
public void setRetryListeners(org.springframework.retry.RetryListener... retryListeners) Public setter for theRetryListeners.- Parameters:
retryListeners- theRetryListeners to set
-
setSkippableExceptionClasses
Public setter for exception classes that when raised won't crash the job but will result in transaction rollback and the item which handling caused the exception will be skipped. -
setRetryableExceptionClasses
public void setRetryableExceptionClasses(Map<Class<? extends Throwable>, Boolean> retryableExceptionClasses) Public setter for exception classes that will retry the item when raised.- Parameters:
retryableExceptionClasses- the retryableExceptionClasses to 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
-
setHasChunkElement
public void setHasChunkElement(boolean hasChunkElement) - Parameters:
hasChunkElement- true if step has <chunk/> element.
-
hasChunkElement
protected boolean hasChunkElement()- Returns:
- true if the defined step has a <chunk/> element
-
hasTasklet
protected boolean hasTasklet()- Returns:
- true if the defined step has a <tasklet/> element
-
hasPartitionElement
protected boolean hasPartitionElement()- Returns:
- true if the defined step has a <partition/> element
-