1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.batch.item.support;
17
18 import java.util.ArrayList;
19 import java.util.Arrays;
20 import java.util.List;
21
22 import org.springframework.batch.item.ExecutionContext;
23 import org.springframework.batch.item.ItemStream;
24 import org.springframework.batch.item.ItemStreamException;
25
26
27
28
29
30
31
32 public class CompositeItemStream implements ItemStream {
33
34 private List<ItemStream> streams = new ArrayList<ItemStream>();
35
36
37
38
39
40
41 public void setStreams(ItemStream[] listeners) {
42 this.streams = Arrays.asList(listeners);
43 }
44
45
46
47
48
49
50 public void register(ItemStream stream) {
51 synchronized (streams) {
52 if (!streams.contains(stream)) {
53 streams.add(stream);
54 }
55 }
56 }
57
58
59
60
61 public CompositeItemStream() {
62 super();
63 }
64
65
66
67
68
69
70
71 public void update(ExecutionContext executionContext) {
72 for (ItemStream itemStream : streams) {
73 itemStream.update(executionContext);
74 }
75 }
76
77
78
79
80
81 public void close() throws ItemStreamException {
82 for (ItemStream itemStream : streams) {
83 itemStream.close();
84 }
85 }
86
87
88
89
90
91 public void open(ExecutionContext executionContext) throws ItemStreamException {
92 for (ItemStream itemStream : streams) {
93 itemStream.open(executionContext);
94 }
95 }
96
97 }