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 */ 016 017package org.springframework.batch.repeat.exception; 018 019import org.springframework.batch.repeat.CompletionPolicy; 020import org.springframework.batch.repeat.RepeatContext; 021 022/** 023 * Handler to allow strategies for re-throwing exceptions. Normally a 024 * {@link CompletionPolicy} will be used to decide whether to end a batch when 025 * there is no exception, and the {@link ExceptionHandler} is used to signal an 026 * abnormal ending - an abnormal ending would result in an 027 * {@link ExceptionHandler} throwing an exception. The caller will catch and 028 * re-throw it if necessary. 029 * 030 * @author Dave Syer 031 * @author Robert Kasanicky 032 * 033 */ 034public interface ExceptionHandler { 035 036 /** 037 * Deal with a Throwable during a batch - decide whether it should be 038 * re-thrown in the first place. 039 * 040 * @param context the current {@link RepeatContext}. Can be used to store 041 * state (via attributes), for example to count the number of occurrences of 042 * a particular exception type and implement a threshold policy. 043 * @param throwable an exception. 044 * @throws Throwable implementations are free to re-throw the exception 045 */ 046 void handleException(RepeatContext context, Throwable throwable) throws Throwable; 047 048}