1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl.endpoint; |
12 | |
|
13 | |
import org.mule.config.i18n.CoreMessages; |
14 | |
import org.mule.impl.ImmutableMuleEndpoint; |
15 | |
import org.mule.providers.service.TransportFactory; |
16 | |
import org.mule.umo.UMOException; |
17 | |
import org.mule.umo.UMOFilter; |
18 | |
import org.mule.umo.UMOTransactionConfig; |
19 | |
import org.mule.umo.endpoint.EndpointException; |
20 | |
import org.mule.umo.endpoint.UMOEndpoint; |
21 | |
import org.mule.umo.endpoint.UMOEndpointURI; |
22 | |
import org.mule.umo.endpoint.UMOImmutableEndpoint; |
23 | |
import org.mule.umo.lifecycle.InitialisationException; |
24 | |
import org.mule.umo.provider.UMOConnector; |
25 | |
import org.mule.umo.security.UMOEndpointSecurityFilter; |
26 | |
import org.mule.umo.transformer.UMOTransformer; |
27 | |
|
28 | |
import java.util.Map; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public class MuleEndpoint extends ImmutableMuleEndpoint implements UMOEndpoint |
35 | |
{ |
36 | |
public static final String ALWAYS_CREATE_STRING = "ALWAYS_CREATE"; |
37 | |
public static final String NEVER_CREATE_STRING = "NEVER_CREATE"; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
public MuleEndpoint() |
44 | |
{ |
45 | 812 | super(null, null, null, null, ENDPOINT_TYPE_SENDER_AND_RECEIVER, 0, null, null); |
46 | 812 | } |
47 | |
|
48 | |
public MuleEndpoint(String name, |
49 | |
UMOEndpointURI endpointUri, |
50 | |
UMOConnector connector, |
51 | |
UMOTransformer transformer, |
52 | |
String type, |
53 | |
int createConnector, |
54 | |
String endpointEncoding, |
55 | |
Map props) |
56 | |
{ |
57 | 14 | super(name, endpointUri, connector, transformer, type, createConnector, endpointEncoding, |
58 | |
props); |
59 | 14 | } |
60 | |
|
61 | |
public MuleEndpoint(UMOImmutableEndpoint endpoint) |
62 | |
{ |
63 | 2 | super(endpoint); |
64 | 2 | } |
65 | |
|
66 | |
public MuleEndpoint(String uri, boolean receiver) throws UMOException |
67 | |
{ |
68 | 38 | super(uri, receiver); |
69 | 38 | } |
70 | |
|
71 | |
public Object clone() |
72 | |
{ |
73 | 12 | UMOEndpoint clone = new MuleEndpoint(name, endpointUri, connector, transformer, type, |
74 | |
createConnector, endpointEncoding, properties); |
75 | |
|
76 | 12 | clone.setTransactionConfig(transactionConfig); |
77 | 12 | clone.setFilter(filter); |
78 | 12 | clone.setSecurityFilter(securityFilter); |
79 | |
try |
80 | |
{ |
81 | 12 | if (responseTransformer != null) |
82 | |
{ |
83 | 2 | clone.setResponseTransformer((UMOTransformer)responseTransformer.clone()); |
84 | |
} |
85 | |
} |
86 | 0 | catch (CloneNotSupportedException e1) |
87 | |
{ |
88 | |
|
89 | 0 | logger.error(e1.getMessage(), e1); |
90 | 12 | } |
91 | |
|
92 | 12 | if (remoteSync != null) |
93 | |
{ |
94 | 8 | clone.setRemoteSync(isRemoteSync()); |
95 | |
} |
96 | 12 | if (remoteSyncTimeout != null) |
97 | |
{ |
98 | 0 | clone.setRemoteSyncTimeout(getRemoteSyncTimeout()); |
99 | |
} |
100 | |
|
101 | 12 | if (synchronous != null) |
102 | |
{ |
103 | 8 | clone.setSynchronous(synchronous.booleanValue()); |
104 | |
} |
105 | |
|
106 | 12 | clone.setDeleteUnacceptedMessages(deleteUnacceptedMessages); |
107 | |
|
108 | 12 | clone.setInitialState(initialState); |
109 | 12 | if (initialised.get()) |
110 | |
{ |
111 | |
try |
112 | |
{ |
113 | 0 | clone.initialise(); |
114 | |
} |
115 | 0 | catch (InitialisationException e) |
116 | |
{ |
117 | |
|
118 | |
|
119 | |
|
120 | 0 | logger.error(e.getMessage(), e); |
121 | 0 | } |
122 | |
} |
123 | |
|
124 | 12 | if (streaming) |
125 | |
{ |
126 | 0 | clone.setStreaming(streaming); |
127 | |
} |
128 | |
|
129 | 12 | return clone; |
130 | |
} |
131 | |
|
132 | |
public void setEndpointURI(UMOEndpointURI endpointUri) throws EndpointException |
133 | |
{ |
134 | 846 | if (connector != null && endpointUri != null |
135 | |
&& !connector.supportsProtocol(endpointUri.getFullScheme())) |
136 | |
{ |
137 | 0 | throw new IllegalArgumentException( |
138 | |
CoreMessages.connectorSchemeIncompatibleWithEndpointScheme(connector.getProtocol(), |
139 | |
endpointUri).getMessage()); |
140 | |
} |
141 | 846 | this.endpointUri = endpointUri; |
142 | 846 | if (endpointUri != null) |
143 | |
{ |
144 | 846 | properties.putAll(endpointUri.getParams()); |
145 | |
} |
146 | 846 | } |
147 | |
|
148 | |
public void setEncoding(String endpointEncoding) |
149 | |
{ |
150 | 0 | this.endpointEncoding = endpointEncoding; |
151 | 0 | } |
152 | |
|
153 | |
public void setType(String type) |
154 | |
{ |
155 | 1702 | this.type = type; |
156 | 1702 | } |
157 | |
|
158 | |
public void setConnector(UMOConnector connector) |
159 | |
{ |
160 | 806 | if (connector != null && endpointUri != null |
161 | |
&& !connector.supportsProtocol(endpointUri.getFullScheme())) |
162 | |
{ |
163 | 0 | throw new IllegalArgumentException( |
164 | |
CoreMessages.connectorSchemeIncompatibleWithEndpointScheme(connector.getProtocol(), |
165 | |
endpointUri).getMessage()); |
166 | |
} |
167 | 806 | this.connector = connector; |
168 | 806 | } |
169 | |
|
170 | |
public void setName(String name) |
171 | |
{ |
172 | 834 | this.name = name; |
173 | 834 | } |
174 | |
|
175 | |
public void setTransformer(UMOTransformer trans) |
176 | |
{ |
177 | 108 | transformer = trans; |
178 | 108 | if (transformer != null) |
179 | |
{ |
180 | 24 | transformer.setEndpoint(this); |
181 | |
} |
182 | 108 | } |
183 | |
|
184 | |
public void setProperties(Map props) |
185 | |
{ |
186 | 4 | properties.clear(); |
187 | 4 | properties.putAll(props); |
188 | 4 | } |
189 | |
|
190 | |
public boolean isReadOnly() |
191 | |
{ |
192 | 0 | return false; |
193 | |
} |
194 | |
|
195 | |
public void setTransactionConfig(UMOTransactionConfig config) |
196 | |
{ |
197 | 12 | transactionConfig = config; |
198 | 12 | } |
199 | |
|
200 | |
public void setFilter(UMOFilter filter) |
201 | |
{ |
202 | 42 | this.filter = filter; |
203 | 42 | } |
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
public void setDeleteUnacceptedMessages(boolean delete) |
212 | |
{ |
213 | 12 | deleteUnacceptedMessages = delete; |
214 | 12 | } |
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
public void setSecurityFilter(UMOEndpointSecurityFilter filter) |
225 | |
{ |
226 | 12 | securityFilter = filter; |
227 | 12 | if (securityFilter != null) |
228 | |
{ |
229 | 0 | securityFilter.setEndpoint(this); |
230 | |
} |
231 | 12 | } |
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
public void setSynchronous(boolean synchronous) |
243 | |
{ |
244 | 8 | this.synchronous = Boolean.valueOf(synchronous); |
245 | 8 | } |
246 | |
|
247 | |
public void setCreateConnector(int action) |
248 | |
{ |
249 | 0 | createConnector = action; |
250 | 0 | } |
251 | |
|
252 | |
public void setCreateConnectorAsString(String action) |
253 | |
{ |
254 | 0 | if (ALWAYS_CREATE_STRING.equals(action)) |
255 | |
{ |
256 | 0 | createConnector = TransportFactory.ALWAYS_CREATE_CONNECTOR; |
257 | |
} |
258 | 0 | else if (NEVER_CREATE_STRING.equals(action)) |
259 | |
{ |
260 | 0 | createConnector = TransportFactory.NEVER_CREATE_CONNECTOR; |
261 | |
} |
262 | |
else |
263 | |
{ |
264 | 0 | createConnector = TransportFactory.GET_OR_CREATE_CONNECTOR; |
265 | |
} |
266 | 0 | } |
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
public void setRemoteSync(boolean value) |
277 | |
{ |
278 | 48 | this.remoteSync = Boolean.valueOf(value); |
279 | 48 | if (value) |
280 | |
{ |
281 | 48 | this.synchronous = Boolean.TRUE; |
282 | |
} |
283 | 48 | } |
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
public void setRemoteSyncTimeout(int timeout) |
291 | |
{ |
292 | 0 | this.remoteSyncTimeout = new Integer(timeout); |
293 | 0 | } |
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
public void setInitialState(String state) |
302 | |
{ |
303 | 12 | this.initialState = state; |
304 | 12 | } |
305 | |
|
306 | |
public void setResponseTransformer(UMOTransformer trans) |
307 | |
{ |
308 | 54 | responseTransformer = trans; |
309 | 54 | } |
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
public void setStreaming(boolean stream) |
317 | |
{ |
318 | 0 | this.streaming = stream; |
319 | 0 | } |
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
public void setProperty(String key, Object value) |
328 | |
{ |
329 | 0 | properties.put(key, value); |
330 | 0 | } |
331 | |
} |