KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > ejb > burlap > SerializedExceptionWrapper


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.ejb.burlap;
30
31 import java.io.PrintStream JavaDoc;
32 import java.io.PrintWriter JavaDoc;
33 import java.rmi.RemoteException JavaDoc;
34
35 public class SerializedExceptionWrapper extends RemoteException JavaDoc {
36   private Throwable JavaDoc cause;
37   private String JavaDoc trace;
38   
39   public SerializedExceptionWrapper() {}
40   
41   public SerializedExceptionWrapper(Throwable JavaDoc cause, String JavaDoc trace)
42   {
43     this.cause = cause;
44     this.trace = trace;
45   }
46
47   public Throwable JavaDoc getRootCause()
48   {
49     return cause;
50   }
51
52   public String JavaDoc getMessage()
53   {
54     return "remote: " + cause.getMessage();
55   }
56
57   public String JavaDoc toString()
58   {
59     return "SerializedExceptionWrapper: " + cause.toString();
60   }
61
62   public void printStackTrace()
63   {
64     if (trace != null) {
65       System.out.print("remote exception: ");
66       System.out.print(trace);
67     }
68     
69     System.out.print("local exception: ");
70     super.printStackTrace();
71   }
72
73   public void printStackTrace(PrintWriter JavaDoc pw)
74   {
75     if (trace != null) {
76       pw.print("remote exception: ");
77       pw.print(trace);
78     }
79     
80     pw.print("local exception: ");
81     super.printStackTrace(pw);
82   }
83
84   public void printStackTrace(PrintStream JavaDoc os)
85   {
86     if (trace != null) {
87       os.print("remote exception: ");
88       os.print(trace);
89     }
90
91     os.print("local exception: ");
92     super.printStackTrace(os);
93   }
94 }
95
Popular Tags