1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl; |
12 | |
|
13 | |
import org.mule.MuleException; |
14 | |
import org.mule.MuleManager; |
15 | |
import org.mule.config.MuleProperties; |
16 | |
import org.mule.config.i18n.CoreMessages; |
17 | |
import org.mule.impl.endpoint.MuleEndpoint; |
18 | |
import org.mule.impl.model.ModelHelper; |
19 | |
import org.mule.impl.security.MuleCredentials; |
20 | |
import org.mule.umo.MessagingException; |
21 | |
import org.mule.umo.UMOComponent; |
22 | |
import org.mule.umo.UMOEvent; |
23 | |
import org.mule.umo.UMOException; |
24 | |
import org.mule.umo.UMOMessage; |
25 | |
import org.mule.umo.UMOSession; |
26 | |
import org.mule.umo.endpoint.UMOEndpoint; |
27 | |
import org.mule.umo.endpoint.UMOImmutableEndpoint; |
28 | |
import org.mule.umo.security.UMOCredentials; |
29 | |
import org.mule.umo.transformer.TransformerException; |
30 | |
import org.mule.umo.transformer.UMOTransformer; |
31 | |
import org.mule.util.UUID; |
32 | |
|
33 | |
import java.io.IOException; |
34 | |
import java.io.ObjectInputStream; |
35 | |
import java.io.ObjectOutputStream; |
36 | |
import java.io.OutputStream; |
37 | |
import java.io.Serializable; |
38 | |
import java.io.UnsupportedEncodingException; |
39 | |
import java.util.EventObject; |
40 | |
import java.util.Iterator; |
41 | |
|
42 | |
import org.apache.commons.beanutils.PropertyUtils; |
43 | |
import org.apache.commons.collections.MapUtils; |
44 | |
import org.apache.commons.lang.SerializationUtils; |
45 | |
import org.apache.commons.logging.Log; |
46 | |
import org.apache.commons.logging.LogFactory; |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public class MuleEvent extends EventObject implements UMOEvent, ThreadSafeAccess |
58 | |
{ |
59 | |
|
60 | |
|
61 | |
|
62 | |
private static final long serialVersionUID = 1L; |
63 | |
|
64 | |
|
65 | |
|
66 | 542 | protected transient Log logger = LogFactory.getLog(getClass()); |
67 | |
|
68 | |
|
69 | |
|
70 | 542 | private transient UMOImmutableEndpoint endpoint = null; |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | 542 | private String id = null; |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | 542 | private UMOMessage message = null; |
81 | |
|
82 | |
private UMOSession session; |
83 | |
|
84 | 542 | private boolean stopFurtherProcessing = false; |
85 | |
|
86 | 542 | private boolean synchronous = false; |
87 | |
|
88 | 542 | private int timeout = TIMEOUT_NOT_SET_VALUE; |
89 | |
|
90 | 542 | private transient ResponseOutputStream outputStream = null; |
91 | |
|
92 | 542 | private transient Object transformedMessage = null; |
93 | |
|
94 | 542 | private UMOCredentials credentials = null; |
95 | |
|
96 | 542 | protected String[] ignoredPropertyOverrides = new String[]{MuleProperties.MULE_METHOD_PROPERTY}; |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public MuleEvent(UMOMessage message, |
104 | |
UMOImmutableEndpoint endpoint, |
105 | |
UMOComponent component, |
106 | |
UMOEvent previousEvent) |
107 | |
{ |
108 | 10 | super(message.getPayload()); |
109 | 10 | this.message = message; |
110 | 10 | this.id = generateEventId(); |
111 | 10 | this.session = previousEvent.getSession(); |
112 | 10 | ((MuleSession) session).setComponent(component); |
113 | 10 | this.endpoint = endpoint; |
114 | 10 | this.synchronous = previousEvent.isSynchronous(); |
115 | 10 | this.timeout = previousEvent.getTimeout(); |
116 | 10 | this.outputStream = (ResponseOutputStream) previousEvent.getOutputStream(); |
117 | 10 | fillProperties(previousEvent); |
118 | 10 | } |
119 | |
|
120 | |
public MuleEvent(UMOMessage message, |
121 | |
UMOImmutableEndpoint endpoint, |
122 | |
UMOSession session, |
123 | |
boolean synchronous) |
124 | |
{ |
125 | 306 | this(message, endpoint, session, synchronous, null); |
126 | 306 | } |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public MuleEvent(UMOMessage message, |
137 | |
UMOImmutableEndpoint endpoint, |
138 | |
UMOSession session, |
139 | |
boolean synchronous, |
140 | |
ResponseOutputStream outputStream) |
141 | |
{ |
142 | 316 | super(message.getPayload()); |
143 | 316 | this.message = message; |
144 | 316 | this.endpoint = endpoint; |
145 | 316 | this.session = session; |
146 | 316 | this.id = generateEventId(); |
147 | 316 | this.synchronous = synchronous; |
148 | 316 | this.outputStream = outputStream; |
149 | 316 | fillProperties(null); |
150 | 316 | } |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
public MuleEvent(UMOMessage message, |
161 | |
UMOImmutableEndpoint endpoint, |
162 | |
UMOSession session, |
163 | |
String eventId, |
164 | |
boolean synchronous) |
165 | |
{ |
166 | 0 | super(message.getPayload()); |
167 | 0 | this.message = message; |
168 | 0 | this.endpoint = endpoint; |
169 | 0 | this.session = session; |
170 | 0 | this.id = eventId; |
171 | 0 | this.synchronous = synchronous; |
172 | 0 | fillProperties(null); |
173 | 0 | } |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
public MuleEvent(UMOMessage message, UMOEvent rewriteEvent) |
182 | |
{ |
183 | 216 | super(message.getPayload()); |
184 | 216 | this.message = message; |
185 | 216 | this.id = rewriteEvent.getId(); |
186 | 216 | this.session = rewriteEvent.getSession(); |
187 | 216 | ((MuleSession) session).setComponent(rewriteEvent.getComponent()); |
188 | 216 | this.endpoint = rewriteEvent.getEndpoint(); |
189 | 216 | this.synchronous = rewriteEvent.isSynchronous(); |
190 | 216 | this.timeout = rewriteEvent.getTimeout(); |
191 | 216 | this.outputStream = (ResponseOutputStream) rewriteEvent.getOutputStream(); |
192 | 216 | if (rewriteEvent instanceof MuleEvent) |
193 | |
{ |
194 | 216 | this.transformedMessage = ((MuleEvent) rewriteEvent).getCachedMessage(); |
195 | |
} |
196 | 216 | fillProperties(rewriteEvent); |
197 | 216 | } |
198 | |
|
199 | |
protected void fillProperties(UMOEvent previousEvent) |
200 | |
{ |
201 | 542 | if (previousEvent != null) |
202 | |
{ |
203 | 226 | UMOMessage msg = previousEvent.getMessage(); |
204 | 226 | synchronized (msg) |
205 | |
{ |
206 | 226 | for (Iterator iterator = msg.getPropertyNames().iterator(); iterator.hasNext();) |
207 | |
{ |
208 | 48 | String prop = (String) iterator.next(); |
209 | 48 | Object value = msg.getProperty(prop); |
210 | |
|
211 | 48 | if (!ignoreProperty(prop)) |
212 | |
{ |
213 | 2 | message.setProperty(prop, value); |
214 | |
} |
215 | 48 | } |
216 | 226 | } |
217 | |
} |
218 | |
|
219 | 542 | if (endpoint != null && endpoint.getProperties() != null) |
220 | |
{ |
221 | 542 | for (Iterator iterator = endpoint.getProperties().keySet().iterator(); iterator.hasNext();) |
222 | |
{ |
223 | 2 | String prop = (String) iterator.next(); |
224 | 2 | Object value = endpoint.getProperties().get(prop); |
225 | |
|
226 | 2 | if (!ignoreProperty(prop)) |
227 | |
{ |
228 | 0 | message.setProperty(prop, value); |
229 | |
} |
230 | 2 | } |
231 | |
} |
232 | |
|
233 | 542 | setCredentials(); |
234 | 542 | } |
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
protected boolean ignoreProperty(String key) |
249 | |
{ |
250 | 50 | if (key == null) |
251 | |
{ |
252 | 0 | return true; |
253 | |
} |
254 | |
|
255 | 100 | for (int i = 0; i < ignoredPropertyOverrides.length; i++) |
256 | |
{ |
257 | 50 | if (key.equals(ignoredPropertyOverrides[i])) |
258 | |
{ |
259 | 0 | return false; |
260 | |
} |
261 | |
} |
262 | 50 | Object value = message.getProperty(key); |
263 | |
|
264 | 50 | if (value != null) |
265 | |
{ |
266 | 48 | return true; |
267 | |
} |
268 | |
|
269 | 2 | return false; |
270 | |
} |
271 | |
|
272 | |
protected void setCredentials() |
273 | |
{ |
274 | 542 | if (null != endpoint && null != endpoint.getEndpointURI() && null != endpoint.getEndpointURI().getUserInfo()) |
275 | |
{ |
276 | 2 | final String userName = endpoint.getEndpointURI().getUsername(); |
277 | 2 | final String password = endpoint.getEndpointURI().getPassword(); |
278 | 2 | if (password != null && userName != null) |
279 | |
{ |
280 | 0 | credentials = new MuleCredentials(userName, password.toCharArray()); |
281 | |
} |
282 | |
} |
283 | 542 | } |
284 | |
|
285 | |
public UMOCredentials getCredentials() |
286 | |
{ |
287 | 2 | return credentials; |
288 | |
} |
289 | |
|
290 | |
Object getCachedMessage() |
291 | |
{ |
292 | 216 | return transformedMessage; |
293 | |
} |
294 | |
|
295 | |
public UMOMessage getMessage() |
296 | |
{ |
297 | 620 | return message; |
298 | |
} |
299 | |
|
300 | |
public byte[] getMessageAsBytes() throws MuleException |
301 | |
{ |
302 | |
try |
303 | |
{ |
304 | 2 | return message.getPayloadAsBytes(); |
305 | |
} |
306 | 0 | catch (Exception e) |
307 | |
{ |
308 | 0 | throw new MuleException( |
309 | |
CoreMessages.cannotReadPayloadAsBytes(message.getPayload().getClass().getName()), e); |
310 | |
} |
311 | |
} |
312 | |
|
313 | |
public Object getTransformedMessage() throws TransformerException |
314 | |
{ |
315 | 56 | if (isStreaming()) |
316 | |
{ |
317 | 0 | return message.getAdapter(); |
318 | |
} |
319 | 56 | if (transformedMessage == null) |
320 | |
{ |
321 | 32 | UMOTransformer tran = endpoint.getTransformer(); |
322 | 32 | if (tran != null) |
323 | |
{ |
324 | 6 | transformedMessage = tran.transform(message.getPayload()); |
325 | |
} |
326 | |
else |
327 | |
{ |
328 | 26 | transformedMessage = message.getPayload(); |
329 | |
} |
330 | |
} |
331 | 56 | return transformedMessage; |
332 | |
} |
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
public byte[] getTransformedMessageAsBytes() throws TransformerException |
346 | |
{ |
347 | 4 | Object msg = getTransformedMessage(); |
348 | 4 | if (msg instanceof byte[]) |
349 | |
{ |
350 | 0 | return (byte[]) msg; |
351 | |
} |
352 | 4 | else if (msg instanceof String) |
353 | |
{ |
354 | |
try |
355 | |
{ |
356 | 4 | return msg.toString().getBytes(getEncoding()); |
357 | |
} |
358 | 0 | catch (UnsupportedEncodingException e) |
359 | |
{ |
360 | 0 | throw new TransformerException( |
361 | |
CoreMessages.transformFailedFrom(msg.getClass()), e); |
362 | |
} |
363 | |
} |
364 | 0 | else if (msg instanceof Serializable) |
365 | |
{ |
366 | |
try |
367 | |
{ |
368 | 0 | return SerializationUtils.serialize((Serializable) msg); |
369 | |
} |
370 | 0 | catch (Exception e) |
371 | |
{ |
372 | 0 | throw new TransformerException( |
373 | |
CoreMessages.transformFailed(msg.getClass().getName(), "byte[]"), e); |
374 | |
} |
375 | |
} |
376 | |
else |
377 | |
{ |
378 | 0 | throw new TransformerException( |
379 | |
CoreMessages.transformOnObjectNotOfSpecifiedType(msg.getClass().getName(), |
380 | 0 | "byte[] or " + Serializable.class.getName())); |
381 | |
} |
382 | |
} |
383 | |
|
384 | |
|
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
public String getTransformedMessageAsString() throws TransformerException |
396 | |
{ |
397 | 0 | return getTransformedMessageAsString(getEncoding()); |
398 | |
} |
399 | |
|
400 | |
public String getMessageAsString() throws UMOException |
401 | |
{ |
402 | 34 | return getMessageAsString(getEncoding()); |
403 | |
} |
404 | |
|
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
public String getTransformedMessageAsString(String encoding) throws TransformerException |
418 | |
{ |
419 | |
try |
420 | |
{ |
421 | 0 | return new String(getTransformedMessageAsBytes(), encoding); |
422 | |
} |
423 | 0 | catch (UnsupportedEncodingException e) |
424 | |
{ |
425 | 0 | throw new TransformerException(endpoint.getTransformer(), e); |
426 | |
} |
427 | |
} |
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
public String getMessageAsString(String encoding) throws UMOException |
438 | |
{ |
439 | |
try |
440 | |
{ |
441 | 42 | return message.getPayloadAsString(encoding); |
442 | |
} |
443 | 0 | catch (Exception e) |
444 | |
{ |
445 | 0 | throw new MuleException( |
446 | |
CoreMessages.cannotReadPayloadAsString(message.getClass().getName()), e); |
447 | |
} |
448 | |
} |
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | |
public String getId() |
456 | |
{ |
457 | 226 | return id; |
458 | |
} |
459 | |
|
460 | |
|
461 | |
|
462 | |
|
463 | |
public Object getProperty(String name, boolean exhaustiveSearch) |
464 | |
{ |
465 | 0 | return getProperty(name, null, exhaustiveSearch); |
466 | |
} |
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
public Object getProperty(String name, Object defaultValue, boolean exhaustiveSearch) |
475 | |
{ |
476 | 0 | Object property = message.getProperty(name); |
477 | |
|
478 | 0 | if (exhaustiveSearch) |
479 | |
{ |
480 | |
|
481 | 0 | if (property == null) |
482 | |
{ |
483 | 0 | property = MapUtils.getObject(getEndpoint().getEndpointURI().getParams(), name, null); |
484 | |
} |
485 | |
|
486 | |
|
487 | 0 | if (property == null) |
488 | |
{ |
489 | |
try |
490 | |
{ |
491 | 0 | property = PropertyUtils.getProperty(getEndpoint().getConnector(), name); |
492 | |
} |
493 | 0 | catch (Exception e) |
494 | |
{ |
495 | |
|
496 | |
|
497 | 0 | } |
498 | |
} |
499 | |
} |
500 | 0 | return (property == null ? defaultValue : property); |
501 | |
} |
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
public UMOImmutableEndpoint getEndpoint() |
509 | |
{ |
510 | 352 | return endpoint; |
511 | |
} |
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
|
518 | |
public String toString() |
519 | |
{ |
520 | 0 | StringBuffer buf = new StringBuffer(64); |
521 | 0 | buf.append("Event: ").append(getId()); |
522 | 0 | buf.append(", sync=").append(isSynchronous()); |
523 | 0 | buf.append(", stop processing=").append(isStopFurtherProcessing()); |
524 | 0 | buf.append(", ").append(endpoint); |
525 | |
|
526 | 0 | return buf.toString(); |
527 | |
} |
528 | |
|
529 | |
protected String generateEventId() |
530 | |
{ |
531 | 326 | return UUID.getUUID(); |
532 | |
} |
533 | |
|
534 | |
public UMOSession getSession() |
535 | |
{ |
536 | 360 | return session; |
537 | |
} |
538 | |
|
539 | |
void setSession(UMOSession session) |
540 | |
{ |
541 | 0 | this.session = session; |
542 | 0 | } |
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
public UMOComponent getComponent() |
548 | |
{ |
549 | 232 | return session.getComponent(); |
550 | |
} |
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | |
|
557 | |
public boolean isStopFurtherProcessing() |
558 | |
{ |
559 | 28 | return stopFurtherProcessing; |
560 | |
} |
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
public void setStopFurtherProcessing(boolean stopFurtherProcessing) |
574 | |
{ |
575 | 0 | this.stopFurtherProcessing = stopFurtherProcessing; |
576 | 0 | } |
577 | |
|
578 | |
public boolean equals(Object o) |
579 | |
{ |
580 | 16 | if (this == o) |
581 | |
{ |
582 | 16 | return true; |
583 | |
} |
584 | 0 | if (!(o instanceof MuleEvent)) |
585 | |
{ |
586 | 0 | return false; |
587 | |
} |
588 | |
|
589 | 0 | final MuleEvent event = (MuleEvent)o; |
590 | |
|
591 | 0 | if (message != null ? !message.equals(event.message) : event.message != null) |
592 | |
{ |
593 | 0 | return false; |
594 | |
} |
595 | 0 | return id.equals(event.id); |
596 | |
} |
597 | |
|
598 | |
public int hashCode() |
599 | |
{ |
600 | 0 | return 29 * id.hashCode() + (message != null ? message.hashCode() : 0); |
601 | |
} |
602 | |
|
603 | |
public boolean isSynchronous() |
604 | |
{ |
605 | 262 | return synchronous; |
606 | |
} |
607 | |
|
608 | |
public void setSynchronous(boolean value) |
609 | |
{ |
610 | 10 | synchronous = value; |
611 | 10 | } |
612 | |
|
613 | |
public int getTimeout() |
614 | |
{ |
615 | 226 | if (timeout == TIMEOUT_NOT_SET_VALUE) |
616 | |
{ |
617 | |
|
618 | 214 | timeout = endpoint.getRemoteSyncTimeout(); |
619 | |
} |
620 | 226 | return timeout; |
621 | |
} |
622 | |
|
623 | |
public void setTimeout(int timeout) |
624 | |
{ |
625 | 0 | this.timeout = timeout; |
626 | 0 | } |
627 | |
|
628 | |
|
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
public OutputStream getOutputStream() |
636 | |
{ |
637 | 230 | return outputStream; |
638 | |
} |
639 | |
|
640 | |
private void marshallTransformers(UMOTransformer firstTransformer, ObjectOutputStream out) throws IOException |
641 | |
{ |
642 | 2 | UMOTransformer cursor = firstTransformer; |
643 | |
|
644 | |
|
645 | 2 | int num = 0; |
646 | 6 | while (cursor != null) |
647 | |
{ |
648 | 4 | num++; |
649 | 4 | cursor = cursor.getNextTransformer(); |
650 | |
} |
651 | |
|
652 | |
|
653 | 2 | out.writeInt(num); |
654 | |
|
655 | |
|
656 | 2 | if (num > 0) |
657 | |
{ |
658 | 2 | cursor = firstTransformer; |
659 | 6 | while (cursor != null) |
660 | |
{ |
661 | 4 | out.writeObject(cursor.getName()); |
662 | 4 | cursor = cursor.getNextTransformer(); |
663 | |
} |
664 | |
} |
665 | 2 | } |
666 | |
|
667 | |
private UMOTransformer unmarshallTransformers(ObjectInputStream in) throws IOException, ClassNotFoundException |
668 | |
{ |
669 | 2 | UMOTransformer first = null; |
670 | 2 | int count = in.readInt(); |
671 | |
|
672 | 2 | if (count > 0) |
673 | |
{ |
674 | 2 | String firstName = (String) in.readObject(); |
675 | 2 | first = MuleManager.getInstance().lookupTransformer(firstName); |
676 | |
|
677 | 2 | if (first == null) |
678 | |
{ |
679 | 0 | throw new IllegalStateException(CoreMessages.objectNotFound(firstName).toString()); |
680 | |
} |
681 | |
|
682 | 2 | UMOTransformer cursor = first; |
683 | 4 | while (--count > 0) |
684 | |
{ |
685 | 2 | String nextName = (String)in.readObject(); |
686 | 2 | UMOTransformer next = MuleManager.getInstance().lookupTransformer(nextName); |
687 | 2 | if (next == null) |
688 | |
{ |
689 | 0 | throw new IllegalStateException(CoreMessages.objectNotFound(nextName).toString()); |
690 | |
} |
691 | |
else |
692 | |
{ |
693 | 2 | cursor.setNextTransformer(next); |
694 | 2 | cursor = next; |
695 | |
} |
696 | 2 | } |
697 | |
} |
698 | |
|
699 | 2 | return first; |
700 | |
} |
701 | |
|
702 | |
private void writeObject(ObjectOutputStream out) throws IOException |
703 | |
{ |
704 | 2 | out.defaultWriteObject(); |
705 | 2 | out.writeObject(endpoint.getEndpointURI().toString()); |
706 | 2 | out.writeObject(endpoint.getType()); |
707 | 2 | if ((session.getComponent() == null) || |
708 | |
(session.getComponent().getDescriptor() == null)) |
709 | |
{ |
710 | 2 | out.writeObject(""); |
711 | |
} |
712 | |
else |
713 | |
{ |
714 | 0 | out.writeObject(session.getComponent().getDescriptor().getName()); |
715 | |
} |
716 | 2 | marshallTransformers(endpoint.getTransformer(), out); |
717 | 2 | } |
718 | |
|
719 | |
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException, MessagingException |
720 | |
{ |
721 | 2 | logger = LogFactory.getLog(getClass()); |
722 | 2 | in.defaultReadObject(); |
723 | 2 | String uri = (String) in.readObject(); |
724 | 2 | String type = (String) in.readObject(); |
725 | 2 | String componentName = (String) in.readObject(); |
726 | 2 | if ((componentName.length()!=0) && (session != null)) |
727 | |
{ |
728 | 0 | if (!ModelHelper.isComponentRegistered(componentName)) { |
729 | 0 | throw new MessagingException( |
730 | |
CoreMessages.objectNotRegisteredWithManager("Component '" + componentName + "'"), |
731 | |
message, null); |
732 | |
} |
733 | 0 | ((MuleSession)session).setComponent(ModelHelper.getComponent(componentName)); |
734 | |
} |
735 | 2 | UMOTransformer trans = unmarshallTransformers(in); |
736 | |
try |
737 | |
{ |
738 | 2 | endpoint = MuleEndpoint.getOrCreateEndpointForUri(uri,type); |
739 | |
|
740 | 2 | if (endpoint.getTransformer() == null) |
741 | |
{ |
742 | 2 | ((UMOEndpoint) endpoint).setTransformer(trans); |
743 | |
} |
744 | |
} |
745 | 0 | catch (UMOException e) |
746 | |
{ |
747 | 0 | throw (IOException) new IOException(e.getMessage()).initCause(e); |
748 | 2 | } |
749 | 2 | } |
750 | |
|
751 | |
|
752 | |
|
753 | |
|
754 | |
|
755 | |
|
756 | |
public boolean isStreaming() |
757 | |
{ |
758 | 56 | return endpoint.isStreaming(); |
759 | |
} |
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
public String getEncoding() |
770 | |
{ |
771 | 38 | String encoding = endpoint.getEncoding(); |
772 | 38 | if (encoding == null) |
773 | |
{ |
774 | 38 | encoding = message.getEncoding(); |
775 | |
} |
776 | 38 | if (encoding == null) |
777 | |
{ |
778 | 0 | encoding = MuleManager.getConfiguration().getEncoding(); |
779 | |
} |
780 | 38 | return encoding; |
781 | |
} |
782 | |
|
783 | |
public ThreadSafeAccess newThreadCopy() |
784 | |
{ |
785 | 206 | if (message instanceof ThreadSafeAccess) |
786 | |
{ |
787 | 206 | MuleEvent copy = new MuleEvent((UMOMessage) ((ThreadSafeAccess) message).newThreadCopy(), this); |
788 | 206 | copy.resetAccessControl(); |
789 | 206 | return copy; |
790 | |
} |
791 | |
else |
792 | |
{ |
793 | 0 | return this; |
794 | |
} |
795 | |
} |
796 | |
|
797 | |
public void resetAccessControl() |
798 | |
{ |
799 | 208 | if (message instanceof ThreadSafeAccess) |
800 | |
{ |
801 | 208 | ((ThreadSafeAccess) message).resetAccessControl(); |
802 | |
} |
803 | 208 | } |
804 | |
|
805 | |
public void assertAccess(boolean write) |
806 | |
{ |
807 | 42 | if (message instanceof ThreadSafeAccess) |
808 | |
{ |
809 | 42 | ((ThreadSafeAccess) message).assertAccess(write); |
810 | |
} |
811 | 34 | } |
812 | |
|
813 | |
} |