KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > resource > connectionmanager > JBossLocalXAException


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.resource.connectionmanager;
23
24 import java.io.PrintStream JavaDoc;
25 import java.io.PrintWriter JavaDoc;
26
27 import javax.transaction.xa.XAException JavaDoc;
28
29 import org.jboss.util.NestedThrowable;
30
31 /**
32  * JBossLocalXAException
33  *
34  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
35  * @author <a HREF="mailto:adrian@jboss.com">Adrian Brock</a>
36  * @version $Revision: 41437 $
37  */

38 public class JBossLocalXAException extends XAException JavaDoc implements NestedThrowable
39 {
40    private static final long serialVersionUID = -6208145503935506281L;
41
42    private final Throwable JavaDoc t;
43
44    public JBossLocalXAException()
45    {
46       super();
47       t = null;
48    }
49
50    public JBossLocalXAException(int errcode)
51    {
52       super(errcode);
53       t = null;
54    }
55
56    public JBossLocalXAException(String JavaDoc message)
57    {
58       super(message);
59       t = null;
60    }
61
62    public JBossLocalXAException(String JavaDoc message, int errorcode)
63    {
64       super(message);
65       this.errorCode = errorcode;
66       t = null;
67    }
68
69    public JBossLocalXAException(String JavaDoc message, Throwable JavaDoc t)
70    {
71       super(message);
72       this.t = t;
73    }
74
75    public JBossLocalXAException(String JavaDoc message, int errorcode, Throwable JavaDoc t)
76    {
77       super(message);
78       this.errorCode = errorcode;
79       this.t = t;
80    }
81
82    // Implementation of org.jboss.util.NestedThrowable
83

84    public Throwable JavaDoc getNested()
85    {
86       return t;
87    }
88
89    public Throwable JavaDoc getCause()
90    {
91       return t;
92    }
93
94    /**
95     * Returns the composite throwable message.
96     *
97     * @return The composite throwable message.
98     */

99    public String JavaDoc getMessage()
100    {
101       return NestedThrowable.Util.getMessage(super.getMessage(), t);
102    }
103
104    /**
105     * Prints the composite message and the embedded stack trace to the
106     * specified print stream.
107     *
108     * @param stream Stream to print to.
109     */

110    public void printStackTrace(final PrintStream JavaDoc stream)
111    {
112       if (t == null || NestedThrowable.PARENT_TRACE_ENABLED)
113          super.printStackTrace(stream);
114       NestedThrowable.Util.print(t, stream);
115    }
116
117    /**
118     * Prints the composite message and the embedded stack trace to the
119     * specified print writer.
120     *
121     * @param writer Writer to print to.
122     */

123    public void printStackTrace(final PrintWriter JavaDoc writer)
124    {
125       if (t == null || NestedThrowable.PARENT_TRACE_ENABLED)
126          super.printStackTrace(writer);
127       NestedThrowable.Util.print(t, writer);
128    }
129
130    /**
131     * Prints the composite message and the embedded stack trace to
132     * <tt>System.err</tt>.
133     */

134    public void printStackTrace()
135    {
136       printStackTrace(System.err);
137    }
138 }
139
Popular Tags