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