1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.flow; |
20 | |
|
21 | |
import java.util.ArrayList; |
22 | |
import java.util.Collections; |
23 | |
import java.util.List; |
24 | |
import javax.el.MethodExpression; |
25 | |
import javax.el.ValueExpression; |
26 | |
import javax.faces.flow.MethodCallNode; |
27 | |
import javax.faces.flow.Parameter; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public class MethodCallNodeImpl extends MethodCallNode implements Freezable |
35 | |
{ |
36 | |
private String _id; |
37 | |
private MethodExpression _methodExpression; |
38 | |
private ValueExpression _outcome; |
39 | |
|
40 | |
private List<Parameter> _parameters; |
41 | |
private List<Parameter> _unmodifiableParameters; |
42 | |
|
43 | |
private boolean _initialized; |
44 | |
|
45 | |
public MethodCallNodeImpl(String methodCallNodeId) |
46 | 0 | { |
47 | 0 | this._id = methodCallNodeId; |
48 | 0 | _parameters = new ArrayList<Parameter>(); |
49 | 0 | _unmodifiableParameters = Collections.unmodifiableList(_parameters); |
50 | 0 | } |
51 | |
|
52 | |
@Override |
53 | |
public MethodExpression getMethodExpression() |
54 | |
{ |
55 | 0 | return _methodExpression; |
56 | |
} |
57 | |
|
58 | |
@Override |
59 | |
public ValueExpression getOutcome() |
60 | |
{ |
61 | 0 | return _outcome; |
62 | |
} |
63 | |
|
64 | |
@Override |
65 | |
public List<Parameter> getParameters() |
66 | |
{ |
67 | 0 | return _unmodifiableParameters; |
68 | |
} |
69 | |
|
70 | |
public void addParameter(Parameter parameter) |
71 | |
{ |
72 | 0 | checkInitialized(); |
73 | 0 | _parameters.add(parameter); |
74 | 0 | } |
75 | |
|
76 | |
@Override |
77 | |
public String getId() |
78 | |
{ |
79 | 0 | return _id; |
80 | |
} |
81 | |
|
82 | |
public void freeze() |
83 | |
{ |
84 | 0 | _initialized = true; |
85 | |
|
86 | 0 | for (Parameter value : _parameters) |
87 | |
{ |
88 | 0 | if (value instanceof Freezable) |
89 | |
{ |
90 | 0 | ((Freezable)value).freeze(); |
91 | |
} |
92 | 0 | } |
93 | 0 | } |
94 | |
|
95 | |
private void checkInitialized() throws IllegalStateException |
96 | |
{ |
97 | 0 | if (_initialized) |
98 | |
{ |
99 | 0 | throw new IllegalStateException("Flow is inmutable once initialized"); |
100 | |
} |
101 | 0 | } |
102 | |
|
103 | |
public void setMethodExpression(MethodExpression methodExpression) |
104 | |
{ |
105 | 0 | checkInitialized(); |
106 | 0 | this._methodExpression = methodExpression; |
107 | 0 | } |
108 | |
|
109 | |
public void setOutcome(ValueExpression outcome) |
110 | |
{ |
111 | 0 | checkInitialized(); |
112 | 0 | this._outcome = outcome; |
113 | 0 | } |
114 | |
|
115 | |
public void setId(String id) |
116 | |
{ |
117 | 0 | checkInitialized(); |
118 | 0 | this._id = id; |
119 | 0 | } |
120 | |
} |