001/* 002 * Copyright 2006-2007 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.flow; 017 018import java.util.Collection; 019 020/** 021 * @author Dave Syer 022 * @since 2.0 023 */ 024public interface Flow { 025 026 /** 027 * @return the name of the flow 028 */ 029 String getName(); 030 031 /** 032 * Retrieve the State with the given name. If there is no State with the 033 * given name, then return null. 034 * 035 * @param stateName the name of the state to retrieve 036 * @return the State 037 */ 038 State getState(String stateName); 039 040 /** 041 * @param executor the {@link FlowExecutor} instance to use for the flow execution. 042 * @return a {@link FlowExecution} containing the exit status of the flow. 043 * 044 * @throws FlowExecutionException thrown if error occurs during flow execution. 045 */ 046 FlowExecution start(FlowExecutor executor) throws FlowExecutionException; 047 048 /** 049 * @param stateName the name of the state to resume on. 050 * @param executor the context to be passed into each state executed. 051 * @return a {@link FlowExecution} containing the exit status of the flow. 052 * 053 * @throws FlowExecutionException thrown if error occurs during flow execution. 054 */ 055 FlowExecution resume(String stateName, FlowExecutor executor) throws FlowExecutionException; 056 057 /** 058 * Convenient accessor for clients needing to explore the states of this 059 * flow. 060 * @return the states 061 */ 062 Collection<State> getStates(); 063 064}