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 */
016package org.springframework.batch.core;
017
018/**
019 * Interface for listener to skipped items. Callbacks will be called by
020 * {@link Step} implementations at the appropriate time in the step lifecycle.
021 * Implementers of this interface should not assume that any method will be 
022 * called immediately after an error has been encountered.  Because there 
023 * may be errors later on in processing the chunk, this listener will not be
024 * called until just before committing.
025 * 
026 * @author Dave Syer
027 * @author Robert Kasanicky
028 * 
029 */
030public interface SkipListener<T,S> extends StepListener {
031
032        /**
033         * Callback for a failure on read that is legal, so is not going to be
034         * re-thrown. In case transaction is rolled back and items are re-read, this
035         * callback will occur repeatedly for the same cause.  This will only happen
036         * if read items are not buffered.
037         * 
038         * @param t cause of the failure
039         */
040        void onSkipInRead(Throwable t);
041
042        /**
043         * This item failed on write with the given exception, and a skip was called
044         * for. 
045         * 
046         * @param item the failed item
047         * @param t the cause of the failure
048         */
049        void onSkipInWrite(S item, Throwable t);
050
051        /**
052         * This item failed on processing with the given exception, and a skip was called
053         * for. 
054         * 
055         * @param item the failed item
056         * @param t the cause of the failure
057         */
058        void onSkipInProcess(T item, Throwable t);
059
060}