| 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.ChunkListener; |
| 21 | import org.springframework.batch.core.ExitStatus; |
| 22 | import org.springframework.batch.core.ItemProcessListener; |
| 23 | import org.springframework.batch.core.ItemReadListener; |
| 24 | import org.springframework.batch.core.ItemWriteListener; |
| 25 | import org.springframework.batch.core.SkipListener; |
| 26 | import org.springframework.batch.core.StepExecution; |
| 27 | import org.springframework.batch.core.StepExecutionListener; |
| 28 | import org.springframework.batch.core.StepListener; |
| 29 | import org.springframework.batch.core.scope.context.ChunkContext; |
| 30 | |
| 31 | /** |
| 32 | * Basic no-op implementations of all {@link StepListener} interfaces. |
| 33 | * |
| 34 | * @author Lucas Ward |
| 35 | * @author Robert Kasanicky |
| 36 | */ |
| 37 | public class StepListenerSupport<T,S> implements StepExecutionListener, ChunkListener, |
| 38 | ItemReadListener<T>, ItemProcessListener<T,S>, ItemWriteListener<S>, SkipListener<T, S> { |
| 39 | |
| 40 | /* (non-Javadoc) |
| 41 | * @see org.springframework.batch.core.StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution) |
| 42 | */ |
| 43 | @Override |
| 44 | public ExitStatus afterStep(StepExecution stepExecution) { |
| 45 | return null; |
| 46 | } |
| 47 | |
| 48 | /* (non-Javadoc) |
| 49 | * @see org.springframework.batch.core.StepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution) |
| 50 | */ |
| 51 | @Override |
| 52 | public void beforeStep(StepExecution stepExecution) { |
| 53 | } |
| 54 | |
| 55 | /* (non-Javadoc) |
| 56 | * @see org.springframework.batch.core.domain.ChunkListener#afterChunk(ChunkContext context) |
| 57 | */ |
| 58 | @Override |
| 59 | public void afterChunk(ChunkContext context) { |
| 60 | } |
| 61 | |
| 62 | /* (non-Javadoc) |
| 63 | * @see org.springframework.batch.core.domain.ChunkListener#beforeChunk(ChunkContext context) |
| 64 | */ |
| 65 | @Override |
| 66 | public void beforeChunk(ChunkContext context) { |
| 67 | } |
| 68 | |
| 69 | /* (non-Javadoc) |
| 70 | * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) |
| 71 | */ |
| 72 | @Override |
| 73 | public void afterRead(T item) { |
| 74 | } |
| 75 | |
| 76 | /* (non-Javadoc) |
| 77 | * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() |
| 78 | */ |
| 79 | @Override |
| 80 | public void beforeRead() { |
| 81 | } |
| 82 | |
| 83 | /* (non-Javadoc) |
| 84 | * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) |
| 85 | */ |
| 86 | @Override |
| 87 | public void onReadError(Exception ex) { |
| 88 | } |
| 89 | |
| 90 | /* (non-Javadoc) |
| 91 | * @see org.springframework.batch.core.ItemWriteListener#afterWrite(java.util.List) |
| 92 | */ |
| 93 | @Override |
| 94 | public void afterWrite(List<? extends S> items) { |
| 95 | } |
| 96 | |
| 97 | /* (non-Javadoc) |
| 98 | * @see org.springframework.batch.core.ItemWriteListener#beforeWrite(java.util.List) |
| 99 | */ |
| 100 | @Override |
| 101 | public void beforeWrite(List<? extends S> items) { |
| 102 | } |
| 103 | |
| 104 | /* (non-Javadoc) |
| 105 | * @see org.springframework.batch.core.ItemWriteListener#onWriteError(java.lang.Exception, java.util.List) |
| 106 | */ |
| 107 | @Override |
| 108 | public void onWriteError(Exception exception, List<? extends S> items) { |
| 109 | } |
| 110 | |
| 111 | /* (non-Javadoc) |
| 112 | * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, java.lang.Object) |
| 113 | */ |
| 114 | @Override |
| 115 | public void afterProcess(T item, S result) { |
| 116 | } |
| 117 | |
| 118 | /* (non-Javadoc) |
| 119 | * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) |
| 120 | */ |
| 121 | @Override |
| 122 | public void beforeProcess(T item) { |
| 123 | } |
| 124 | |
| 125 | /* (non-Javadoc) |
| 126 | * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, java.lang.Exception) |
| 127 | */ |
| 128 | @Override |
| 129 | public void onProcessError(T item, Exception e) { |
| 130 | } |
| 131 | |
| 132 | /* (non-Javadoc) |
| 133 | * @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable) |
| 134 | */ |
| 135 | @Override |
| 136 | public void onSkipInProcess(T item, Throwable t) { |
| 137 | } |
| 138 | |
| 139 | /* (non-Javadoc) |
| 140 | * @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable) |
| 141 | */ |
| 142 | @Override |
| 143 | public void onSkipInRead(Throwable t) { |
| 144 | } |
| 145 | |
| 146 | /* (non-Javadoc) |
| 147 | * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable) |
| 148 | */ |
| 149 | @Override |
| 150 | public void onSkipInWrite(S item, Throwable t) { |
| 151 | } |
| 152 | |
| 153 | @Override |
| 154 | public void afterChunkError(ChunkContext context) { |
| 155 | } |
| 156 | |
| 157 | } |