1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.routing; |
12 | |
|
13 | |
import org.mule.config.i18n.CoreMessages; |
14 | |
import org.mule.impl.MuleEvent; |
15 | |
import org.mule.impl.MuleMessage; |
16 | |
import org.mule.umo.UMOEvent; |
17 | |
import org.mule.umo.UMOMessage; |
18 | |
import org.mule.umo.UMOSession; |
19 | |
import org.mule.umo.endpoint.UMOEndpoint; |
20 | |
import org.mule.umo.routing.ComponentRoutingException; |
21 | |
import org.mule.umo.routing.RoutingException; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public class ForwardingCatchAllStrategy extends AbstractCatchAllStrategy |
31 | |
{ |
32 | 0 | private boolean sendTransformed = false; |
33 | |
|
34 | |
public UMOMessage catchMessage(UMOMessage message, UMOSession session, boolean synchronous) |
35 | |
throws RoutingException |
36 | |
{ |
37 | 0 | if (getEndpoint() == null) |
38 | |
{ |
39 | 0 | throw new ComponentRoutingException(CoreMessages.noCatchAllEndpointSet(), message, |
40 | |
getEndpoint(), session.getComponent()); |
41 | |
} |
42 | |
try |
43 | |
{ |
44 | 0 | UMOEndpoint endpoint = getEndpoint(); |
45 | |
|
46 | 0 | if (sendTransformed && endpoint.getTransformer() != null) |
47 | |
{ |
48 | 0 | Object payload = message.getPayload(); |
49 | 0 | payload = endpoint.getTransformer().transform(payload); |
50 | 0 | message = new MuleMessage(payload, message); |
51 | |
} |
52 | |
|
53 | 0 | UMOEvent newEvent = new MuleEvent(message, endpoint, session, synchronous); |
54 | |
|
55 | 0 | if (synchronous) |
56 | |
{ |
57 | 0 | UMOMessage result = endpoint.send(newEvent); |
58 | 0 | if (statistics != null) |
59 | |
{ |
60 | 0 | statistics.incrementRoutedMessage(getEndpoint()); |
61 | |
} |
62 | 0 | return result; |
63 | |
} |
64 | |
else |
65 | |
{ |
66 | 0 | endpoint.dispatch(newEvent); |
67 | 0 | if (statistics != null) |
68 | |
{ |
69 | 0 | statistics.incrementRoutedMessage(getEndpoint()); |
70 | |
} |
71 | 0 | return null; |
72 | |
} |
73 | |
} |
74 | 0 | catch (Exception e) |
75 | |
{ |
76 | 0 | throw new RoutingException(message, getEndpoint(), e); |
77 | |
|
78 | |
} |
79 | |
} |
80 | |
|
81 | |
public boolean isSendTransformed() |
82 | |
{ |
83 | 0 | return sendTransformed; |
84 | |
} |
85 | |
|
86 | |
public void setSendTransformed(boolean sendTransformed) |
87 | |
{ |
88 | 0 | this.sendTransformed = sendTransformed; |
89 | 0 | } |
90 | |
} |