1
2
3
4
5
6
7
8
9
10
11 package org.mule.routing;
12
13 import org.mule.impl.MuleEvent;
14 import org.mule.impl.RequestContext;
15 import org.mule.umo.UMOEvent;
16 import org.mule.umo.UMOException;
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 public class ComponentCatchAllStrategy extends AbstractCatchAllStrategy
28 {
29 public void setEndpoint(UMOEndpoint endpoint)
30 {
31 throw new UnsupportedOperationException("The endpoint cannot be set on this catch all");
32 }
33
34 public UMOEndpoint getEndpoint()
35 {
36 return null;
37 }
38
39 public synchronized UMOMessage catchMessage(UMOMessage message, UMOSession session, boolean synchronous)
40 throws RoutingException
41 {
42 UMOEvent event = RequestContext.getEvent();
43 try
44 {
45 event = new MuleEvent(message, event.getEndpoint(), session.getComponent(), event);
46 if (synchronous)
47 {
48 statistics.incrementRoutedMessage(event.getEndpoint());
49 logger.info("Event being routed from catch all strategy for endpoint: "
50 + RequestContext.getEvent().getEndpoint());
51 return session.getComponent().sendEvent(event);
52 }
53 else
54 {
55 statistics.incrementRoutedMessage(event.getEndpoint());
56 session.getComponent().dispatchEvent(event);
57 return null;
58 }
59 }
60 catch (UMOException e)
61 {
62 throw new ComponentRoutingException(event.getMessage(), event.getEndpoint(),
63 session.getComponent(), e);
64 }
65 }
66 }