Class 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. It stores all of the properties that are configurable on the <step/> (and its inner <tasklet/>). Based on which properties are configured, the getObject() method delegates to the appropriate class for generating the Step.
Dan Garrette, Josh Long, Michael Minella, Chris Schaefer, Mahmoud Ben Hassine
See Also:
  • Constructor Details

    • StepParserStepFactoryBean

      public StepParserStepFactoryBean()
  • Method Details

    • getObject

      public Step getObject() throws Exception
      Create a Step from the configuration provided.
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<I>
      See Also:
      • FactoryBean.getObject()
    • requiresTransactionManager

      public boolean requiresTransactionManager()
      Currently, all step implementations other than TaskletStep are instances of AbstractStep and do not require a transaction manager.
    • enhanceCommonStep

      protected void enhanceCommonStep(StepBuilderHelper<?> builder)
      Enhances a step with attributes from the provided StepBuilderHelper.
      builder - StepBuilderHelper representing the step to be enhanced
    • createPartitionStep

      protected Step createPartitionStep()
      Create a partition Step.
      the Step.
    • createFaultTolerantStep

      protected Step createFaultTolerantStep()
      Creates a fault tolerant Step.
      the Step.
    • getFaultTolerantStepBuilder

      protected FaultTolerantStepBuilder<I,O> getFaultTolerantStepBuilder(String stepName)
      stepName - The name of the step used by the created builder.
      the FaultTolerantStepBuilder.
    • registerItemListeners

      protected void registerItemListeners(SimpleStepBuilder<I,O> builder)
    • createSimpleStep

      protected Step createSimpleStep()
      Creates a new TaskletStep.
      the TaskletStep.
    • setChunk

      protected void setChunk(SimpleStepBuilder<I,O> builder)
    • getCompletionPolicy

      protected CompletionPolicy getCompletionPolicy()
    • getSimpleStepBuilder

      protected SimpleStepBuilder<I,O> getSimpleStepBuilder(String stepName)
    • createTaskletStep

      protected TaskletStep createTaskletStep()
      Create a new TaskletStep.
      a new TaskletStep
    • enhanceTaskletStepBuilder

      protected void enhanceTaskletStepBuilder(AbstractTaskletStepBuilder<?> builder)
      Set the state of the AbstractTaskletStepBuilder using the values that were established for the factory bean.
      builder - The AbstractTaskletStepBuilder to be modified.
    • createFlowStep

      protected Step createFlowStep()
      Create a new FlowStep.
      the FlowStep.
    • validateFaultTolerantSettings

      protected void validateFaultTolerantSettings()
      Validates that all components required to build a fault tolerant step are set.
    • isFaultTolerant

      protected boolean isFaultTolerant()
      Indicates whether the step has any components that require fault tolerance.
      true if the step is configured with any components that require fault tolerance.
    • getObjectType

      public Class<TaskletStep> getObjectType()
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<I>
    • isSingleton

      public boolean isSingleton()
      Specified by:
      isSingleton in interface org.springframework.beans.factory.FactoryBean<I>
    • setBeanName

      public void setBeanName(String name)
      Set the bean name property, which will become the name of the Step when it is created.
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
      See Also:
      • BeanNameAware.setBeanName(java.lang.String)
    • setName

      public void setName(String name)
      name - the name to set
    • getName

      public String getName()
    • setFlow

      public void setFlow(Flow flow)
      flow - the flow to set
    • setJob

      public void setJob(Job job)
    • setJobParametersExtractor

      public void setJobParametersExtractor(JobParametersExtractor jobParametersExtractor)
    • setJobLauncher

      public void setJobLauncher(JobLauncher jobLauncher)
    • setPartitioner

      public void setPartitioner(Partitioner partitioner)
      partitioner - the partitioner to set
    • setStepExecutionAggregator

      public void setStepExecutionAggregator(StepExecutionAggregator stepExecutionAggregator)
      stepExecutionAggregator - the stepExecutionAggregator to set
    • getStepExecutionAggergator

      protected StepExecutionAggregator getStepExecutionAggergator()
      The current step's StepExecutionAggregator
    • setPartitionHandler

      public void setPartitionHandler(PartitionHandler partitionHandler)
      partitionHandler - The partitionHandler to set
    • getPartitionHandler

      protected PartitionHandler getPartitionHandler()
      The current step's PartitionHandler
    • setGridSize

      public void setGridSize(int gridSize)
      gridSize - the gridSize to set
    • setStep

      public void setStep(Step step)
      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.
      allowStartIfComplete - the shouldAllowStartIfComplete to set
    • getJobRepository

      public JobRepository getJobRepository()
      The jobRepository
    • setJobRepository

      public void setJobRepository(JobRepository jobRepository)
      Public setter for JobRepository.
      jobRepository - JobRepository instance to be used by the step.
    • setStartLimit

      public void setStartLimit(int startLimit)
      The number of times that the step should be allowed to start.
      startLimit - int containing the number of times a step should be allowed to start.
    • setTasklet

      public void setTasklet(Tasklet tasklet)
      A preconfigured Tasklet to use.
      tasklet - Tasklet instance to be used by step.
    • getTasklet

      protected Tasklet getTasklet()
    • getTransactionManager

      public org.springframework.transaction.PlatformTransactionManager getTransactionManager()
      An instance of PlatformTransactionManager used by the step.
    • setTransactionManager

      public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
      transactionManager - the transaction manager to set
    • setListeners

      public void setListeners(Object[] listeners)
      The listeners to inject into the Step. Any instance of StepListener can be used and then receives callbacks at the appropriate stage in the step.
      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.
      noRollbackExceptionClasses - The noRollbackExceptionClasses to set
    • setTransactionTimeout

      public void setTransactionTimeout(int transactionTimeout)
      transactionTimeout - The transactionTimeout to set
    • setIsolation

      public void setIsolation(org.springframework.transaction.annotation.Isolation isolation)
      isolation - The isolation to set
    • setPropagation

      public void setPropagation(org.springframework.transaction.annotation.Propagation propagation)
      propagation - The propagation to set
    • setBackOffPolicy

      public void setBackOffPolicy(org.springframework.retry.backoff.BackOffPolicy backOffPolicy)
      A backoff policy to be applied to the retry process.
      backOffPolicy - The BackOffPolicy to 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.
      retryPolicy - the RetryPolicy to set
    • setRetryContextCache

      public void setRetryContextCache(org.springframework.retry.policy.RetryContextCache retryContextCache)
      retryContextCache - The RetryContextCache to set
    • setKeyGenerator

      public void setKeyGenerator(KeyGenerator keyGenerator)
      A key generator that can be used to compare items with previously recorded items in a retry. Used only if the reader is a transactional queue.
      keyGenerator - the KeyGenerator to set
    • setCacheCapacity

      public void setCacheCapacity(int cacheCapacity)
      Public setter for the capacity of the cache in the retry policy. If there are more items than the specified capacity, the the step fails without being skipped or recovered, and an exception is thrown. This guards against inadvertent infinite loops generated by item identity problems.

      The default value should be high enough for most purposes. To breach the limit in a single-threaded step, you typically have to have this many failures in a single transaction. Defaults to the value in the MapRetryContextCache.
      cacheCapacity - The cache capacity to set (greater than 0 else ignored)
    • setChunkCompletionPolicy

      public void setChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy)
      Public setter for the CompletionPolicy that applies to the chunk level. A transaction is committed when this policy decides to complete. Defaults to a SimpleCompletionPolicy with chunk size equal to the commitInterval property.
      chunkCompletionPolicy - The chunkCompletionPolicy to set.
    • setCommitInterval

      public void setCommitInterval(int commitInterval)
      Set the commit interval. Set either this or the chunkCompletionPolicy but not both.
      commitInterval - 1 by default
    • getCommitInterval

      protected Integer getCommitInterval()
      The commit interval.
    • 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.
      isReaderTransactionalQueue - the value of the flag
    • setProcessorTransactional

      public void setProcessorTransactional(Boolean processorTransactional)
      Flag to signal that the processor is transactional -- in that case, it should be called for every item in every transaction. If false, we can cache the processor results between transactions in the case of a rollback.
      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 that this limit includes the initial attempt to process the item. Therefore, by default, retryLimit == 1.
      retryLimit - The retry limit to set. Must be greater than or equal to 1.
    • setSkipLimit

      public void setSkipLimit(int skipLimit)
      Public setter for a limit that determines skip policy. If this value is positive, an exception in chunk processing causes the item to be skipped and no exception to be propagated until the limit is reached. If it is zero, all exceptions are propagated from the chunk and cause the step to abort.
      skipLimit - The value to set. The default is 0 (never skip).
    • setSkipPolicy

      public void setSkipPolicy(SkipPolicy skipPolicy)
      Public setter for a skip policy. If this value is set, the skip limit and skippable exceptions are ignored.
      skipPolicy - The SkipPolicy to set.
    • setTaskExecutor

      public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
      Public setter for the TaskExecutor. If this is set, it is used to execute the chunk processing inside the Step.
      taskExecutor - The taskExecutor to set.
    • setThrottleLimit

      @Deprecated(since="5.0", forRemoval=true) public void setThrottleLimit(Integer throttleLimit)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.0, scheduled for removal in 6.0. This API is not intended for end users anyway. It is only used by the XML namespace parser.
      Public setter for the throttle limit. This limits the number of tasks queued for concurrent processing to prevent thread pools from being overwhelmed. Defaults to TaskExecutorRepeatTemplate.DEFAULT_THROTTLE_LIMIT.
      throttleLimit - The throttle limit to set.
    • setItemReader

      public void setItemReader(ItemReader<? extends I> itemReader)
      itemReader - The ItemReader to set.
    • setItemProcessor

      public void setItemProcessor(ItemProcessor<? super I,? extends O> itemProcessor)
      itemProcessor - The ItemProcessor to set.
    • setItemWriter

      public void setItemWriter(ItemWriter<? super O> itemWriter)
      itemWriter - The ItemWriter to set.
    • setRetryListeners

      public void setRetryListeners(org.springframework.retry.RetryListener... retryListeners)
      Public setter for the RetryListener instances.
      retryListeners - The RetryListener instances to set.
    • setSkippableExceptionClasses

      public void setSkippableExceptionClasses(Map<Class<? extends Throwable>,Boolean> exceptionClasses)
      Public setter for exception classes that, when raised, do not crash the job but result in transaction rollback. The item for which handling caused the exception is skipped.
      exceptionClasses - A Map containing the Throwable instances as the keys and the Boolean instances as the values. If true, the item is skipped.
    • setRetryableExceptionClasses

      public void setRetryableExceptionClasses(Map<Class<? extends Throwable>,Boolean> retryableExceptionClasses)
      Public setter for exception classes that retries the item when raised.
      retryableExceptionClasses - The retryableExceptionClasses to set.
    • setStreams

      public void setStreams(ItemStream[] streams)
      The streams to inject into the Step. Any instance of ItemStream can be used, and it then receives callbacks at the appropriate stage in the step.
      streams - an array of listeners
    • setHasChunkElement

      public void setHasChunkElement(boolean hasChunkElement)
      hasChunkElement - true if step has <chunk/> element.
    • hasChunkElement

      protected boolean hasChunkElement()
      true if the defined step has a <chunk/> element.
    • hasTasklet

      protected boolean hasTasklet()
      true if the defined step has a <tasklet/> element.
    • hasPartitionElement

      protected boolean hasPartitionElement()
      true if the defined step has a <partition/> element.