001/* 002 * Copyright 2006-2013 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.batch.core.job.builder; 017 018import org.springframework.batch.core.Step; 019import org.springframework.batch.core.job.flow.Flow; 020 021/** 022 * Convenience for building jobs of various kinds. 023 * 024 * @author Dave Syer 025 * 026 * @since 2.2 027 * 028 */ 029public class JobBuilder extends JobBuilderHelper<JobBuilder> { 030 031 /** 032 * Create a new builder for a job with the given name. 033 * 034 * @param name the name of the job 035 */ 036 public JobBuilder(String name) { 037 super(name); 038 } 039 040 /** 041 * Create a new job builder that will execute a step or sequence of steps. 042 * 043 * @param step a step to execute 044 * @return a {@link SimpleJobBuilder} 045 */ 046 public SimpleJobBuilder start(Step step) { 047 return new SimpleJobBuilder(this).start(step); 048 } 049 050 /** 051 * Create a new job builder that will execute a flow. 052 * 053 * @param flow a flow to execute 054 * @return a {@link SimpleJobBuilder} 055 */ 056 public JobFlowBuilder start(Flow flow) { 057 return new FlowJobBuilder(this).start(flow); 058 } 059 060 /** 061 * Create a new job builder that will execute a step or sequence of steps. 062 * 063 * @param step a step to execute 064 * @return a {@link SimpleJobBuilder} 065 */ 066 public JobFlowBuilder flow(Step step) { 067 return new FlowJobBuilder(this).start(step); 068 } 069}