KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > message > ExceptionMessage


1 /*
2  * $Id: ExceptionMessage.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.impl.message;
12
13 import org.mule.impl.RequestContext;
14 import org.mule.umo.UMOEventContext;
15 import org.mule.umo.UMOMessage;
16 import org.mule.umo.endpoint.UMOEndpointURI;
17
18 import java.util.Date JavaDoc;
19 import java.util.Iterator JavaDoc;
20
21 /**
22  * <code>ExceptionMessage</code> is used by the DefaultComponentExceptionStrategy
23  * for wrapping an exception with a message to send via an endpointUri.
24  *
25  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
26  * @version $Revision: 3798 $
27  */

28 public class ExceptionMessage extends BaseMessage
29 {
30     /**
31      * Serial version
32      */

33     private static final long serialVersionUID = -538516243574950621L;
34
35     private Throwable JavaDoc exception;
36     private String JavaDoc componentName;
37     private UMOEndpointURI endpointUri;
38     private Date JavaDoc timeStamp;
39
40     public ExceptionMessage(Object JavaDoc message,
41                             Throwable JavaDoc exception,
42                             String JavaDoc componentName,
43                             UMOEndpointURI endpointUri)
44     {
45         super(message);
46         this.exception = exception;
47         timeStamp = new Date JavaDoc();
48         this.componentName = componentName;
49         this.endpointUri = endpointUri;
50
51         UMOEventContext ctx = RequestContext.getEventContext();
52         if (ctx != null)
53         {
54             UMOMessage msg = ctx.getMessage();
55             for (Iterator JavaDoc iterator = msg.getPropertyNames().iterator(); iterator.hasNext();)
56             {
57                 String JavaDoc propertyKey = (String JavaDoc)iterator.next();
58                 setProperty(propertyKey, msg.getProperty(propertyKey));
59             }
60         }
61     }
62
63     public String JavaDoc getComponentName()
64     {
65         return componentName;
66     }
67
68     public UMOEndpointURI getEndpoint()
69     {
70         return endpointUri;
71     }
72
73     public Date JavaDoc getTimeStamp()
74     {
75         return timeStamp;
76     }
77
78     public Throwable JavaDoc getException()
79     {
80         return exception;
81     }
82
83     public String JavaDoc toString()
84     {
85         return "ExceptionMessage{" + "message=" + message + ", context=" + context + "exception=" + exception
86                + ", componentName='" + componentName + "'" + ", endpointUri=" + endpointUri + ", timeStamp="
87                + timeStamp + "}";
88     }
89 }
90
Popular Tags