EMMA Coverage Report (generated Tue May 06 07:29:23 PDT 2008)
[all classes][org.springframework.batch.core.listener]

COVERAGE SUMMARY FOR SOURCE FILE [CompositeStepExecutionListener.java]

nameclass, %method, %block, %line, %
CompositeStepExecutionListener.java100% (1/1)100% (6/6)96%  (93/97)99%  (25.8/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeStepExecutionListener100% (1/1)100% (6/6)96%  (93/97)99%  (25.8/26)
onErrorInStep (StepExecution, Throwable): ExitStatus 100% (1/1)86%  (25/29)97%  (6.8/7)
CompositeStepExecutionListener (): void 100% (1/1)100% (8/8)100% (2/2)
afterStep (StepExecution): ExitStatus 100% (1/1)100% (28/28)100% (7/7)
beforeStep (StepExecution): void 100% (1/1)100% (16/16)100% (5/5)
register (StepExecutionListener): void 100% (1/1)100% (11/11)100% (3/3)
setListeners (StepExecutionListener []): 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.StepExecution;
24import org.springframework.batch.core.StepExecutionListener;
25import org.springframework.batch.repeat.ExitStatus;
26 
27/**
28 * @author Lucas Ward
29 * @author Dave Syer
30 * 
31 */
32public class CompositeStepExecutionListener implements StepExecutionListener {
33 
34        private List listeners = new ArrayList();
35 
36        /**
37         * Public setter for the listeners.
38         * 
39         * @param listeners
40         */
41        public void setListeners(StepExecutionListener[] listeners) {
42                this.listeners = Arrays.asList(listeners);
43        }
44 
45        /**
46         * Register additional listener.
47         * 
48         * @param stepExecutionListener
49         */
50        public void register(StepExecutionListener stepExecutionListener) {
51                if (!listeners.contains(stepExecutionListener)) {
52                        listeners.add(stepExecutionListener);
53                }
54        }
55 
56        /* (non-Javadoc)
57         * @see org.springframework.batch.core.domain.StepListener#close()
58         */
59        public ExitStatus afterStep(StepExecution stepExecution) {
60                ExitStatus status = null;
61                for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
62                        StepExecutionListener listener = (StepExecutionListener) iterator.next();
63                        ExitStatus close = listener.afterStep(stepExecution);
64                        status = status!=null ? status.and(close): close;
65                }
66                return status;
67        }
68 
69        /* (non-Javadoc)
70         * @see org.springframework.batch.core.domain.StepListener#open(org.springframework.batch.core.domain.JobParameters)
71         */
72        public void beforeStep(StepExecution stepExecution) {
73                for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
74                        StepExecutionListener listener = (StepExecutionListener) iterator.next();
75                        listener.beforeStep(stepExecution);
76                }
77        }
78 
79        /* (non-Javadoc)
80         * @see org.springframework.batch.core.domain.StepListener#onError(java.lang.Throwable)
81         */
82        public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
83                ExitStatus status = null;
84                for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
85                        StepExecutionListener listener = (StepExecutionListener) iterator.next();
86                        ExitStatus close = listener.onErrorInStep(stepExecution, e);
87                        status = status!=null ? status.and(close): close;
88                }
89                return status;
90        }
91}

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