EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.item.support]

COVERAGE SUMMARY FOR SOURCE FILE [CompositeItemWriter.java]

nameclass, %method, %block, %line, %
CompositeItemWriter.java100% (1/1)50%  (4/8)46%  (49/107)46%  (11/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompositeItemWriter100% (1/1)50%  (4/8)46%  (49/107)46%  (11/24)
afterPropertiesSet (): void 0%   (0/1)0%   (0/9)0%   (0/3)
close (): void 0%   (0/1)0%   (0/22)0%   (0/4)
setIgnoreItemStream (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
update (ExecutionContext): void 0%   (0/1)0%   (0/23)0%   (0/4)
CompositeItemWriter (): void 100% (1/1)100% (6/6)100% (2/2)
open (ExecutionContext): void 100% (1/1)100% (23/23)100% (4/4)
setDelegates (List): void 100% (1/1)100% (4/4)100% (2/2)
write (List): void 100% (1/1)100% (16/16)100% (3/3)

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 */
16 
17package org.springframework.batch.item.support;
18 
19import java.util.List;
20 
21import org.springframework.batch.item.ExecutionContext;
22import org.springframework.batch.item.ItemStream;
23import org.springframework.batch.item.ItemStreamException;
24import org.springframework.batch.item.ItemStreamWriter;
25import org.springframework.batch.item.ItemWriter;
26import org.springframework.beans.factory.InitializingBean;
27import org.springframework.util.Assert;
28 
29/**
30 * Calls a collection of {@link ItemWriter}s in fixed-order sequence.<br/>
31 * <br/>
32 * 
33 * The implementation is thread-safe if all delegates are thread-safe.
34 * 
35 * @author Robert Kasanicky
36 * @author Dave Syer
37 */
38public class CompositeItemWriter<T> implements ItemStreamWriter<T>, InitializingBean {
39 
40        private List<ItemWriter<? super T>> delegates;
41 
42        private boolean ignoreItemStream = false;
43 
44        public void setIgnoreItemStream(boolean ignoreItemStream) {
45                this.ignoreItemStream = ignoreItemStream;
46        }
47 
48        public void write(List<? extends T> item) throws Exception {
49                for (ItemWriter<? super T> writer : delegates) {
50                        writer.write(item);
51                }
52        }
53 
54        public void afterPropertiesSet() throws Exception {
55                Assert.notNull(delegates, "The 'delgates' may not be null");
56                Assert.notEmpty(delegates, "The 'delgates' may not be empty");
57        }
58 
59        public void setDelegates(List<ItemWriter<? super T>> delegates) {
60                this.delegates = delegates;
61        }
62 
63        public void close() throws ItemStreamException {
64                for (ItemWriter<? super T> writer : delegates) {
65                        if (!ignoreItemStream && (writer instanceof ItemStream)) {
66                                ((ItemStream) writer).close();
67                        }
68                }
69        }
70 
71        public void open(ExecutionContext executionContext) throws ItemStreamException {
72                for (ItemWriter<? super T> writer : delegates) {
73                        if (!ignoreItemStream && (writer instanceof ItemStream)) {
74                                ((ItemStream) writer).open(executionContext);
75                        }
76                }
77        }
78 
79        public void update(ExecutionContext executionContext) throws ItemStreamException {
80                for (ItemWriter<? super T> writer : delegates) {
81                        if (!ignoreItemStream && (writer instanceof ItemStream)) {
82                                ((ItemStream) writer).update(executionContext);
83                        }
84                }
85        }
86 
87}

[all classes][org.springframework.batch.item.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov