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  import org.springframework.batch.item.ItemProcessor;
19  
20  /**
21   * Listener interface for the processing of an item.  Implementations
22   * of this interface will be notified before and after an item is
23   * passed to the {@link ItemProcessor} and in the event of any
24   * exceptions thrown by the processor.
25   * 
26   * @author Dave Syer
27   *
28   */
29  public interface ItemProcessListener<T, S> extends StepListener {
30  
31  	/**
32  	 * Called before {@link ItemProcessor#process(Object)}.
33  	 * 
34  	 * @param item to be processed.
35  	 */
36  	void beforeProcess(T item);
37  	
38  	/**
39  	 * Called after {@link ItemProcessor#process(Object)} returns.  If the
40  	 * processor returns null, this method will still be called, with
41  	 * a null result, allowing for notification of 'filtered' items.
42  	 * 
43  	 * @param item to be processed
44  	 * @param result of processing
45  	 */
46  	void afterProcess(T item, S result);
47  	
48  	/**
49  	 * Called if an exception was thrown from {@link ItemProcessor#process(Object)}.
50  	 * 
51  	 * @param item attempted to be processed
52  	 * @param e - exception thrown during processing.
53  	 */
54  	void onProcessError(T item, Exception e);
55  }