EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[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)85%  (23/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeRepeatListener100% (1/1)88%  (7/8)84%  (89/106)85%  (23/27)
after (RepeatContext, RepeatStatus): void 0%   (0/1)0%   (0/17)0%   (0/4)
CompositeRepeatListener (): void 100% (1/1)100% (8/8)100% (2/2)
before (RepeatContext): void 100% (1/1)100% (16/16)100% (4/4)
close (RepeatContext): void 100% (1/1)100% (16/16)100% (4/4)
onError (RepeatContext, Throwable): void 100% (1/1)100% (17/17)100% (4/4)
open (RepeatContext): void 100% (1/1)100% (16/16)100% (4/4)
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    @Override
58        public void after(RepeatContext context, RepeatStatus result) {
59                for (RepeatListener listener : listeners) {
60                        listener.after(context, result);
61                }
62        }
63 
64        /* (non-Javadoc)
65         * @see org.springframework.batch.repeat.RepeatListener#before(org.springframework.batch.repeat.RepeatContext)
66         */
67    @Override
68        public void before(RepeatContext context) {
69                for (RepeatListener listener : listeners) {
70                        listener.before(context);
71                }
72        }
73 
74        /* (non-Javadoc)
75         * @see org.springframework.batch.repeat.RepeatListener#close(org.springframework.batch.repeat.RepeatContext)
76         */
77    @Override
78        public void close(RepeatContext context) {
79                for (RepeatListener listener : listeners) {
80                        listener.close(context);
81                }
82        }
83 
84        /* (non-Javadoc)
85         * @see org.springframework.batch.repeat.RepeatListener#onError(org.springframework.batch.repeat.RepeatContext, java.lang.Throwable)
86         */
87    @Override
88        public void onError(RepeatContext context, Throwable e) {
89                for (RepeatListener listener : listeners) {
90                        listener.onError(context, e);
91                }
92        }
93 
94        /* (non-Javadoc)
95         * @see org.springframework.batch.repeat.RepeatListener#open(org.springframework.batch.repeat.RepeatContext)
96         */
97    @Override
98        public void open(RepeatContext context) {
99                for (RepeatListener listener : listeners) {
100                        listener.open(context);
101                }
102        }
103 
104}

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