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 | |
|
37 | |
|
38 | |
|
39 | |
private static final long serialVersionUID = 2028442057178326047L; |
40 | |
|
41 | |
public static final String ALWAYS_CREATE_STRING = "ALWAYS_CREATE"; |
42 | |
public static final String NEVER_CREATE_STRING = "NEVER_CREATE"; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public MuleEndpoint() |
49 | |
{ |
50 | 0 | super(null, null, null, null, ENDPOINT_TYPE_SENDER_AND_RECEIVER, 0, null, null); |
51 | 0 | } |
52 | |
|
53 | |
public MuleEndpoint(String name, |
54 | |
UMOEndpointURI endpointUri, |
55 | |
UMOConnector connector, |
56 | |
UMOTransformer transformer, |
57 | |
String type, |
58 | |
int createConnector, |
59 | |
String endpointEncoding, |
60 | |
Map props) |
61 | |
{ |
62 | 0 | super(name, endpointUri, connector, transformer, type, createConnector, endpointEncoding, |
63 | |
props); |
64 | 0 | } |
65 | |
|
66 | |
public MuleEndpoint(UMOImmutableEndpoint endpoint) |
67 | |
{ |
68 | 0 | super(endpoint); |
69 | 0 | } |
70 | |
|
71 | |
public MuleEndpoint(String uri, boolean receiver) throws UMOException |
72 | |
{ |
73 | 0 | super(uri, receiver); |
74 | 0 | } |
75 | |
|
76 | |
public Object clone() |
77 | |
{ |
78 | 0 | UMOEndpoint clone = new MuleEndpoint(name, endpointUri, connector, transformer, type, |
79 | |
createConnector, endpointEncoding, properties); |
80 | |
|
81 | 0 | clone.setTransactionConfig(transactionConfig); |
82 | 0 | clone.setFilter(filter); |
83 | 0 | clone.setSecurityFilter(securityFilter); |
84 | |
try |
85 | |
{ |
86 | 0 | if (responseTransformer != null) |
87 | |
{ |
88 | 0 | clone.setResponseTransformer((UMOTransformer)responseTransformer.clone()); |
89 | |
} |
90 | |
} |
91 | 0 | catch (CloneNotSupportedException e1) |
92 | |
{ |
93 | |
|
94 | 0 | logger.error(e1.getMessage(), e1); |
95 | 0 | } |
96 | |
|
97 | 0 | if (remoteSync != null) |
98 | |
{ |
99 | 0 | clone.setRemoteSync(isRemoteSync()); |
100 | |
} |
101 | 0 | if (remoteSyncTimeout != null) |
102 | |
{ |
103 | 0 | clone.setRemoteSyncTimeout(getRemoteSyncTimeout()); |
104 | |
} |
105 | |
|
106 | 0 | if (synchronous != null) |
107 | |
{ |
108 | 0 | clone.setSynchronous(synchronous.booleanValue()); |
109 | |
} |
110 | |
|
111 | 0 | clone.setDeleteUnacceptedMessages(deleteUnacceptedMessages); |
112 | |
|
113 | 0 | clone.setInitialState(initialState); |
114 | 0 | if (initialised.get()) |
115 | |
{ |
116 | |
try |
117 | |
{ |
118 | 0 | clone.initialise(); |
119 | |
} |
120 | 0 | catch (InitialisationException e) |
121 | |
{ |
122 | |
|
123 | |
|
124 | |
|
125 | 0 | logger.error(e.getMessage(), e); |
126 | 0 | } |
127 | |
} |
128 | |
|
129 | 0 | return clone; |
130 | |
} |
131 | |
|
132 | |
public void setEndpointURI(UMOEndpointURI endpointUri) throws EndpointException |
133 | |
{ |
134 | 0 | 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 | 0 | this.endpointUri = endpointUri; |
142 | 0 | if (endpointUri != null) |
143 | |
{ |
144 | 0 | properties.putAll(endpointUri.getParams()); |
145 | |
} |
146 | 0 | } |
147 | |
|
148 | |
public void setEncoding(String endpointEncoding) |
149 | |
{ |
150 | 0 | this.endpointEncoding = endpointEncoding; |
151 | 0 | } |
152 | |
|
153 | |
public void setType(String type) |
154 | |
{ |
155 | 0 | this.type = type; |
156 | 0 | } |
157 | |
|
158 | |
public void setConnector(UMOConnector connector) |
159 | |
{ |
160 | 0 | 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 | 0 | this.connector = connector; |
168 | 0 | } |
169 | |
|
170 | |
public void setName(String name) |
171 | |
{ |
172 | 0 | this.name = name; |
173 | 0 | } |
174 | |
|
175 | |
public void setTransformer(UMOTransformer trans) |
176 | |
{ |
177 | 0 | transformer = trans; |
178 | 0 | if (transformer != null) |
179 | |
{ |
180 | 0 | transformer.setEndpoint(this); |
181 | |
} |
182 | 0 | } |
183 | |
|
184 | |
public void setProperties(Map props) |
185 | |
{ |
186 | 0 | properties.clear(); |
187 | 0 | properties.putAll(props); |
188 | 0 | } |
189 | |
|
190 | |
public boolean isReadOnly() |
191 | |
{ |
192 | 0 | return false; |
193 | |
} |
194 | |
|
195 | |
public void setTransactionConfig(UMOTransactionConfig config) |
196 | |
{ |
197 | 0 | transactionConfig = config; |
198 | 0 | } |
199 | |
|
200 | |
public void setFilter(UMOFilter filter) |
201 | |
{ |
202 | 0 | this.filter = filter; |
203 | 0 | } |
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
public void setDeleteUnacceptedMessages(boolean delete) |
212 | |
{ |
213 | 0 | deleteUnacceptedMessages = delete; |
214 | 0 | } |
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
public void setSecurityFilter(UMOEndpointSecurityFilter filter) |
225 | |
{ |
226 | 0 | securityFilter = filter; |
227 | 0 | if (securityFilter != null) |
228 | |
{ |
229 | 0 | securityFilter.setEndpoint(this); |
230 | |
} |
231 | 0 | } |
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
public void setSynchronous(boolean synchronous) |
243 | |
{ |
244 | 0 | this.synchronous = Boolean.valueOf(synchronous); |
245 | 0 | } |
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 | 0 | this.remoteSync = Boolean.valueOf(value); |
279 | 0 | if (value) |
280 | |
{ |
281 | 0 | this.synchronous = Boolean.TRUE; |
282 | |
} |
283 | 0 | } |
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 | 0 | this.initialState = state; |
304 | 0 | } |
305 | |
|
306 | |
public void setResponseTransformer(UMOTransformer trans) |
307 | |
{ |
308 | 0 | responseTransformer = trans; |
309 | 0 | } |
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 | |
} |