EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.core.listener]

COVERAGE SUMMARY FOR SOURCE FILE [CompositeJobExecutionListener.java]

nameclass, %method, %block, %line, %
CompositeJobExecutionListener.java100% (1/1)100% (5/5)100% (50/50)100% (16/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeJobExecutionListener100% (1/1)100% (5/5)100% (50/50)100% (16/16)
CompositeJobExecutionListener (): 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)
register (JobExecutionListener): void 100% (1/1)100% (5/5)100% (2/2)
setListeners (List): void 100% (1/1)100% (5/5)100% (2/2)

1/*
2 * Copyright 2006-2013 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;
19import java.util.List;
20 
21import org.springframework.batch.core.JobExecution;
22import org.springframework.batch.core.JobExecutionListener;
23import org.springframework.core.Ordered;
24 
25/**
26 * @author Dave Syer
27 *
28 */
29public class CompositeJobExecutionListener implements JobExecutionListener {
30 
31        private OrderedComposite<JobExecutionListener> listeners = new OrderedComposite<JobExecutionListener>();
32 
33        /**
34         * Public setter for the listeners.
35         *
36         * @param listeners
37         */
38        public void setListeners(List<? extends JobExecutionListener> listeners) {
39                this.listeners.setItems(listeners);
40        }
41 
42        /**
43         * Register additional listener.
44         *
45         * @param jobExecutionListener
46         */
47        public void register(JobExecutionListener jobExecutionListener) {
48                listeners.add(jobExecutionListener);
49        }
50 
51        /**
52         * Call the registered listeners in reverse order, respecting and
53         * prioritising those that implement {@link Ordered}.
54         * @see org.springframework.batch.core.JobExecutionListener#afterJob(org.springframework.batch.core.JobExecution)
55         */
56        @Override
57        public void afterJob(JobExecution jobExecution) {
58                for (Iterator<JobExecutionListener> iterator = listeners.reverse(); iterator.hasNext();) {
59                        JobExecutionListener listener = iterator.next();
60                        listener.afterJob(jobExecution);
61                }
62        }
63 
64        /**
65         * Call the registered listeners in order, respecting and prioritising those
66         * that implement {@link Ordered}.
67         * @see org.springframework.batch.core.JobExecutionListener#beforeJob(org.springframework.batch.core.JobExecution)
68         */
69        @Override
70        public void beforeJob(JobExecution jobExecution) {
71                for (Iterator<JobExecutionListener> iterator = listeners.iterator(); iterator.hasNext();) {
72                        JobExecutionListener listener = iterator.next();
73                        listener.beforeJob(jobExecution);
74                }
75        }
76 
77}

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