001/* 002 * Copyright 2006-2018 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; 017 018import org.springframework.batch.item.ItemReader; 019import org.springframework.batch.item.ItemWriter; 020 021/** 022 * Listener interface around the reading of an item. 023 * 024 * @author Lucas Ward 025 * @author Mahmoud Ben Hassine 026 * 027 */ 028public interface ItemReadListener<T> extends StepListener { 029 030 /** 031 * Called before {@link ItemReader#read()} 032 */ 033 void beforeRead(); 034 035 /** 036 * Called after {@link ItemReader#read()}. 037 * This method is called only for actual items (ie it is not called when the 038 * reader returns null). 039 * 040 * @param item returned from read() 041 */ 042 void afterRead(T item); 043 044 /** 045 * Called if an error occurs while trying to read. 046 * 047 * @param ex thrown from {@link ItemWriter} 048 */ 049 void onReadError(Exception ex); 050}