org.springframework.batch.repeat

## Interface RepeatContext

- All Superinterfaces:
    org.springframework.core.AttributeAccessor
  All Known Implementing Classes:
    CompositeCompletionPolicy.CompositeBatchContext, CountingCompletionPolicy.CountingBatchContext, RepeatContextSupport, SimpleCompletionPolicy.SimpleTerminationContext, TimeoutTerminationPolicy.TimeoutBatchContext

      public interface RepeatContext
      extends org.springframework.core.AttributeAccessor

  Base interface for context which controls the state and completion / termination of a batch step. A new context is created for each call to the `RepeatOperations`. Within a batch callback code can communicate via the `AttributeAccessor` interface.
  Author:
    Dave Syer
  See Also:
    `RepeatOperations.iterate(RepeatCallback)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Allow resources to be cleared, especially in destruction callbacks.
    `RepeatContext` | `getParent()` If batches are nested, then the inner batch will be created with the outer one as a parent.
    `int` | `getStartedCount()` Public access to a counter for the number of operations attempted.
    `boolean` | `isCompleteOnly()` Public accessor for the complete flag.
    `boolean` | `isTerminateOnly()` Public accessor for the termination flag.
    `void` | `registerDestructionCallback(java.lang.String name, java.lang.Runnable callback)` Register a callback to be executed on close, associated with the attribute having the given name.
    `void` | `setCompleteOnly()` Signal to the framework that the current batch should complete normally, independent of the current `CompletionPolicy`.
    `void` | `setTerminateOnly()` Signal to the framework that the current batch should complete abnormally, independent of the current `CompletionPolicy`.

    - ### Methods inherited from interface org.springframework.core.AttributeAccessor

      `attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttribute`

- - ### Method Detail

    - #### getParent

          RepeatContext getParent()

      If batches are nested, then the inner batch will be created with the outer one as a parent. This is an accessor for the parent if it exists.
      Returns:
        the parent context or null if there is none

    - #### getStartedCount

          int getStartedCount()

      Public access to a counter for the number of operations attempted.
      Returns:
        the number of batch operations started.

    - #### setCompleteOnly

          void setCompleteOnly()

      Signal to the framework that the current batch should complete normally, independent of the current `CompletionPolicy`.

    - #### isCompleteOnly

          boolean isCompleteOnly()

      Public accessor for the complete flag.
      Returns:
        indicator if the repeat is complete

    - #### setTerminateOnly

          void setTerminateOnly()

      Signal to the framework that the current batch should complete abnormally, independent of the current `CompletionPolicy`.

    - #### isTerminateOnly

          boolean isTerminateOnly()

      Public accessor for the termination flag. If this flag is set then the complete flag will also be.
      Returns:
        indicates if the repeat should terminate

    - #### registerDestructionCallback

          void registerDestructionCallback(java.lang.String name,
                                           java.lang.Runnable callback)

      Register a callback to be executed on close, associated with the attribute having the given name. The `Runnable` callback should not throw any exceptions.
      Parameters:
        `name` - the name of the attribute to associated this callback with. If this attribute is removed the callback should never be called.
        `callback` - a `Runnable` to execute when the context is closed.

    - #### close

          void close()

      Allow resources to be cleared, especially in destruction callbacks. Implementations should ensure that any registered destruction callbacks are executed here, as long as the corresponding attribute is still available.