org.springframework.batch.core.step.builder

## Class 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>

- Direct Known Subclasses:
    FaultTolerantStepBuilder, JsrSimpleStepBuilder

      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.
  Since:
    2.2
  Author:
    Dave Syer
  See Also:
    `for a step that handles retry and skip of failed items`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper

      `StepBuilderHelper.CommonStepProperties`

  - ### Field Summary

    - ### Fields inherited from class org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder

      `chunkListeners`

    - ### Fields inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper

      `logger, properties`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `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.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TaskletStep` | `build()` Build a step with the reader, writer, processor as provided.
    `SimpleStepBuilder<I,O>` | `chunk(CompletionPolicy completionPolicy)` Sets a completion policy for the chunk processing.
    `SimpleStepBuilder<I,O>` | `chunk(int chunkSize)` Sets the chunk size or commit interval for this step.
    `SimpleStepBuilder<I,O>` | `chunkOperations(RepeatOperations repeatTemplate)` Instead of a `chunk size` or `completion 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(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` | `listener(java.lang.Object listener)` Registers objects using the annotation based listener configuration.
    `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.

    - ### Methods inherited from class org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder

      `concurrent, exceptionHandler, getExceptionHandler, getStepOperations, getStreams, getTaskExecutor, getThrottleLimit, getTransactionAttribute, listener, registerStepListenerAsChunkListener, stepOperations, stream, taskExecutor, throttleLimit, transactionAttribute`

    - ### Methods inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper

      `allowStartIfComplete, enhance, getJobRepository, getName, getTransactionManager, isAllowStartIfComplete, listener, repository, startLimit, transactionManager`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### 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.
      Parameters:
        `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.
      Parameters:
        `parent` - a parent helper containing common step properties

  - ### Method Detail

    - #### faultTolerant

          public FaultTolerantStepBuilder<I,O> faultTolerant()

    - #### build

          public TaskletStep build()

      Build a step with the reader, writer, processor as provided.
      Overrides:
        `build` in class `AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>`
      Returns:
        a tasklet step fully configured and read to execute
      See Also:
        `AbstractTaskletStepBuilder.build()`

    - #### registerStepListenerAsItemListener

          protected void registerStepListenerAsItemListener()

    - #### createTasklet

          protected Tasklet createTasklet()

      Specified by:
        `createTasklet` in class `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 with `completionPolicy` .
      Parameters:
        `chunkSize` - the chunk size (a.k.a commit interval)
      Returns:
        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 the `chunk size` (or commit interval).
      Parameters:
        `completionPolicy` - a completion policy for the chunk
      Returns:
        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 a `AbstractTaskletStepBuilder.stream(ItemStream)` or listener if it implements the corresponding interface. By default assumed to be non-transactional.
      Parameters:
        `reader` - an item reader
      Returns:
        this for fluent chaining
      See Also:
        `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 a `AbstractTaskletStepBuilder.stream(ItemStream)` or listener if it implements the corresponding interface.
      Parameters:
        `writer` - an item writer
      Returns:
        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 a `AbstractTaskletStepBuilder.stream(ItemStream)` or listener if it implements the corresponding interface.
      Parameters:
        `processor` - an item processor
      Returns:
        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.
      Returns:
        this for fluent chaining

    - #### listener

          public SimpleStepBuilder listener(java.lang.Object listener)

      Registers objects using the annotation based listener configuration.
      Overrides:
        `listener` in class `StepBuilderHelper<AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>>`
      Parameters:
        `listener` - the object that has a method configured with listener annotation
      Returns:
        this for fluent chaining

    - #### listener

          public SimpleStepBuilder<I,O> listener(ItemReadListener<? super I> listener)

      Register an item reader listener.
      Parameters:
        `listener` - the listener to register
      Returns:
        this for fluent chaining

    - #### listener

          public SimpleStepBuilder<I,O> listener(ItemWriteListener<? super O> listener)

      Register an item writer listener.
      Parameters:
        `listener` - the listener to register
      Returns:
        this for fluent chaining

    - #### listener

          public SimpleStepBuilder<I,O> listener(ItemProcessListener<? super I,? super O> listener)

      Register an item processor listener.
      Parameters:
        `listener` - the listener to register
      Returns:
        this for fluent chaining

    - #### chunkOperations

          public SimpleStepBuilder<I,O> chunkOperations(RepeatOperations repeatTemplate)

      Instead of a `chunk size` or `completion policy` you can provide a complete repeat operations instance that handles the iteration over the item reader.
      Parameters:
        `repeatTemplate` - a complete repeat template for the chunk
      Returns:
        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()

      Returns:
        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)