View Javadoc

1   /*
2    * Copyright 2006-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.springframework.batch.core;
17  
18  /**
19   * Interface for listener to skipped items. Callbacks will be called by
20   * {@link Step} implementations at the appropriate time in the step lifecycle.
21   * Implementers of this interface should not assume that any method will be 
22   * called immediately after an error has been encountered.  Because there 
23   * may be errors later on in processing the chunk, this listener will not be
24   * called until just before committing.
25   * 
26   * @author Dave Syer
27   * @author Robert Kasanicky
28   * 
29   */
30  public interface SkipListener<T,S> extends StepListener {
31  
32  	/**
33  	 * Callback for a failure on read that is legal, so is not going to be
34  	 * re-thrown. In case transaction is rolled back and items are re-read, this
35  	 * callback will occur repeatedly for the same cause.  This will only happen
36  	 * if read items are not buffered.
37  	 * 
38  	 * @param t cause of the failure
39  	 */
40  	void onSkipInRead(Throwable t);
41  
42  	/**
43  	 * This item failed on write with the given exception, and a skip was called
44  	 * for. 
45  	 * 
46  	 * @param item the failed item
47  	 * @param t the cause of the failure
48  	 */
49  	void onSkipInWrite(S item, Throwable t);
50  
51  	/**
52  	 * This item failed on processing with the given exception, and a skip was called
53  	 * for. 
54  	 * 
55  	 * @param item the failed item
56  	 * @param t the cause of the failure
57  	 */
58  	void onSkipInProcess(T item, Throwable t);
59  
60  }