EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[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%  (13/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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    @Override
49        public void write(List<? extends T> item) throws Exception {
50                for (ItemWriter<? super T> writer : delegates) {
51                        writer.write(item);
52                }
53        }
54 
55    @Override
56        public void afterPropertiesSet() throws Exception {
57                Assert.notNull(delegates, "The 'delegates' may not be null");
58                Assert.notEmpty(delegates, "The 'delegates' may not be empty");
59        }
60 
61        public void setDelegates(List<ItemWriter<? super T>> delegates) {
62                this.delegates = delegates;
63        }
64 
65    @Override
66        public void close() throws ItemStreamException {
67                for (ItemWriter<? super T> writer : delegates) {
68                        if (!ignoreItemStream && (writer instanceof ItemStream)) {
69                                ((ItemStream) writer).close();
70                        }
71                }
72        }
73 
74    @Override
75        public void open(ExecutionContext executionContext) throws ItemStreamException {
76                for (ItemWriter<? super T> writer : delegates) {
77                        if (!ignoreItemStream && (writer instanceof ItemStream)) {
78                                ((ItemStream) writer).open(executionContext);
79                        }
80                }
81        }
82 
83    @Override
84        public void update(ExecutionContext executionContext) throws ItemStreamException {
85                for (ItemWriter<? super T> writer : delegates) {
86                        if (!ignoreItemStream && (writer instanceof ItemStream)) {
87                                ((ItemStream) writer).update(executionContext);
88                        }
89                }
90        }
91 
92}

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