View Javadoc

1   /*
2    * Copyright 2006-2011 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  package org.springframework.batch.core.job.builder;
17  
18  import org.springframework.batch.core.Step;
19  import org.springframework.batch.core.job.flow.Flow;
20  
21  /**
22   * Convenience for building jobs of various kinds.
23   * 
24   * @author Dave Syer
25   * 
26   * @since 2.2
27   * 
28   */
29  public class JobBuilder extends JobBuilderHelper<JobBuilder> {
30  
31  	/**
32  	 * Create a new builder for a job with the given name.
33  	 * 
34  	 * @param name the name of the job
35  	 */
36  	public JobBuilder(String name) {
37  		super(name);
38  	}
39  
40  	/**
41  	 * Create a new job builder that will execute a step or sequence of steps.
42  	 * 
43  	 * @param step a step to execute
44  	 * @return a {@link SimpleJobBuilder}
45  	 */
46  	public SimpleJobBuilder start(Step step) {
47  		return new SimpleJobBuilder(this).start(step);
48  	}
49  
50  	/**
51  	 * Create a new job builder that will execute a step or sequence of steps.
52  	 * 
53  	 * @param step a step to execute
54  	 * @return a {@link SimpleJobBuilder}
55  	 */
56  	public JobFlowBuilder start(Flow flow) {
57  		return new FlowJobBuilder(this).start(flow);
58  	}
59  
60  	/**
61  	 * Create a new job builder that will execute a step or sequence of steps.
62  	 * 
63  	 * @param step a step to execute
64  	 * @return a {@link SimpleJobBuilder}
65  	 */
66  	public JobFlowBuilder flow(Step step) {
67  		return new FlowJobBuilder(this).start(step);
68  	}
69  
70  
71  }