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