1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl; |
12 | |
|
13 | |
import org.mule.impl.message.ExceptionPayload; |
14 | |
import org.mule.providers.NullPayload; |
15 | |
import org.mule.umo.UMOMessage; |
16 | |
import org.mule.umo.endpoint.UMOImmutableEndpoint; |
17 | |
import org.mule.util.ObjectUtils; |
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | 2796 | public class DefaultExceptionStrategy extends AbstractExceptionListener |
25 | |
{ |
26 | |
public void handleMessagingException(UMOMessage message, Throwable t) |
27 | |
{ |
28 | 4 | defaultHandler(t); |
29 | 4 | routeException(message, null, t); |
30 | 4 | } |
31 | |
|
32 | |
public void handleRoutingException(UMOMessage message, UMOImmutableEndpoint endpoint, Throwable t) |
33 | |
{ |
34 | 0 | defaultHandler(t); |
35 | 0 | routeException(message, endpoint, t); |
36 | 0 | } |
37 | |
|
38 | |
public void handleLifecycleException(Object component, Throwable t) |
39 | |
{ |
40 | |
|
41 | |
|
42 | 0 | handleStandardException(t); |
43 | 0 | logger.error("The object that failed was: \n" + ObjectUtils.toString(component, "null")); |
44 | 0 | } |
45 | |
|
46 | |
public void handleStandardException(Throwable t) |
47 | |
{ |
48 | 4 | markTransactionForRollback(); |
49 | |
|
50 | 4 | if (RequestContext.getEventContext() != null) |
51 | |
{ |
52 | 4 | handleMessagingException(RequestContext.getEventContext().getMessage(), t); |
53 | |
} |
54 | |
else |
55 | |
{ |
56 | 0 | logger.info("There is no current event available, routing Null message with the exception"); |
57 | 0 | handleMessagingException(new MuleMessage(NullPayload.getInstance()), t); |
58 | |
} |
59 | 4 | } |
60 | |
|
61 | |
protected void defaultHandler(Throwable t) |
62 | |
{ |
63 | 4 | if (RequestContext.getEvent() != null) |
64 | |
{ |
65 | 4 | RequestContext.setExceptionPayload(new ExceptionPayload(t)); |
66 | |
} |
67 | 4 | } |
68 | |
} |