1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.nordija.tapestry.bayeux.stream;
17
18 import org.apache.hivemind.util.Defense;
19 import org.apache.tapestry.IDynamicInvoker;
20
21 import java.util.Collection;
22
23
24
25
26 public class StreamServiceParameter {
27
28 private IStream stream;
29
30 private String streamResourceSourceExtentionName;
31
32 private Object[] serviceParameters;
33
34 private String[] updateParts;
35
36 private boolean json;
37
38 private boolean async;
39
40 public StreamServiceParameter(IStream stream, String streamResourceSourceExtentionName, Object[] serviceParameters) {
41 this(stream, streamResourceSourceExtentionName, serviceParameters, null);
42 }
43
44 public StreamServiceParameter(IStream stream, String streamResourceSourceExtentionName, Object[] serviceParameters, IDynamicInvoker invoker) {
45 Defense.notNull(stream, "stream");
46 this.stream = stream;
47 this.serviceParameters = serviceParameters;
48 this.streamResourceSourceExtentionName = streamResourceSourceExtentionName;
49
50 if (invoker == null) {
51
52 Collection comps = stream.getUpdateComponents();
53 if (comps == null)
54 updateParts = new String[0];
55 else
56 updateParts = (String[]) comps.toArray(new String[comps.size()]);
57
58 json = stream.isJson();
59 async = stream.isAsync();
60 } else {
61
62 Collection comps = invoker.getUpdateComponents();
63 if (comps == null)
64 updateParts = new String[0];
65 else
66 updateParts = (String[]) comps.toArray(new String[comps.size()]);
67
68 json = invoker.isJson();
69 async = invoker.isAsync();
70 }
71
72
73 if (!json && !async && updateParts.length > 0)
74 async = true;
75
76 }
77
78 public IStream getStream() {
79 return stream;
80 }
81
82 public String getStreamResourceSourceExtentionName() {
83 return streamResourceSourceExtentionName;
84 }
85
86 public Object[] getServiceParameters() {
87 return serviceParameters;
88 }
89
90 public String[] getUpdateParts() {
91 return updateParts;
92 }
93
94 public boolean isJson() {
95 return json;
96 }
97
98 public boolean isAsync() {
99 return async;
100 }
101 }