View Javadoc

1   /*
2    * Copyright 2006-2013 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  
17  package org.springframework.batch.core.job.flow.support.state;
18  
19  import org.springframework.batch.core.job.flow.FlowExecutionStatus;
20  import org.springframework.batch.core.job.flow.FlowExecutor;
21  import org.springframework.batch.core.job.flow.JobExecutionDecider;
22  
23  /**
24   * State that requires a decider to make the status decision.
25   *
26   * @author Dave Syer
27   * @since 2.0
28   */
29  public class DecisionState extends AbstractState {
30  
31  	private final JobExecutionDecider decider;
32  
33  	/**
34  	 * @param name
35  	 */
36  	public DecisionState(JobExecutionDecider decider, String name) {
37  		super(name);
38  		this.decider = decider;
39  	}
40  
41  	@Override
42  	public FlowExecutionStatus handle(FlowExecutor executor) throws Exception {
43  		return decider.decide(executor.getJobExecution(), executor.getStepExecution());
44  	}
45  
46  	/* (non-Javadoc)
47  	 * @see org.springframework.batch.core.job.flow.State#isEndState()
48  	 */
49  	@Override
50  	public boolean isEndState() {
51  		return false;
52  	}
53  
54  }