001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.tm;
023:
024: import java.io.PrintStream;
025: import java.io.PrintWriter;
026: import javax.transaction.RollbackException;
027: import org.jboss.util.NestedThrowable;
028:
029: /**
030: * JBossRollbackException.java
031: *
032: *
033: * Created: Sun Feb 9 22:45:03 2003
034: *
035: * @author <a href="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
036: * @version
037: */
038:
039: public class JBossRollbackException extends RollbackException implements
040: NestedThrowable {
041: static final long serialVersionUID = 2924502280803535350L;
042:
043: Throwable t;
044:
045: public JBossRollbackException() {
046: super ();
047: }
048:
049: public JBossRollbackException(final String message) {
050: super (message);
051: }
052:
053: public JBossRollbackException(final Throwable t) {
054: super ();
055: this .t = t;
056: }
057:
058: public JBossRollbackException(final String message,
059: final Throwable t) {
060: super (message);
061: this .t = t;
062: }
063:
064: // Implementation of org.jboss.util.NestedThrowable
065:
066: public Throwable getNested() {
067: return t;
068: }
069:
070: public Throwable getCause() {
071: return t;
072: }
073:
074: /**
075: * Returns the composite throwable message.
076: *
077: * @return The composite throwable message.
078: */
079: public String getMessage() {
080: return NestedThrowable.Util.getMessage(super .getMessage(), t);
081: }
082:
083: /**
084: * Prints the composite message and the embedded stack trace to the
085: * specified print stream.
086: *
087: * @param stream Stream to print to.
088: */
089: public void printStackTrace(final PrintStream stream) {
090: if (t == null || NestedThrowable.PARENT_TRACE_ENABLED) {
091: super .printStackTrace(stream);
092: }
093: NestedThrowable.Util.print(t, stream);
094: }
095:
096: /**
097: * Prints the composite message and the embedded stack trace to the
098: * specified print writer.
099: *
100: * @param writer Writer to print to.
101: */
102: public void printStackTrace(final PrintWriter writer) {
103: if (t == null || NestedThrowable.PARENT_TRACE_ENABLED) {
104: super .printStackTrace(writer);
105: }
106: NestedThrowable.Util.print(t, writer);
107: }
108:
109: /**
110: * Prints the composite message and the embedded stack trace to
111: * <tt>System.err</tt>.
112: */
113: public void printStackTrace() {
114: printStackTrace(System.err);
115: }
116:
117: }// JBossRollbackException
|