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 |
9 |
this(direct, null); |
44 |
9 |
} |
45 |
|
|
46 |
|
public DirectServiceParameter(IDirect direct, Object[] serviceParameters) |
47 |
|
{ |
48 |
15 |
this(direct, serviceParameters, null); |
49 |
15 |
} |
50 |
|
|
51 |
|
public DirectServiceParameter(IDirect direct, Object[] serviceParameters, IDynamicInvoker invoker) |
52 |
17 |
{ |
53 |
17 |
Defense.notNull(direct, "direct"); |
54 |
|
|
55 |
17 |
_direct = direct; |
56 |
17 |
_serviceParameters = serviceParameters; |
57 |
|
|
58 |
17 |
if (invoker == null) { |
59 |
|
|
60 |
15 |
Collection comps = direct.getUpdateComponents(); |
61 |
15 |
if (comps == null) |
62 |
6 |
_updateParts = new String[0]; |
63 |
|
else |
64 |
9 |
_updateParts = (String[])comps.toArray(new String[comps.size()]); |
65 |
|
|
66 |
15 |
_json = direct.isJson(); |
67 |
15 |
_async = direct.isAsync(); |
68 |
15 |
} else { |
69 |
|
|
70 |
2 |
Collection comps = invoker.getUpdateComponents(); |
71 |
2 |
if (comps == null) |
72 |
0 |
_updateParts = new String[0]; |
73 |
|
else |
74 |
2 |
_updateParts = (String[])comps.toArray(new String[comps.size()]); |
75 |
|
|
76 |
2 |
_json = invoker.isJson(); |
77 |
2 |
_async = invoker.isAsync(); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
17 |
if (!_json && !_async && _updateParts.length > 0) |
83 |
1 |
_async = true; |
84 |
17 |
} |
85 |
|
|
86 |
|
public IDirect getDirect() |
87 |
|
{ |
88 |
8 |
return _direct; |
89 |
|
} |
90 |
|
|
91 |
|
public Object[] getServiceParameters() |
92 |
|
{ |
93 |
4 |
return _serviceParameters; |
94 |
|
} |
95 |
|
|
96 |
|
public String[] getUpdateParts() |
97 |
|
{ |
98 |
0 |
return _updateParts; |
99 |
|
} |
100 |
|
|
101 |
|
public boolean isJson() |
102 |
|
{ |
103 |
4 |
return _json; |
104 |
|
} |
105 |
|
|
106 |
|
public boolean isAsync() |
107 |
|
{ |
108 |
4 |
return _async; |
109 |
|
} |
110 |
|
} |