1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.message; |
12 | |
|
13 | |
import org.mule.RequestContext; |
14 | |
import org.mule.api.MuleEventContext; |
15 | |
import org.mule.api.MuleMessage; |
16 | |
import org.mule.api.endpoint.EndpointURI; |
17 | |
|
18 | |
import java.util.Date; |
19 | |
import java.util.Iterator; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public class ExceptionMessage extends BaseMessage |
26 | |
{ |
27 | |
|
28 | |
|
29 | |
|
30 | |
private static final long serialVersionUID = -538516243574950621L; |
31 | |
|
32 | |
private Throwable exception; |
33 | |
private String componentName; |
34 | |
private EndpointURI endpointUri; |
35 | |
private Date timeStamp; |
36 | |
|
37 | |
public ExceptionMessage(Object message, |
38 | |
Throwable exception, |
39 | |
String componentName, |
40 | |
EndpointURI endpointUri) |
41 | |
{ |
42 | 0 | super(message); |
43 | 0 | this.exception = exception; |
44 | 0 | timeStamp = new Date(); |
45 | 0 | this.componentName = componentName; |
46 | 0 | this.endpointUri = endpointUri; |
47 | |
|
48 | 0 | MuleEventContext ctx = RequestContext.getEventContext(); |
49 | 0 | if (ctx != null) |
50 | |
{ |
51 | 0 | MuleMessage msg = ctx.getMessage(); |
52 | 0 | for (Iterator iterator = msg.getPropertyNames().iterator(); iterator.hasNext();) |
53 | |
{ |
54 | 0 | String propertyKey = (String) iterator.next(); |
55 | 0 | setProperty(propertyKey, msg.getProperty(propertyKey)); |
56 | 0 | } |
57 | |
} |
58 | 0 | } |
59 | |
|
60 | |
public String getComponentName() |
61 | |
{ |
62 | 0 | return componentName; |
63 | |
} |
64 | |
|
65 | |
public EndpointURI getEndpoint() |
66 | |
{ |
67 | 0 | return endpointUri; |
68 | |
} |
69 | |
|
70 | |
public Date getTimeStamp() |
71 | |
{ |
72 | 0 | return timeStamp; |
73 | |
} |
74 | |
|
75 | |
public Throwable getException() |
76 | |
{ |
77 | 0 | return exception; |
78 | |
} |
79 | |
|
80 | |
public String toString() |
81 | |
{ |
82 | 0 | return "ExceptionMessage{" + "message=" + message + ", context=" + context + "exception=" + exception |
83 | |
+ ", componentName='" + componentName + "'" + ", endpointUri=" + endpointUri + ", timeStamp=" |
84 | |
+ timeStamp + "}"; |
85 | |
} |
86 | |
} |