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 package org.springframework.batch.core.job.flow;
17
18 /**
19 * @author Dave Syer
20 * @since 2.0
21 */
22 public interface State {
23
24 /**
25 * The name of the state. Should be unique within a flow.
26 *
27 * @return the name of this state
28 */
29 String getName();
30
31 /**
32 * Handle some business or processing logic and return a status that can be
33 * used to drive a flow to the next {@link State}. The status can be any
34 * string, but special meaning is assigned to the static constants in
35 * {@link FlowExecution}. The context can be used by implementations to do
36 * whatever they need to do. The same context will be passed to all
37 * {@link State} instances, so implementations should be careful that the
38 * context is thread safe, or used in a thread safe manner.
39 *
40 * @param executor the context passed in by the caller
41 * @return a status for the execution
42 * @throws Exception if anything goes wrong
43 */
44 FlowExecutionStatus handle(FlowExecutor executor) throws Exception;
45
46 /**
47 * Inquire as to whether a {@link State} is an end state. Implementations
48 * should return false if processing can continue, even if that would
49 * require a restart.
50 *
51 * @return true if this {@link State} is the end of processing
52 */
53 boolean isEndState();
54
55 }