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.Collections; |
22 | |
import java.util.HashMap; |
23 | |
import java.util.Map; |
24 | |
import javax.el.ValueExpression; |
25 | |
import javax.faces.context.FacesContext; |
26 | |
import javax.faces.flow.FlowCallNode; |
27 | |
import javax.faces.flow.Parameter; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public class FlowCallNodeImpl extends FlowCallNode implements Freezable |
35 | |
{ |
36 | |
private String _id; |
37 | |
private String _calledFlowId; |
38 | |
private ValueExpression _calledFlowIdEL; |
39 | |
private String _calledFlowDocumentId; |
40 | |
private ValueExpression _calledFlowDocumentIdEL; |
41 | |
|
42 | |
private Map<String, Parameter> _outboundParametersMap; |
43 | |
private Map<String, Parameter> _unmodifiableOutboundParametersMap; |
44 | |
|
45 | |
private boolean _initialized; |
46 | |
|
47 | |
public FlowCallNodeImpl(String id) |
48 | 0 | { |
49 | 0 | this._id = id; |
50 | 0 | _outboundParametersMap = new HashMap<String, Parameter>(); |
51 | 0 | _unmodifiableOutboundParametersMap = Collections.unmodifiableMap(_outboundParametersMap); |
52 | 0 | } |
53 | |
|
54 | |
@Override |
55 | |
public Map<String, Parameter> getOutboundParameters() |
56 | |
{ |
57 | 0 | return _unmodifiableOutboundParametersMap; |
58 | |
} |
59 | |
|
60 | |
public void putOutboundParameter(String key, Parameter value) |
61 | |
{ |
62 | 0 | checkInitialized(); |
63 | 0 | _outboundParametersMap.put(key, value); |
64 | 0 | } |
65 | |
|
66 | |
@Override |
67 | |
public String getCalledFlowDocumentId(FacesContext context) |
68 | |
{ |
69 | 0 | if (_calledFlowDocumentIdEL != null) |
70 | |
{ |
71 | 0 | return (String) _calledFlowDocumentIdEL.getValue(context.getELContext()); |
72 | |
} |
73 | 0 | return _calledFlowDocumentId; |
74 | |
} |
75 | |
|
76 | |
@Override |
77 | |
public String getCalledFlowId(FacesContext context) |
78 | |
{ |
79 | 0 | if (_calledFlowIdEL != null) |
80 | |
{ |
81 | 0 | return (String) _calledFlowIdEL.getValue(context.getELContext()); |
82 | |
} |
83 | 0 | return _calledFlowId; |
84 | |
} |
85 | |
|
86 | |
@Override |
87 | |
public String getId() |
88 | |
{ |
89 | 0 | return _id; |
90 | |
} |
91 | |
|
92 | |
public void setId(String id) |
93 | |
{ |
94 | 0 | checkInitialized(); |
95 | 0 | this._id = id; |
96 | 0 | } |
97 | |
|
98 | |
public void setCalledFlowId(String calledFlowId) |
99 | |
{ |
100 | 0 | checkInitialized(); |
101 | 0 | this._calledFlowId = calledFlowId; |
102 | 0 | this._calledFlowIdEL = null; |
103 | 0 | } |
104 | |
|
105 | |
public void setCalledFlowDocumentId(String calledFlowDocumentId) |
106 | |
{ |
107 | 0 | checkInitialized(); |
108 | 0 | this._calledFlowDocumentId = calledFlowDocumentId; |
109 | 0 | this._calledFlowDocumentIdEL = null; |
110 | 0 | } |
111 | |
|
112 | |
public void freeze() |
113 | |
{ |
114 | 0 | _initialized = true; |
115 | |
|
116 | 0 | for (Map.Entry<String, Parameter> entry : _outboundParametersMap.entrySet()) |
117 | |
{ |
118 | 0 | if (entry.getValue() instanceof Freezable) |
119 | |
{ |
120 | 0 | ((Freezable)entry.getValue()).freeze(); |
121 | |
} |
122 | 0 | } |
123 | 0 | } |
124 | |
|
125 | |
private void checkInitialized() throws IllegalStateException |
126 | |
{ |
127 | 0 | if (_initialized) |
128 | |
{ |
129 | 0 | throw new IllegalStateException("Flow is inmutable once initialized"); |
130 | |
} |
131 | 0 | } |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public void setCalledFlowId(ValueExpression calledFlowIdEL) |
137 | |
{ |
138 | 0 | this._calledFlowIdEL = calledFlowIdEL; |
139 | 0 | this._calledFlowId = null; |
140 | 0 | } |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public void setCalledFlowDocumentId(ValueExpression calledFlowDocumentIdEL) |
146 | |
{ |
147 | 0 | this._calledFlowDocumentIdEL = calledFlowDocumentIdEL; |
148 | 0 | this._calledFlowDocumentId = null; |
149 | 0 | } |
150 | |
} |