001/* 002 * Copyright 2014 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.jsr.job.flow.support.state; 017 018import java.util.Collections; 019 020import org.springframework.batch.core.Step; 021import org.springframework.batch.core.job.flow.FlowExecutionStatus; 022import org.springframework.batch.core.job.flow.FlowExecutor; 023 024/** 025 * Extends {@link org.springframework.batch.core.job.flow.support.state.StepState} to persist what the 026 * last step that was executed was (used in Decisions and restarts). 027 * 028 * @author Michael Minella 029 * @since 3.0 030 */ 031public class JsrStepState extends org.springframework.batch.core.job.flow.support.state.StepState { 032 033 /** 034 * @param step the step that will be executed 035 */ 036 public JsrStepState(Step step) { 037 super(step); 038 } 039 040 /** 041 * @param name for the step that will be executed 042 * @param step the step that will be executed 043 */ 044 public JsrStepState(String name, Step step) { 045 super(name, step); 046 } 047 048 /* (non-Javadoc) 049 * @see org.springframework.batch.core.job.flow.support.state.StepState#handle(org.springframework.batch.core.job.flow.FlowExecutor) 050 */ 051 @Override 052 public FlowExecutionStatus handle(FlowExecutor executor) throws Exception { 053 FlowExecutionStatus result = super.handle(executor); 054 055 executor.getJobExecution().getExecutionContext().put("batch.lastSteps", Collections.singletonList(getStep().getName())); 056 057 return result; 058 } 059}