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.MuleMessage;
16 import org.mule.api.MuleSession;
17 import org.mule.api.endpoint.OutboundEndpoint;
18 import org.mule.api.routing.RoutingException;
19 import org.mule.api.routing.ServiceRoutingException;
20 import org.mule.config.i18n.CoreMessages;
21
22
23
24
25
26
27
28
29 public class ForwardingCatchAllStrategy extends AbstractCatchAllStrategy
30 {
31 private boolean sendTransformed = false;
32
33 public MuleMessage catchMessage(MuleMessage message, MuleSession session, boolean synchronous)
34 throws RoutingException
35 {
36 if (getEndpoint() == null)
37 {
38 throw new ServiceRoutingException(CoreMessages.noCatchAllEndpointSet(), message,
39 getEndpoint(), session.getService());
40 }
41 try
42 {
43 OutboundEndpoint endpoint = getEndpoint();
44 if (sendTransformed && endpoint.getTransformers() != null)
45 {
46 message.applyTransformers(endpoint.getTransformers());
47 }
48
49 MuleEvent newEvent = new DefaultMuleEvent(message, endpoint, session, synchronous);
50
51 if (synchronous)
52 {
53 MuleMessage result = endpoint.send(newEvent);
54 if (statistics != null)
55 {
56 statistics.incrementRoutedMessage(getEndpoint());
57 }
58 return result;
59 }
60 else
61 {
62 endpoint.dispatch(newEvent);
63 if (statistics != null)
64 {
65 statistics.incrementRoutedMessage(getEndpoint());
66 }
67 return null;
68 }
69 }
70 catch (Exception e)
71 {
72 throw new RoutingException(message, getEndpoint(), e);
73
74 }
75 }
76
77 public boolean isSendTransformed()
78 {
79 return sendTransformed;
80 }
81
82 public void setSendTransformed(boolean sendTransformed)
83 {
84 this.sendTransformed = sendTransformed;
85 }
86 }