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.RequestContext; |
15 | |
import org.mule.api.MuleEvent; |
16 | |
import org.mule.api.MuleException; |
17 | |
import org.mule.api.MuleMessage; |
18 | |
import org.mule.api.MuleSession; |
19 | |
import org.mule.api.endpoint.OutboundEndpoint; |
20 | |
import org.mule.api.routing.RoutingException; |
21 | |
import org.mule.api.routing.ServiceRoutingException; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | 0 | public class ServiceCatchAllStrategy extends AbstractCatchAllStrategy |
28 | |
{ |
29 | |
public void setEndpoint(OutboundEndpoint endpoint) |
30 | |
{ |
31 | 0 | throw new UnsupportedOperationException("The endpoint cannot be set on this catch all"); |
32 | |
} |
33 | |
|
34 | |
public OutboundEndpoint getEndpoint() |
35 | |
{ |
36 | 0 | return null; |
37 | |
} |
38 | |
|
39 | |
public synchronized MuleMessage catchMessage(MuleMessage message, MuleSession session, boolean synchronous) |
40 | |
throws RoutingException |
41 | |
{ |
42 | 0 | MuleEvent event = RequestContext.getEvent(); |
43 | 0 | logger.debug("Catch all strategy handling event: " + event); |
44 | |
try |
45 | |
{ |
46 | 0 | logger.info("MuleEvent being routed from catch all strategy for endpoint: " + event.getEndpoint()); |
47 | 0 | event = new DefaultMuleEvent(message, event.getEndpoint(), session.getService(), event); |
48 | 0 | if (synchronous) |
49 | |
{ |
50 | 0 | statistics.incrementRoutedMessage(event.getEndpoint()); |
51 | 0 | return session.getService().sendEvent(event); |
52 | |
} |
53 | |
else |
54 | |
{ |
55 | 0 | statistics.incrementRoutedMessage(event.getEndpoint()); |
56 | 0 | session.getService().dispatchEvent(event); |
57 | 0 | return null; |
58 | |
} |
59 | |
} |
60 | 0 | catch (MuleException e) |
61 | |
{ |
62 | 0 | throw new ServiceRoutingException(event.getMessage(), event.getEndpoint(), |
63 | |
session.getService(), e); |
64 | |
} |
65 | |
} |
66 | |
} |