01: /*
02: * $Id: ExceptionMessage.java 10529 2008-01-25 05:58:36Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: * <code>ExceptionMessage</code> is used by the DefaultServiceExceptionStrategy
23: * for wrapping an exception with a message to send via an endpointUri.
24: */
25: public class ExceptionMessage extends BaseMessage {
26: /**
27: * Serial version
28: */
29: private static final long serialVersionUID = -538516243574950621L;
30:
31: private Throwable exception;
32: private String componentName;
33: private EndpointURI endpointUri;
34: private Date timeStamp;
35:
36: public ExceptionMessage(Object message, Throwable exception,
37: String componentName, EndpointURI endpointUri) {
38: super (message);
39: this .exception = exception;
40: timeStamp = new Date();
41: this .componentName = componentName;
42: this .endpointUri = endpointUri;
43:
44: MuleEventContext ctx = RequestContext.getEventContext();
45: if (ctx != null) {
46: MuleMessage msg = ctx.getMessage();
47: for (Iterator iterator = msg.getPropertyNames().iterator(); iterator
48: .hasNext();) {
49: String propertyKey = (String) iterator.next();
50: setProperty(propertyKey, msg.getProperty(propertyKey));
51: }
52: }
53: }
54:
55: public String getComponentName() {
56: return componentName;
57: }
58:
59: public EndpointURI getEndpoint() {
60: return endpointUri;
61: }
62:
63: public Date getTimeStamp() {
64: return timeStamp;
65: }
66:
67: public Throwable getException() {
68: return exception;
69: }
70:
71: public String toString() {
72: return "ExceptionMessage{" + "message=" + message
73: + ", context=" + context + "exception=" + exception
74: + ", componentName='" + componentName + "'"
75: + ", endpointUri=" + endpointUri + ", timeStamp="
76: + timeStamp + "}";
77: }
78: }
|