org.springframework.batch.core.partition.support

## Class AbstractPartitionHandler

- java.lang.Object
- - org.springframework.batch.core.partition.support.AbstractPartitionHandler

- All Implemented Interfaces:
    PartitionHandler
  Direct Known Subclasses:
    TaskExecutorPartitionHandler

      public abstract class AbstractPartitionHandler
      extends java.lang.Object
      implements PartitionHandler

  Base `PartitionHandler` implementation providing common base features. Subclasses are expected to implement only the `doHandle(org.springframework.batch.core.StepExecution, java.util.Set)` method which returns with the result of the execution(s) or an exception if the step failed to process.
  Author:
    Sebastien Gerard, Dave Syer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractPartitionHandler()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract java.util.Set<StepExecution>` | `doHandle(StepExecution masterStepExecution, java.util.Set<StepExecution> partitionStepExecutions)` Executes the specified `StepExecution` instances and returns an updated view of them.
    `int` | `getGridSize()` Returns the number of step executions.
    `java.util.Collection<StepExecution>` | `handle(StepExecutionSplitter stepSplitter, StepExecution masterStepExecution)` Main entry point for `PartitionHandler` interface.
    `void` | `setGridSize(int gridSize)` Passed to the `StepExecutionSplitter` in the `handle(StepExecutionSplitter, StepExecution)` method, instructing it how many `StepExecution` instances are required, ideally.

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

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

- - ### Constructor Detail

    - #### AbstractPartitionHandler

          public AbstractPartitionHandler()

  - ### Method Detail

    - #### doHandle

          protected abstract java.util.Set<StepExecution> doHandle(StepExecution masterStepExecution,
                                                                   java.util.Set<StepExecution> partitionStepExecutions)
                                                            throws java.lang.Exception

      Executes the specified `StepExecution` instances and returns an updated view of them. Throws an `Exception` if anything goes wrong.
      Parameters:
        `masterStepExecution` - the whole partition execution
        `partitionStepExecutions` - the `StepExecution` instances to execute
      Returns:
        an updated view of these completed `StepExecution` instances
      Throws:
        `java.lang.Exception` - if anything goes wrong. This allows implementations to be liberal and rely on the caller to translate an exception into a step failure as necessary.

    - #### handle

          public java.util.Collection<StepExecution> handle(StepExecutionSplitter stepSplitter,
                                                            StepExecution masterStepExecution)
                                                     throws java.lang.Exception

      Description copied from interface: `PartitionHandler`
      Main entry point for `PartitionHandler` interface. The splitter creates all the executions that need to be farmed out, along with their input parameters (in the form of their `ExecutionContext`). The master step execution is used to identify the partition and group together the results logically.
      Specified by:
        `handle` in interface `PartitionHandler`
      Parameters:
        `stepSplitter` - a strategy for generating a collection of `StepExecution` instances
        `masterStepExecution` - the master step execution for the whole partition
      Returns:
        a collection of completed `StepExecution` instances
      Throws:
        `java.lang.Exception` - if anything goes wrong. This allows implementations to be liberal and rely on the caller to translate an exception into a step failure as necessary.
      See Also:
        `PartitionHandler.handle(StepExecutionSplitter, StepExecution)`

    - #### getGridSize

          public int getGridSize()

      Returns the number of step executions.
      Returns:
        the number of step executions

    - #### setGridSize

          public void setGridSize(int gridSize)

      Passed to the `StepExecutionSplitter` in the `handle(StepExecutionSplitter, StepExecution)` method, instructing it how many `StepExecution` instances are required, ideally. The `StepExecutionSplitter` is allowed to ignore the grid size in the case of a restart, since the input data partitions must be preserved.
      Parameters:
        `gridSize` - the number of step executions that will be created