KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tm > JBossRollbackException


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.tm;
23
24 import java.io.PrintStream JavaDoc;
25 import java.io.PrintWriter JavaDoc;
26 import javax.transaction.RollbackException JavaDoc;
27 import org.jboss.util.NestedThrowable;
28
29 /**
30  * JBossRollbackException.java
31  *
32  *
33  * Created: Sun Feb 9 22:45:03 2003
34  *
35  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
36  * @version
37  */

38
39 public class JBossRollbackException
40    extends RollbackException JavaDoc
41    implements NestedThrowable
42 {
43    static final long serialVersionUID = 2924502280803535350L;
44
45    Throwable JavaDoc t;
46
47    public JBossRollbackException()
48    {
49       super();
50    }
51
52    public JBossRollbackException(final String JavaDoc message)
53    {
54       super(message);
55    }
56
57    public JBossRollbackException(final Throwable JavaDoc t)
58    {
59       super();
60       this.t = t;
61    }
62
63    public JBossRollbackException(final String JavaDoc message, final Throwable JavaDoc t)
64    {
65       super(message);
66       this.t = t;
67    }
68
69    // Implementation of org.jboss.util.NestedThrowable
70

71    public Throwable JavaDoc getNested()
72    {
73       return t;
74    }
75
76    public Throwable JavaDoc getCause()
77    {
78       return t;
79    }
80
81    /**
82     * Returns the composite throwable message.
83     *
84     * @return The composite throwable message.
85     */

86    public String JavaDoc getMessage() {
87       return NestedThrowable.Util.getMessage(super.getMessage(), t);
88    }
89
90    /**
91     * Prints the composite message and the embedded stack trace to the
92     * specified print stream.
93     *
94     * @param stream Stream to print to.
95     */

96    public void printStackTrace(final PrintStream JavaDoc stream)
97    {
98       if (t == null || NestedThrowable.PARENT_TRACE_ENABLED)
99       {
100          super.printStackTrace(stream);
101       }
102       NestedThrowable.Util.print(t, stream);
103    }
104
105    /**
106     * Prints the composite message and the embedded stack trace to the
107     * specified print writer.
108     *
109     * @param writer Writer to print to.
110     */

111    public void printStackTrace(final PrintWriter JavaDoc writer)
112    {
113       if (t == null || NestedThrowable.PARENT_TRACE_ENABLED)
114       {
115          super.printStackTrace(writer);
116       }
117       NestedThrowable.Util.print(t, writer);
118    }
119
120    /**
121     * Prints the composite message and the embedded stack trace to
122     * <tt>System.err</tt>.
123     */

124    public void printStackTrace()
125    {
126       printStackTrace(System.err);
127    }
128
129 }// JBossRollbackException
130
Popular Tags