001/* 002 * Copyright 2006-2009 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 */ 016 017package org.springframework.batch.core.job; 018 019import org.springframework.batch.core.Job; 020import org.springframework.batch.core.JobExecution; 021import org.springframework.batch.core.JobInterruptedException; 022import org.springframework.batch.core.StartLimitExceededException; 023import org.springframework.batch.core.Step; 024import org.springframework.batch.core.StepExecution; 025import org.springframework.batch.core.repository.JobRestartException; 026 027/** 028 * Strategy interface for handling a {@link Step} on behalf of a {@link Job}. 029 * 030 * @author Dave Syer 031 * 032 */ 033public interface StepHandler { 034 035 /** 036 * Handle a step and return the execution for it. Does not save the 037 * {@link JobExecution}, but should manage the persistence of the 038 * {@link StepExecution} if required (e.g. at least it needs to be added to 039 * a repository before the step can be executed). 040 * 041 * @param step a {@link Step} 042 * @param jobExecution a {@link JobExecution} 043 * @return an execution of the step 044 * 045 * @throws JobInterruptedException if there is an interruption 046 * @throws JobRestartException if there is a problem restarting a failed 047 * step 048 * @throws StartLimitExceededException if the step exceeds its start limit 049 * 050 * @see Job#execute(JobExecution) 051 * @see Step#execute(StepExecution) 052 */ 053 StepExecution handleStep(Step step, JobExecution jobExecution) throws JobInterruptedException, JobRestartException, 054 StartLimitExceededException; 055 056}