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