Class SimpleStepBuilder<I,O>

Direct Known Subclasses:
FaultTolerantStepBuilder

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 the processor can be omitted) all in the same transaction.
Since:
2.2
Author:
Dave Syer, Mahmoud Ben Hassine, Parikshit Dutta
See Also:
  • Constructor Details

    • 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 Details

    • 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 ready to execute
      See Also:
    • 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<I,O> listener(Object listener)
      Registers objects using the annotation based listener configuration.
      Overrides:
      listener in class 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
    • self

      protected SimpleStepBuilder<I,O> self()
      Specified by:
      self in class StepBuilderHelper<SimpleStepBuilder<I,O>>
    • 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 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)