1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.routing; |
12 | |
|
13 | |
import org.mule.DefaultMuleEvent; |
14 | |
import org.mule.api.MuleEvent; |
15 | |
import org.mule.api.endpoint.OutboundEndpoint; |
16 | |
import org.mule.api.processor.MessageProcessor; |
17 | |
import org.mule.api.routing.RoutingException; |
18 | |
import org.mule.config.i18n.CoreMessages; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | 0 | public class ForwardingCatchAllStrategy extends AbstractCatchAllStrategy |
28 | |
{ |
29 | 0 | private boolean sendTransformed = false; |
30 | |
|
31 | |
protected OutboundEndpoint endpoint; |
32 | |
|
33 | |
public void setEndpoint(OutboundEndpoint endpoint) |
34 | |
{ |
35 | 0 | this.endpoint = endpoint; |
36 | 0 | } |
37 | |
|
38 | |
public void setMessageProcessor(MessageProcessor processor) |
39 | |
{ |
40 | 0 | this.endpoint = (OutboundEndpoint) processor; |
41 | 0 | } |
42 | |
|
43 | |
public OutboundEndpoint getEndpoint() |
44 | |
{ |
45 | 0 | return endpoint; |
46 | |
} |
47 | |
|
48 | |
@Override |
49 | |
public MuleEvent doCatchMessage(MuleEvent event) throws RoutingException |
50 | |
{ |
51 | 0 | if (getEndpoint() == null) |
52 | |
{ |
53 | 0 | throw new RoutingException(CoreMessages.noCatchAllEndpointSet(), event, getEndpoint()); |
54 | |
} |
55 | |
try |
56 | |
{ |
57 | 0 | OutboundEndpoint endpoint = getEndpoint(); |
58 | 0 | if (sendTransformed && endpoint.getTransformers() != null) |
59 | |
{ |
60 | 0 | event.getMessage().applyTransformers(event, endpoint.getTransformers()); |
61 | |
} |
62 | |
|
63 | |
|
64 | |
|
65 | 0 | event = new DefaultMuleEvent(event.getMessage(), endpoint, event.getFlowConstruct(), event); |
66 | 0 | MuleEvent result = endpoint.process(event); |
67 | 0 | if (statistics != null && statistics.isEnabled()) |
68 | |
{ |
69 | 0 | statistics.incrementRoutedMessage(getEndpoint()); |
70 | |
} |
71 | 0 | return result; |
72 | |
} |
73 | 0 | catch (Exception e) |
74 | |
{ |
75 | 0 | throw new RoutingException(event, getEndpoint(), e); |
76 | |
|
77 | |
} |
78 | |
} |
79 | |
|
80 | |
public boolean isSendTransformed() |
81 | |
{ |
82 | 0 | return sendTransformed; |
83 | |
} |
84 | |
|
85 | |
public void setSendTransformed(boolean sendTransformed) |
86 | |
{ |
87 | 0 | this.sendTransformed = sendTransformed; |
88 | 0 | } |
89 | |
} |