1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule; |
8 | |
|
9 | |
import org.mule.api.DefaultMuleException; |
10 | |
import org.mule.api.MuleContext; |
11 | |
import org.mule.api.MuleEvent; |
12 | |
import org.mule.api.MuleException; |
13 | |
import org.mule.api.MuleMessage; |
14 | |
import org.mule.api.MuleSession; |
15 | |
import org.mule.api.ThreadSafeAccess; |
16 | |
import org.mule.api.config.MuleProperties; |
17 | |
import org.mule.api.construct.FlowConstruct; |
18 | |
import org.mule.api.endpoint.EndpointBuilder; |
19 | |
import org.mule.api.endpoint.EndpointURI; |
20 | |
import org.mule.api.endpoint.ImmutableEndpoint; |
21 | |
import org.mule.api.endpoint.InboundEndpoint; |
22 | |
import org.mule.api.registry.ServiceType; |
23 | |
import org.mule.api.security.Credentials; |
24 | |
import org.mule.api.transformer.DataType; |
25 | |
import org.mule.api.transformer.Transformer; |
26 | |
import org.mule.api.transformer.TransformerException; |
27 | |
import org.mule.api.transport.ReplyToHandler; |
28 | |
import org.mule.config.i18n.CoreMessages; |
29 | |
import org.mule.endpoint.DefaultEndpointFactory; |
30 | |
import org.mule.endpoint.MuleEndpointURI; |
31 | |
import org.mule.management.stats.ProcessingTime; |
32 | |
import org.mule.security.MuleCredentials; |
33 | |
import org.mule.session.DefaultMuleSession; |
34 | |
import org.mule.transformer.types.DataTypeFactory; |
35 | |
import org.mule.transport.service.TransportServiceDescriptor; |
36 | |
import org.mule.util.ObjectNameHelper; |
37 | |
import org.mule.util.UUID; |
38 | |
import org.mule.util.store.DeserializationPostInitialisable; |
39 | |
|
40 | |
import java.io.IOException; |
41 | |
import java.io.ObjectInputStream; |
42 | |
import java.io.ObjectOutputStream; |
43 | |
import java.io.OutputStream; |
44 | |
import java.util.EventObject; |
45 | |
import java.util.HashMap; |
46 | |
import java.util.Iterator; |
47 | |
import java.util.LinkedList; |
48 | |
import java.util.List; |
49 | |
import java.util.Map; |
50 | |
|
51 | |
import org.apache.commons.logging.Log; |
52 | |
import org.apache.commons.logging.LogFactory; |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public class DefaultMuleEvent extends EventObject implements MuleEvent, ThreadSafeAccess, DeserializationPostInitialisable |
64 | |
{ |
65 | |
|
66 | |
|
67 | |
|
68 | |
private static final long serialVersionUID = 1L; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | 0 | private static Log logger = LogFactory.getLog(DefaultMuleEvent.class); |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | 0 | private transient ImmutableEndpoint endpoint = null; |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | 0 | private String id = null; |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | 0 | private MuleMessage message = null; |
89 | |
|
90 | |
private MuleSession session; |
91 | |
|
92 | 0 | private boolean stopFurtherProcessing = false; |
93 | |
|
94 | 0 | private int timeout = TIMEOUT_NOT_SET_VALUE; |
95 | |
|
96 | 0 | private transient ResponseOutputStream outputStream = null; |
97 | |
|
98 | 0 | private transient Object transformedMessage = null; |
99 | |
|
100 | 0 | private Credentials credentials = null; |
101 | |
|
102 | 0 | protected String[] ignoredPropertyOverrides = new String[]{MuleProperties.MULE_METHOD_PROPERTY}; |
103 | |
|
104 | 0 | private transient Map<String, Object> serializedData = null; |
105 | |
|
106 | |
private final ProcessingTime processingTime; |
107 | |
|
108 | |
private Object replyToDestination; |
109 | |
|
110 | |
private ReplyToHandler replyToHanlder; |
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public DefaultMuleEvent(MuleMessage message, |
123 | |
ImmutableEndpoint endpoint, |
124 | |
FlowConstruct service, |
125 | |
MuleEvent previousEvent) |
126 | |
{ |
127 | 0 | super(message.getPayload()); |
128 | 0 | this.message = message; |
129 | 0 | this.id = generateEventId(); |
130 | 0 | this.session = previousEvent.getSession(); |
131 | 0 | session.setFlowConstruct(service); |
132 | 0 | this.endpoint = endpoint; |
133 | 0 | this.timeout = previousEvent.getTimeout(); |
134 | 0 | this.outputStream = (ResponseOutputStream) previousEvent.getOutputStream(); |
135 | 0 | this.processingTime = ProcessingTime.newInstance(this.session, message.getMuleContext()); |
136 | 0 | this.replyToDestination = previousEvent.getReplyToDestination(); |
137 | 0 | this.replyToHanlder = previousEvent.getReplyToHandler(); |
138 | 0 | fillProperties(); |
139 | 0 | } |
140 | |
|
141 | |
public DefaultMuleEvent(MuleMessage message, |
142 | |
ImmutableEndpoint endpoint, |
143 | |
MuleEvent previousEvent, |
144 | |
MuleSession session) |
145 | |
{ |
146 | 0 | super(message.getPayload()); |
147 | 0 | this.message = message; |
148 | 0 | this.id = previousEvent.getId(); |
149 | 0 | this.session = session; |
150 | 0 | this.endpoint = endpoint; |
151 | 0 | this.timeout = previousEvent.getTimeout(); |
152 | 0 | this.outputStream = (ResponseOutputStream) previousEvent.getOutputStream(); |
153 | 0 | this.processingTime = ProcessingTime.newInstance(this.session, message.getMuleContext()); |
154 | 0 | this.replyToDestination = previousEvent.getReplyToDestination(); |
155 | 0 | this.replyToHanlder = previousEvent.getReplyToHandler(); |
156 | 0 | fillProperties(); |
157 | 0 | } |
158 | |
|
159 | |
public DefaultMuleEvent(MuleMessage message, |
160 | |
ImmutableEndpoint endpoint, |
161 | |
MuleSession session) |
162 | |
{ |
163 | 0 | this(message, endpoint, session, null, null, null); |
164 | 0 | } |
165 | |
|
166 | |
public DefaultMuleEvent(MuleMessage message, |
167 | |
ImmutableEndpoint endpoint, |
168 | |
MuleSession session, |
169 | |
ProcessingTime time) |
170 | |
{ |
171 | 0 | this(message, endpoint, session, null, time, null); |
172 | 0 | } |
173 | |
|
174 | |
public DefaultMuleEvent(MuleMessage message, |
175 | |
ImmutableEndpoint endpoint, |
176 | |
MuleSession session, |
177 | |
ResponseOutputStream outputStream) |
178 | |
{ |
179 | 0 | this(message, endpoint, session, outputStream, null, null); |
180 | 0 | } |
181 | |
|
182 | |
public DefaultMuleEvent(MuleMessage message, |
183 | |
ImmutableEndpoint endpoint, |
184 | |
MuleSession session, |
185 | |
ResponseOutputStream outputStream, |
186 | |
ProcessingTime time, |
187 | |
ReplyToHandler replyToHandler) |
188 | |
{ |
189 | 0 | super(message.getPayload()); |
190 | 0 | this.message = message; |
191 | 0 | this.endpoint = endpoint; |
192 | 0 | this.session = session; |
193 | 0 | this.id = generateEventId(); |
194 | 0 | this.outputStream = outputStream; |
195 | 0 | fillProperties(); |
196 | 0 | this.processingTime = time != null ? time : ProcessingTime.newInstance(this.session, message.getMuleContext()); |
197 | 0 | this.replyToHanlder = replyToHandler; |
198 | 0 | } |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
public DefaultMuleEvent(MuleMessage message, MuleEvent rewriteEvent) |
207 | |
{ |
208 | 0 | super(message.getPayload()); |
209 | 0 | this.message = message; |
210 | 0 | this.id = rewriteEvent.getId(); |
211 | 0 | this.session = rewriteEvent.getSession(); |
212 | 0 | session.setFlowConstruct(rewriteEvent.getFlowConstruct()); |
213 | 0 | this.endpoint = rewriteEvent.getEndpoint(); |
214 | 0 | this.timeout = rewriteEvent.getTimeout(); |
215 | 0 | this.outputStream = (ResponseOutputStream) rewriteEvent.getOutputStream(); |
216 | 0 | if (rewriteEvent instanceof DefaultMuleEvent) |
217 | |
{ |
218 | 0 | this.transformedMessage = ((DefaultMuleEvent) rewriteEvent).getCachedMessage(); |
219 | 0 | this.processingTime = ((DefaultMuleEvent)rewriteEvent).processingTime; |
220 | |
} |
221 | |
else |
222 | |
{ |
223 | 0 | this.processingTime = ProcessingTime.newInstance(this.session, message.getMuleContext()); |
224 | |
} |
225 | 0 | this.replyToDestination = rewriteEvent.getReplyToDestination(); |
226 | 0 | this.replyToHanlder = rewriteEvent.getReplyToHandler(); |
227 | 0 | fillProperties(); |
228 | 0 | } |
229 | |
|
230 | |
protected void fillProperties() |
231 | |
{ |
232 | 0 | if (endpoint != null && endpoint.getProperties() != null) |
233 | |
{ |
234 | 0 | for (Iterator<?> iterator = endpoint.getProperties().keySet().iterator(); iterator.hasNext();) |
235 | |
{ |
236 | 0 | String prop = (String) iterator.next(); |
237 | 0 | Object value = endpoint.getProperties().get(prop); |
238 | |
|
239 | 0 | if (!ignoreProperty(prop)) |
240 | |
{ |
241 | |
|
242 | 0 | message.setInvocationProperty(prop, value); |
243 | |
} |
244 | 0 | } |
245 | |
} |
246 | |
|
247 | 0 | setCredentials(); |
248 | 0 | } |
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
protected boolean ignoreProperty(String key) |
263 | |
{ |
264 | 0 | if (key == null) |
265 | |
{ |
266 | 0 | return true; |
267 | |
} |
268 | |
|
269 | 0 | for (int i = 0; i < ignoredPropertyOverrides.length; i++) |
270 | |
{ |
271 | 0 | if (key.equals(ignoredPropertyOverrides[i])) |
272 | |
{ |
273 | 0 | return false; |
274 | |
} |
275 | |
} |
276 | |
|
277 | 0 | return null != message.getOutboundProperty(key); |
278 | |
} |
279 | |
|
280 | |
protected void setCredentials() |
281 | |
{ |
282 | 0 | if (null != endpoint && null != endpoint.getEndpointURI() && null != endpoint.getEndpointURI().getUserInfo()) |
283 | |
{ |
284 | 0 | final String userName = endpoint.getEndpointURI().getUser(); |
285 | 0 | final String password = endpoint.getEndpointURI().getPassword(); |
286 | 0 | if (password != null && userName != null) |
287 | |
{ |
288 | 0 | credentials = new MuleCredentials(userName, password.toCharArray()); |
289 | |
} |
290 | |
} |
291 | 0 | } |
292 | |
|
293 | |
public Credentials getCredentials() |
294 | |
{ |
295 | 0 | MuleCredentials creds = message.getOutboundProperty(MuleProperties.MULE_CREDENTIALS_PROPERTY); |
296 | 0 | return (credentials != null ? credentials : creds); |
297 | |
} |
298 | |
|
299 | |
Object getCachedMessage() |
300 | |
{ |
301 | 0 | return transformedMessage; |
302 | |
} |
303 | |
|
304 | |
public MuleMessage getMessage() |
305 | |
{ |
306 | 0 | return message; |
307 | |
} |
308 | |
|
309 | |
public byte[] getMessageAsBytes() throws DefaultMuleException |
310 | |
{ |
311 | |
try |
312 | |
{ |
313 | 0 | return message.getPayloadAsBytes(); |
314 | |
} |
315 | 0 | catch (Exception e) |
316 | |
{ |
317 | 0 | throw new DefaultMuleException( |
318 | |
CoreMessages.cannotReadPayloadAsBytes(message.getPayload().getClass().getName()), e); |
319 | |
} |
320 | |
} |
321 | |
|
322 | |
@SuppressWarnings("cast") |
323 | |
public <T> T transformMessage(Class<T> outputType) throws TransformerException |
324 | |
{ |
325 | 0 | return (T) transformMessage(DataTypeFactory.create(outputType)); |
326 | |
} |
327 | |
|
328 | |
public <T> T transformMessage(DataType<T> outputType) throws TransformerException |
329 | |
{ |
330 | 0 | if (outputType == null) |
331 | |
{ |
332 | 0 | throw new TransformerException(CoreMessages.objectIsNull("outputType")); |
333 | |
} |
334 | 0 | return message.getPayload(outputType); |
335 | |
} |
336 | |
|
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
|
349 | |
@Deprecated |
350 | |
public byte[] transformMessageToBytes() throws TransformerException |
351 | |
{ |
352 | 0 | return transformMessage(DataType.BYTE_ARRAY_DATA_TYPE); |
353 | |
} |
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
public String transformMessageToString() throws TransformerException |
368 | |
{ |
369 | 0 | return transformMessage(DataTypeFactory.createWithEncoding(String.class, getEncoding())); |
370 | |
} |
371 | |
|
372 | |
public String getMessageAsString() throws MuleException |
373 | |
{ |
374 | 0 | return getMessageAsString(getEncoding()); |
375 | |
} |
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
public String getMessageAsString(String encoding) throws MuleException |
386 | |
{ |
387 | |
try |
388 | |
{ |
389 | 0 | return message.getPayloadForLogging(encoding); |
390 | |
} |
391 | 0 | catch (Exception e) |
392 | |
{ |
393 | 0 | throw new DefaultMuleException( |
394 | |
CoreMessages.cannotReadPayloadAsString(message.getClass().getName()), e); |
395 | |
} |
396 | |
} |
397 | |
|
398 | |
public String getId() |
399 | |
{ |
400 | 0 | return id; |
401 | |
} |
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
@Deprecated |
408 | |
public Object getProperty(String name) |
409 | |
{ |
410 | 0 | throw new UnsupportedOperationException("Method's behavior has changed in Mule 3, use " + |
411 | |
"event.getMessage() and suitable scope-aware property access " + |
412 | |
"methods on it"); |
413 | |
} |
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
@Deprecated |
420 | |
public Object getProperty(String name, Object defaultValue) |
421 | |
{ |
422 | 0 | throw new UnsupportedOperationException("Method's behavior has changed in Mule 3, use " + |
423 | |
"event.getMessage() and suitable scope-aware property access " + |
424 | |
"methods on it"); |
425 | |
} |
426 | |
|
427 | |
public ImmutableEndpoint getEndpoint() |
428 | |
{ |
429 | 0 | return endpoint; |
430 | |
} |
431 | |
|
432 | |
@Override |
433 | |
public String toString() |
434 | |
{ |
435 | 0 | StringBuffer buf = new StringBuffer(64); |
436 | 0 | buf.append("MuleEvent: ").append(getId()); |
437 | 0 | buf.append(", stop processing=").append(isStopFurtherProcessing()); |
438 | 0 | buf.append(", ").append(endpoint); |
439 | |
|
440 | 0 | return buf.toString(); |
441 | |
} |
442 | |
|
443 | |
protected String generateEventId() |
444 | |
{ |
445 | 0 | return UUID.getUUID(); |
446 | |
} |
447 | |
|
448 | |
public MuleSession getSession() |
449 | |
{ |
450 | 0 | return session; |
451 | |
} |
452 | |
|
453 | |
void setSession(MuleSession session) |
454 | |
{ |
455 | 0 | this.session = session; |
456 | 0 | } |
457 | |
|
458 | |
|
459 | |
|
460 | |
|
461 | |
public FlowConstruct getFlowConstruct() |
462 | |
{ |
463 | 0 | return session.getFlowConstruct(); |
464 | |
} |
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
public boolean isStopFurtherProcessing() |
472 | |
{ |
473 | 0 | return stopFurtherProcessing; |
474 | |
} |
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
public void setStopFurtherProcessing(boolean stopFurtherProcessing) |
488 | |
{ |
489 | 0 | this.stopFurtherProcessing = stopFurtherProcessing; |
490 | 0 | } |
491 | |
|
492 | |
@Override |
493 | |
public boolean equals(Object o) |
494 | |
{ |
495 | 0 | if (this == o) |
496 | |
{ |
497 | 0 | return true; |
498 | |
} |
499 | 0 | if (!(o instanceof DefaultMuleEvent)) |
500 | |
{ |
501 | 0 | return false; |
502 | |
} |
503 | |
|
504 | 0 | final DefaultMuleEvent event = (DefaultMuleEvent) o; |
505 | |
|
506 | 0 | if (message != null ? !message.equals(event.message) : event.message != null) |
507 | |
{ |
508 | 0 | return false; |
509 | |
} |
510 | 0 | return id.equals(event.id); |
511 | |
} |
512 | |
|
513 | |
@Override |
514 | |
public int hashCode() |
515 | |
{ |
516 | 0 | return 29 * id.hashCode() + (message != null ? message.hashCode() : 0); |
517 | |
} |
518 | |
|
519 | |
public int getTimeout() |
520 | |
{ |
521 | 0 | if (timeout == TIMEOUT_NOT_SET_VALUE) |
522 | |
{ |
523 | |
|
524 | 0 | timeout = endpoint.getResponseTimeout(); |
525 | |
} |
526 | 0 | return timeout; |
527 | |
} |
528 | |
|
529 | |
public void setTimeout(int timeout) |
530 | |
{ |
531 | 0 | this.timeout = timeout; |
532 | 0 | } |
533 | |
|
534 | |
|
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
|
541 | |
public OutputStream getOutputStream() |
542 | |
{ |
543 | 0 | return outputStream; |
544 | |
} |
545 | |
|
546 | |
private void writeObject(ObjectOutputStream out) throws IOException |
547 | |
{ |
548 | 0 | out.defaultWriteObject(); |
549 | 0 | out.writeInt(endpoint.hashCode()); |
550 | 0 | out.writeBoolean(endpoint instanceof InboundEndpoint); |
551 | 0 | out.writeObject(endpoint.getEndpointBuilderName()); |
552 | |
|
553 | 0 | String uri = endpoint.getEndpointURI().getUri().toString(); |
554 | |
|
555 | 0 | if (ObjectNameHelper.isDefaultAutoGeneratedConnector(endpoint.getConnector())) |
556 | |
{ |
557 | |
|
558 | |
|
559 | |
|
560 | 0 | out.writeObject(uri); |
561 | |
} |
562 | |
else |
563 | |
{ |
564 | |
|
565 | |
|
566 | |
|
567 | 0 | out.writeObject(uri + "?connector=" + endpoint.getConnector().getName()); |
568 | |
} |
569 | |
|
570 | |
|
571 | 0 | out.writeInt(endpoint.getTransformers().size()); |
572 | |
|
573 | |
|
574 | 0 | if (endpoint.getTransformers().size() > 0) |
575 | |
{ |
576 | 0 | for (Transformer transformer : endpoint.getTransformers()) |
577 | |
{ |
578 | 0 | out.writeObject(transformer.getName()); |
579 | |
} |
580 | |
} |
581 | 0 | } |
582 | |
|
583 | |
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException, MuleException |
584 | |
{ |
585 | 0 | in.defaultReadObject(); |
586 | 0 | serializedData = new HashMap<String, Object>(); |
587 | 0 | serializedData.put("endpointHashcode", in.readInt()); |
588 | 0 | serializedData.put("isInboundEndpoint", in.readBoolean()); |
589 | 0 | serializedData.put("endpointBuilderName", in.readObject()); |
590 | 0 | serializedData.put("endpointUri", in.readObject()); |
591 | 0 | int count = in.readInt(); |
592 | |
|
593 | 0 | List<String> transformerNames = new LinkedList<String>(); |
594 | 0 | if (count > 0) |
595 | |
{ |
596 | 0 | while (--count > 0) |
597 | |
{ |
598 | 0 | transformerNames.add((String) in.readObject()); |
599 | |
} |
600 | |
} |
601 | 0 | serializedData.put("transformers", transformerNames); |
602 | 0 | } |
603 | |
|
604 | |
|
605 | |
|
606 | |
|
607 | |
|
608 | |
|
609 | |
|
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
@SuppressWarnings({"unused", "unchecked"}) |
616 | |
private void initAfterDeserialisation(MuleContext muleContext) throws MuleException |
617 | |
{ |
618 | 0 | if (session instanceof DefaultMuleSession) |
619 | |
{ |
620 | 0 | ((DefaultMuleSession) session).initAfterDeserialisation(muleContext); |
621 | |
} |
622 | 0 | if (message instanceof DefaultMuleMessage) |
623 | |
{ |
624 | 0 | ((DefaultMuleMessage) message).initAfterDeserialisation(muleContext); |
625 | |
} |
626 | 0 | int endpointHashcode = (Integer) serializedData.get("endpointHashcode"); |
627 | 0 | boolean isInboundEndpoint = (Boolean) serializedData.get("isInboundEndpoint"); |
628 | 0 | String endpointBuilderName = (String) serializedData.get("endpointBuilderName"); |
629 | 0 | String endpointUri = (String) serializedData.get("endpointUri"); |
630 | 0 | List<String> transformerNames = (List<String>) serializedData.get("transformers"); |
631 | |
|
632 | |
|
633 | |
|
634 | 0 | endpoint = (ImmutableEndpoint) muleContext.getRegistry().lookupObject( |
635 | |
DefaultEndpointFactory.ENDPOINT_REGISTRY_PREFIX + endpointHashcode); |
636 | |
|
637 | |
|
638 | 0 | if (endpoint == null) |
639 | |
{ |
640 | |
|
641 | |
|
642 | 0 | if ((endpointBuilderName != null) |
643 | |
&& muleContext.getRegistry().lookupEndpointBuilder(endpointBuilderName) != null) |
644 | |
{ |
645 | 0 | if (isInboundEndpoint) |
646 | |
{ |
647 | 0 | endpoint = muleContext.getEndpointFactory().getInboundEndpoint( |
648 | |
endpointBuilderName); |
649 | |
} |
650 | |
else |
651 | |
{ |
652 | 0 | endpoint = muleContext.getEndpointFactory().getOutboundEndpoint( |
653 | |
endpointBuilderName); |
654 | |
} |
655 | |
} |
656 | |
|
657 | |
else |
658 | |
{ |
659 | 0 | List<Transformer> transformers = new LinkedList<Transformer>(); |
660 | 0 | for (String name : transformerNames) |
661 | |
{ |
662 | 0 | Transformer next = muleContext.getRegistry().lookupTransformer(name); |
663 | 0 | if (next == null) |
664 | |
{ |
665 | 0 | throw new IllegalStateException(CoreMessages.objectNotFound(name).toString()); |
666 | |
} |
667 | |
else |
668 | |
{ |
669 | 0 | transformers.add(next); |
670 | |
} |
671 | 0 | } |
672 | 0 | EndpointURI uri = new MuleEndpointURI(endpointUri, muleContext); |
673 | |
|
674 | 0 | TransportServiceDescriptor tsd = (TransportServiceDescriptor) muleContext.getRegistry().lookupServiceDescriptor(ServiceType.TRANSPORT, uri.getFullScheme(), null); |
675 | 0 | EndpointBuilder endpointBuilder = tsd.createEndpointBuilder(endpointUri); |
676 | 0 | endpointBuilder.setTransformers(transformers); |
677 | |
|
678 | 0 | if (isInboundEndpoint) |
679 | |
{ |
680 | 0 | endpoint = muleContext.getEndpointFactory().getInboundEndpoint( |
681 | |
endpointBuilder); |
682 | |
} |
683 | |
else |
684 | |
{ |
685 | 0 | endpoint = muleContext.getEndpointFactory().getOutboundEndpoint( |
686 | |
endpointBuilder); |
687 | |
} |
688 | |
} |
689 | |
} |
690 | |
|
691 | 0 | serializedData = null; |
692 | 0 | } |
693 | |
|
694 | |
|
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
|
700 | |
|
701 | |
|
702 | |
public String getEncoding() |
703 | |
{ |
704 | 0 | String encoding = message.getEncoding(); |
705 | 0 | if (encoding == null) |
706 | |
{ |
707 | 0 | encoding = endpoint.getEncoding(); |
708 | |
} |
709 | |
|
710 | 0 | return encoding; |
711 | |
} |
712 | |
|
713 | |
public MuleContext getMuleContext() |
714 | |
{ |
715 | 0 | return message.getMuleContext(); |
716 | |
} |
717 | |
|
718 | |
public ThreadSafeAccess newThreadCopy() |
719 | |
{ |
720 | 0 | if (message instanceof ThreadSafeAccess) |
721 | |
{ |
722 | 0 | DefaultMuleEvent copy = new DefaultMuleEvent((MuleMessage) ((ThreadSafeAccess) message).newThreadCopy(), this); |
723 | 0 | copy.resetAccessControl(); |
724 | 0 | return copy; |
725 | |
} |
726 | |
else |
727 | |
{ |
728 | 0 | return this; |
729 | |
} |
730 | |
} |
731 | |
|
732 | |
public void resetAccessControl() |
733 | |
{ |
734 | 0 | if (message instanceof ThreadSafeAccess) |
735 | |
{ |
736 | 0 | ((ThreadSafeAccess) message).resetAccessControl(); |
737 | |
} |
738 | 0 | } |
739 | |
|
740 | |
public void assertAccess(boolean write) |
741 | |
{ |
742 | 0 | if (message instanceof ThreadSafeAccess) |
743 | |
{ |
744 | 0 | ((ThreadSafeAccess) message).assertAccess(write); |
745 | |
} |
746 | 0 | } |
747 | |
|
748 | |
@Deprecated |
749 | |
public Object transformMessage() throws TransformerException |
750 | |
{ |
751 | 0 | logger.warn("Deprecation warning: MuleEvent.transformMessage does nothing in Mule 3.x. The message is already transformed before the event reaches a component"); |
752 | 0 | return message.getPayload(); |
753 | |
} |
754 | |
|
755 | |
public ProcessingTime getProcessingTime() |
756 | |
{ |
757 | 0 | return processingTime; |
758 | |
} |
759 | |
|
760 | |
public Object getReplyToDestination() |
761 | |
{ |
762 | 0 | return replyToDestination; |
763 | |
} |
764 | |
|
765 | |
public void captureReplyToDestination() |
766 | |
{ |
767 | 0 | if (message != null) |
768 | |
{ |
769 | 0 | replyToDestination = message.getReplyTo(); |
770 | 0 | message.setReplyTo(null); |
771 | |
} |
772 | 0 | } |
773 | |
|
774 | |
public ReplyToHandler getReplyToHandler() |
775 | |
{ |
776 | 0 | return replyToHanlder; |
777 | |
} |
778 | |
|
779 | |
} |