| 1 | /* |
| 2 | * Copyright 2006-2013 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 | @Override |
| 41 | public void afterRead(I item) { |
| 42 | } |
| 43 | |
| 44 | /* |
| 45 | * (non-Javadoc) |
| 46 | * |
| 47 | * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() |
| 48 | */ |
| 49 | @Override |
| 50 | public void beforeRead() { |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * (non-Javadoc) |
| 55 | * |
| 56 | * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) |
| 57 | */ |
| 58 | @Override |
| 59 | public void onReadError(Exception ex) { |
| 60 | } |
| 61 | |
| 62 | /* |
| 63 | * (non-Javadoc) |
| 64 | * |
| 65 | * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, |
| 66 | * java.lang.Object) |
| 67 | */ |
| 68 | @Override |
| 69 | public void afterProcess(I item, O result) { |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * (non-Javadoc) |
| 74 | * |
| 75 | * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) |
| 76 | */ |
| 77 | @Override |
| 78 | public void beforeProcess(I item) { |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * (non-Javadoc) |
| 83 | * |
| 84 | * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, |
| 85 | * java.lang.Exception) |
| 86 | */ |
| 87 | @Override |
| 88 | public void onProcessError(I item, Exception e) { |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * (non-Javadoc) |
| 93 | * |
| 94 | * @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite() |
| 95 | */ |
| 96 | @Override |
| 97 | public void afterWrite(List<? extends O> item) { |
| 98 | } |
| 99 | |
| 100 | /* |
| 101 | * (non-Javadoc) |
| 102 | * |
| 103 | * @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object) |
| 104 | */ |
| 105 | @Override |
| 106 | public void beforeWrite(List<? extends O> item) { |
| 107 | } |
| 108 | |
| 109 | /* |
| 110 | * (non-Javadoc) |
| 111 | * |
| 112 | * @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception, |
| 113 | * java.lang.Object) |
| 114 | */ |
| 115 | @Override |
| 116 | public void onWriteError(Exception ex, List<? extends O> item) { |
| 117 | } |
| 118 | } |