EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.repeat.listener]

COVERAGE SUMMARY FOR SOURCE FILE [CompositeRepeatListener.java]

nameclass, %method, %block, %line, %
CompositeRepeatListener.java100% (1/1)88%  (7/8)84%  (89/106)86%  (19/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeRepeatListener100% (1/1)88%  (7/8)84%  (89/106)86%  (19/22)
after (RepeatContext, RepeatStatus): void 0%   (0/1)0%   (0/17)0%   (0/3)
CompositeRepeatListener (): void 100% (1/1)100% (8/8)100% (2/2)
before (RepeatContext): void 100% (1/1)100% (16/16)100% (3/3)
close (RepeatContext): void 100% (1/1)100% (16/16)100% (3/3)
onError (RepeatContext, Throwable): void 100% (1/1)100% (17/17)100% (3/3)
open (RepeatContext): void 100% (1/1)100% (16/16)100% (3/3)
register (RepeatListener): void 100% (1/1)100% (11/11)100% (3/3)
setListeners (RepeatListener []): 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.repeat.listener;
17 
18import java.util.ArrayList;
19import java.util.Arrays;
20import java.util.List;
21 
22import org.springframework.batch.repeat.RepeatStatus;
23import org.springframework.batch.repeat.RepeatContext;
24import org.springframework.batch.repeat.RepeatListener;
25 
26/**
27 * @author Dave Syer
28 * 
29 */
30public class CompositeRepeatListener implements RepeatListener {
31 
32        private List<RepeatListener> listeners = new ArrayList<RepeatListener>();
33 
34        /**
35         * Public setter for the listeners.
36         * 
37         * @param listeners
38         */
39        public void setListeners(RepeatListener[] listeners) {
40                this.listeners = Arrays.asList(listeners);
41        }
42 
43        /**
44         * Register additional listener.
45         * 
46         * @param listener
47         */
48        public void register(RepeatListener listener) {
49                if (!listeners.contains(listener)) {
50                        listeners.add(listener);
51                }
52        }
53 
54        /* (non-Javadoc)
55         * @see org.springframework.batch.repeat.RepeatListener#after(org.springframework.batch.repeat.RepeatContext, org.springframework.batch.repeat.ExitStatus)
56         */
57        public void after(RepeatContext context, RepeatStatus result) {
58                for (RepeatListener listener : listeners) {
59                        listener.after(context, result);
60                }
61        }
62 
63        /* (non-Javadoc)
64         * @see org.springframework.batch.repeat.RepeatListener#before(org.springframework.batch.repeat.RepeatContext)
65         */
66        public void before(RepeatContext context) {
67                for (RepeatListener listener : listeners) {
68                        listener.before(context);
69                }
70        }
71 
72        /* (non-Javadoc)
73         * @see org.springframework.batch.repeat.RepeatListener#close(org.springframework.batch.repeat.RepeatContext)
74         */
75        public void close(RepeatContext context) {
76                for (RepeatListener listener : listeners) {
77                        listener.close(context);
78                }
79        }
80 
81        /* (non-Javadoc)
82         * @see org.springframework.batch.repeat.RepeatListener#onError(org.springframework.batch.repeat.RepeatContext, java.lang.Throwable)
83         */
84        public void onError(RepeatContext context, Throwable e) {
85                for (RepeatListener listener : listeners) {
86                        listener.onError(context, e);
87                }
88        }
89 
90        /* (non-Javadoc)
91         * @see org.springframework.batch.repeat.RepeatListener#open(org.springframework.batch.repeat.RepeatContext)
92         */
93        public void open(RepeatContext context) {
94                for (RepeatListener listener : listeners) {
95                        listener.open(context);
96                }
97        }
98 
99}

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