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.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.StepExecution; |
26 | import org.springframework.batch.core.StepExecutionListener; |
27 | import org.springframework.batch.core.StepListener; |
28 | |
29 | /** |
30 | * Basic no-op implementations of all {@link StepListener} implementations. |
31 | * |
32 | * @author Lucas Ward |
33 | * |
34 | */ |
35 | public class StepListenerSupport<T,S> implements StepExecutionListener, ChunkListener, |
36 | ItemReadListener<T>, ItemProcessListener<T,S>, ItemWriteListener<S> { |
37 | |
38 | /* (non-Javadoc) |
39 | * @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution) |
40 | */ |
41 | public ExitStatus afterStep(StepExecution stepExecution) { |
42 | return null; |
43 | } |
44 | |
45 | /* (non-Javadoc) |
46 | * @see org.springframework.batch.core.domain.StepListener#beforeStep(org.springframework.batch.core.domain.StepExecution) |
47 | */ |
48 | public void beforeStep(StepExecution stepExecution) { |
49 | } |
50 | |
51 | /* (non-Javadoc) |
52 | * @see org.springframework.batch.core.domain.StepListener#onErrorInStep(java.lang.Throwable) |
53 | */ |
54 | public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) { |
55 | return null; |
56 | } |
57 | |
58 | /* (non-Javadoc) |
59 | * @see org.springframework.batch.core.domain.ChunkListener#afterChunk() |
60 | */ |
61 | public void afterChunk() { |
62 | } |
63 | |
64 | /* (non-Javadoc) |
65 | * @see org.springframework.batch.core.domain.ChunkListener#beforeChunk() |
66 | */ |
67 | public void beforeChunk() { |
68 | } |
69 | |
70 | /* (non-Javadoc) |
71 | * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) |
72 | */ |
73 | public void afterRead(T item) { |
74 | } |
75 | |
76 | /* (non-Javadoc) |
77 | * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() |
78 | */ |
79 | public void beforeRead() { |
80 | } |
81 | |
82 | /* (non-Javadoc) |
83 | * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) |
84 | */ |
85 | public void onReadError(Exception ex) { |
86 | } |
87 | |
88 | /* (non-Javadoc) |
89 | * @see org.springframework.batch.core.ItemWriteListener#afterWrite(java.util.List) |
90 | */ |
91 | public void afterWrite(List<? extends S> items) { |
92 | } |
93 | |
94 | /* (non-Javadoc) |
95 | * @see org.springframework.batch.core.ItemWriteListener#beforeWrite(java.util.List) |
96 | */ |
97 | public void beforeWrite(List<? extends S> items) { |
98 | } |
99 | |
100 | /* (non-Javadoc) |
101 | * @see org.springframework.batch.core.ItemWriteListener#onWriteError(java.lang.Exception, java.util.List) |
102 | */ |
103 | public void onWriteError(Exception exception, List<? extends S> items) { |
104 | } |
105 | |
106 | /* (non-Javadoc) |
107 | * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, java.lang.Object) |
108 | */ |
109 | public void afterProcess(T item, S result) { |
110 | } |
111 | |
112 | /* (non-Javadoc) |
113 | * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) |
114 | */ |
115 | public void beforeProcess(T item) { |
116 | } |
117 | |
118 | /* (non-Javadoc) |
119 | * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, java.lang.Exception) |
120 | */ |
121 | public void onProcessError(T item, Exception e) { |
122 | } |
123 | |
124 | } |