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.support;
18  
19  import java.util.Map;
20  
21  import org.springframework.batch.item.ExecutionContext;
22  
23  /**
24   * Central strategy interface for creating input parameters for a partitioned
25   * step in the form of {@link ExecutionContext} instances. The usual aim is to
26   * create a set of distinct input values, e.g. a set of non-overlapping primary
27   * key ranges, or a set of unique filenames.
28   * 
29   * @author Dave Syer
30   * @since 2.0
31   */
32  public interface Partitioner {
33  
34  	/**
35  	 * Create a set of distinct {@link ExecutionContext} instances together with
36  	 * a unique identifier for each one. The identifiers should be short,
37  	 * mnemonic values, and only have to be unique within the return value (e.g.
38  	 * use an incrementer).
39  	 * 
40  	 * @param gridSize the size of the map to return
41  	 * @return a map from identifier to input parameters
42  	 */
43  	Map<String, ExecutionContext> partition(int gridSize);
44  
45  }