EMMA Coverage Report (generated Fri Jan 30 13:20:29 EST 2009)
[all classes][org.springframework.batch.core.listener]

COVERAGE SUMMARY FOR SOURCE FILE [CompositeExecutionJobListener.java]

nameclass, %method, %block, %line, %
CompositeExecutionJobListener.java100% (1/1)100% (7/7)100% (83/83)100% (26/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeExecutionJobListener100% (1/1)100% (7/7)100% (83/83)100% (26/26)
CompositeExecutionJobListener (): void 100% (1/1)100% (8/8)100% (2/2)
afterJob (JobExecution): void 100% (1/1)100% (16/16)100% (5/5)
beforeJob (JobExecution): void 100% (1/1)100% (16/16)100% (5/5)
onError (JobExecution, Throwable): void 100% (1/1)100% (17/17)100% (5/5)
onInterrupt (JobExecution): void 100% (1/1)100% (16/16)100% (5/5)
register (JobExecutionListener): void 100% (1/1)100% (5/5)100% (2/2)
setListeners (JobExecutionListener []): 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;
19 
20import org.springframework.batch.core.JobExecution;
21import org.springframework.batch.core.JobExecutionListener;
22import org.springframework.core.Ordered;
23 
24/**
25 * @author Dave Syer
26 * 
27 */
28public class CompositeExecutionJobListener implements JobExecutionListener {
29 
30        private OrderedComposite listeners = new OrderedComposite();
31 
32        /**
33         * Public setter for the listeners.
34         * 
35         * @param listeners
36         */
37        public void setListeners(JobExecutionListener[] listeners) {
38                this.listeners.setItems(listeners);
39        }
40 
41        /**
42         * Register additional listener.
43         * 
44         * @param jobExecutionListener
45         */
46        public void register(JobExecutionListener jobExecutionListener) {
47                listeners.add(jobExecutionListener);
48        }
49 
50        /**
51         * Call the registered listeners in reverse order, respecting and
52         * prioritising those that implement {@link Ordered}.
53         * @see org.springframework.batch.core.JobExecutionListener#afterJob(org.springframework.batch.core.JobExecution)
54         */
55        public void afterJob(JobExecution jobExecution) {
56                for (Iterator iterator = listeners.reverse(); iterator.hasNext();) {
57                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
58                        listener.afterJob(jobExecution);
59                }
60        }
61 
62        /**
63         * Call the registered listeners in order, respecting and prioritising those
64         * that implement {@link Ordered}.
65         * @see org.springframework.batch.core.JobExecutionListener#beforeJob(org.springframework.batch.core.JobExecution)
66         */
67        public void beforeJob(JobExecution jobExecution) {
68                for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
69                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
70                        listener.beforeJob(jobExecution);
71                }
72        }
73 
74        /**
75         * Call the registered listeners in reverse order, respecting and
76         * prioritising those that implement {@link Ordered}.
77         * @see org.springframework.batch.core.JobExecutionListener#onError(org.springframework.batch.core.JobExecution,
78         * java.lang.Throwable)
79         */
80        public void onError(JobExecution jobExecution, Throwable e) {
81                for (Iterator iterator = listeners.reverse(); iterator.hasNext();) {
82                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
83                        listener.onError(jobExecution, e);
84                }
85 
86        }
87 
88        /**
89         * Call the registered listeners in reverse order, respecting and
90         * prioritising those that implement {@link Ordered}.
91         * @see org.springframework.batch.core.JobExecutionListener#onInterrupt(org.springframework.batch.core.JobExecution)
92         */
93        public void onInterrupt(JobExecution jobExecution) {
94                for (Iterator iterator = listeners.reverse(); iterator.hasNext();) {
95                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
96                        listener.onInterrupt(jobExecution);
97                }
98 
99        }
100}

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