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 018/** 019 * @author Dave Syer 020 * @since 2.0 021 */ 022public interface State { 023 024 /** 025 * The name of the state. Should be unique within a flow. 026 * 027 * @return the name of this state 028 */ 029 String getName(); 030 031 /** 032 * Handle some business or processing logic and return a status that can be 033 * used to drive a flow to the next {@link State}. The status can be any 034 * string, but special meaning is assigned to the static constants in 035 * {@link FlowExecution}. The context can be used by implementations to do 036 * whatever they need to do. The same context will be passed to all 037 * {@link State} instances, so implementations should be careful that the 038 * context is thread-safe, or used in a thread-safe manner. 039 * 040 * @param executor the context passed in by the caller 041 * @return a status for the execution 042 * @throws Exception if anything goes wrong 043 */ 044 FlowExecutionStatus handle(FlowExecutor executor) throws Exception; 045 046 /** 047 * Inquire as to whether a {@link State} is an end state. Implementations 048 * should return false if processing can continue, even if that would 049 * require a restart. 050 * 051 * @return true if this {@link State} is the end of processing 052 */ 053 boolean isEndState(); 054 055}