EMMA Coverage Report (generated Fri Aug 21 15:59:46 BST 2009)
[all classes][org.springframework.batch.core.listener]

COVERAGE SUMMARY FOR SOURCE FILE [CompositeChunkListener.java]

nameclass, %method, %block, %line, %
CompositeChunkListener.java100% (1/1)80%  (4/5)90%  (43/48)86%  (12/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeChunkListener100% (1/1)80%  (4/5)90%  (43/48)86%  (12/14)
setListeners (List): void 0%   (0/1)0%   (0/5)0%   (0/2)
CompositeChunkListener (): void 100% (1/1)100% (8/8)100% (2/2)
afterChunk (): void 100% (1/1)100% (15/15)100% (4/4)
beforeChunk (): void 100% (1/1)100% (15/15)100% (4/4)
register (ChunkListener): void 100% (1/1)100% (5/5)100% (2/2)

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 */
16package org.springframework.batch.core.listener;
17 
18import java.util.Iterator;
19import java.util.List;
20 
21import org.springframework.batch.core.ChunkListener;
22import org.springframework.core.Ordered;
23 
24/**
25 * @author Lucas Ward
26 * 
27 */
28public class CompositeChunkListener implements ChunkListener {
29 
30        private OrderedComposite<ChunkListener> listeners = new OrderedComposite<ChunkListener>();
31 
32        /**
33         * Public setter for the listeners.
34         * 
35         * @param listeners
36         */
37        public void setListeners(List<? extends ChunkListener> listeners) {
38                this.listeners.setItems(listeners);
39        }
40 
41        /**
42         * Register additional listener.
43         * 
44         * @param chunkListener
45         */
46        public void register(ChunkListener chunkListener) {
47                listeners.add(chunkListener);
48        }
49 
50        /**
51         * Call the registered listeners in order, respecting and prioritising those
52         * that implement {@link Ordered}.
53         * 
54         * @see org.springframework.batch.core.ChunkListener#afterChunk()
55         */
56        public void afterChunk() {
57                for (Iterator<ChunkListener> iterator = listeners.iterator(); iterator.hasNext();) {
58                        ChunkListener listener = iterator.next();
59                        listener.afterChunk();
60                }
61        }
62 
63        /**
64         * Call the registered listeners in reverse order.
65         * 
66         * @see org.springframework.batch.core.ChunkListener#beforeChunk()
67         */
68        public void beforeChunk() {
69                for (Iterator<ChunkListener> iterator = listeners.reverse(); iterator.hasNext();) {
70                        ChunkListener listener = iterator.next();
71                        listener.beforeChunk();
72                }
73        }
74}

[all classes][org.springframework.batch.core.listener]
EMMA 2.0.5312 (C) Vladimir Roubtsov