1 | /* |
2 | * Copyright 2006-2008 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.listener; |
17 | |
18 | import java.util.List; |
19 | |
20 | import org.springframework.batch.core.ItemProcessListener; |
21 | import org.springframework.batch.core.ItemReadListener; |
22 | import org.springframework.batch.core.ItemWriteListener; |
23 | |
24 | /** |
25 | * Basic no-op implementation of the {@link ItemReadListener}, |
26 | * {@link ItemProcessListener}, and {@link ItemWriteListener} interfaces. All |
27 | * are implemented, since it is very common that all may need to be implemented |
28 | * at once. |
29 | * |
30 | * @author Lucas Ward |
31 | * |
32 | */ |
33 | public class ItemListenerSupport<I, O> implements ItemReadListener<I>, ItemProcessListener<I, O>, ItemWriteListener<O> { |
34 | |
35 | /* |
36 | * (non-Javadoc) |
37 | * |
38 | * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) |
39 | */ |
40 | public void afterRead(I item) { |
41 | } |
42 | |
43 | /* |
44 | * (non-Javadoc) |
45 | * |
46 | * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() |
47 | */ |
48 | public void beforeRead() { |
49 | } |
50 | |
51 | /* |
52 | * (non-Javadoc) |
53 | * |
54 | * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) |
55 | */ |
56 | public void onReadError(Exception ex) { |
57 | } |
58 | |
59 | /* |
60 | * (non-Javadoc) |
61 | * |
62 | * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, |
63 | * java.lang.Object) |
64 | */ |
65 | public void afterProcess(I item, O result) { |
66 | } |
67 | |
68 | /* |
69 | * (non-Javadoc) |
70 | * |
71 | * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) |
72 | */ |
73 | public void beforeProcess(I item) { |
74 | } |
75 | |
76 | /* |
77 | * (non-Javadoc) |
78 | * |
79 | * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, |
80 | * java.lang.Exception) |
81 | */ |
82 | public void onProcessError(I item, Exception e) { |
83 | } |
84 | |
85 | /* |
86 | * (non-Javadoc) |
87 | * |
88 | * @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite() |
89 | */ |
90 | public void afterWrite(List<? extends O> item) { |
91 | } |
92 | |
93 | /* |
94 | * (non-Javadoc) |
95 | * |
96 | * @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object) |
97 | */ |
98 | public void beforeWrite(List<? extends O> item) { |
99 | } |
100 | |
101 | /* |
102 | * (non-Javadoc) |
103 | * |
104 | * @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception, |
105 | * java.lang.Object) |
106 | */ |
107 | public void onWriteError(Exception ex, List<? extends O> item) { |
108 | } |
109 | } |