EMMA Coverage Report (generated Tue May 06 07:29:23 PDT 2008)
[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% (89/89)100% (27/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeExecutionJobListener100% (1/1)100% (7/7)100% (89/89)100% (27/27)
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% (11/11)100% (3/3)
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.ArrayList;
19import java.util.Arrays;
20import java.util.Iterator;
21import java.util.List;
22 
23import org.springframework.batch.core.JobExecution;
24import org.springframework.batch.core.JobExecutionListener;
25 
26/**
27 * @author Dave Syer
28 * 
29 */
30public class CompositeExecutionJobListener implements JobExecutionListener {
31 
32        private List listeners = new ArrayList();
33 
34        /**
35         * Public setter for the listeners.
36         * 
37         * @param listeners
38         */
39        public void setListeners(JobExecutionListener[] listeners) {
40                this.listeners = Arrays.asList(listeners);
41        }
42 
43        /**
44         * Register additional listener.
45         * 
46         * @param jobExecutionListener
47         */
48        public void register(JobExecutionListener jobExecutionListener) {
49                if (!listeners.contains(jobExecutionListener)) {
50                        listeners.add(jobExecutionListener);
51                }
52        }
53 
54        public void afterJob(JobExecution jobExecution) {
55                for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
56                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
57                        listener.afterJob(jobExecution);
58                }
59        }
60 
61        public void beforeJob(JobExecution jobExecution) {
62                for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
63                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
64                        listener.beforeJob(jobExecution);
65                }
66        }
67 
68        public void onError(JobExecution jobExecution, Throwable e) {
69                for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
70                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
71                        listener.onError(jobExecution, e);
72                }
73                
74        }
75 
76        public void onInterrupt(JobExecution jobExecution) {
77                for (Iterator iterator = listeners.listIterator(); iterator.hasNext();) {
78                        JobExecutionListener listener = (JobExecutionListener) iterator.next();
79                        listener.onInterrupt(jobExecution);
80                }
81                
82        }
83}

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