View Javadoc

1   /*
2    * Copyright 2006-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.batch.core.partition;
18  
19  import java.util.Collection;
20  
21  import org.springframework.batch.core.StepExecution;
22  import org.springframework.batch.item.ExecutionContext;
23  
24  /**
25   * Interface defining the responsibilities of controlling the execution of a
26   * partitioned {@link StepExecution}. Implementations will need to create a
27   * partition with the {@link StepExecutionSplitter}, and then use an execution
28   * fabric (grid, etc.), to execute the partitioned step. The results of the
29   * executions can be returned raw from remote workers to be aggregated by the
30   * caller.
31   * 
32   * @author Dave Syer
33   * @since 2.0
34   */
35  public interface PartitionHandler {
36  
37  	/**
38  	 * Main entry point for {@link PartitionHandler} interface. The splitter
39  	 * creates all the executions that need to be farmed out, along with their
40  	 * input parameters (in the form of their {@link ExecutionContext}). The
41  	 * master step execution is used to identify the partition and group
42  	 * together the results logically.
43  	 * 
44  	 * @param stepSplitter a strategy for generating a collection of
45  	 * {@link StepExecution} instances
46  	 * @param stepExecution the master step execution for the whole partition
47  	 * @return a collection of completed {@link StepExecution} instances
48  	 * @throws Exception if anything goes wrong. This allows implementations to
49  	 * be liberal and rely on the caller to translate an exception into a step
50  	 * failure as necessary.
51  	 */
52  	Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception;
53  
54  }