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.resource.connectionmanager;
023:
024: import java.io.PrintStream;
025: import java.io.PrintWriter;
026:
027: import javax.transaction.xa.XAException;
028:
029: import org.jboss.util.NestedThrowable;
030:
031: /**
032: * JBossLocalXAException
033: *
034: * @author <a href="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
035: * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
036: * @version $Revision: 57189 $
037: */
038: public class JBossLocalXAException extends XAException implements
039: NestedThrowable {
040: private static final long serialVersionUID = -6208145503935506281L;
041:
042: private final Throwable t;
043:
044: public JBossLocalXAException() {
045: super ();
046: t = null;
047: }
048:
049: public JBossLocalXAException(int errcode) {
050: super (errcode);
051: t = null;
052: }
053:
054: public JBossLocalXAException(String message) {
055: super (message);
056: t = null;
057: }
058:
059: public JBossLocalXAException(String message, int errorcode) {
060: super (message);
061: this .errorCode = errorcode;
062: t = null;
063: }
064:
065: public JBossLocalXAException(String message, Throwable t) {
066: super (message);
067: this .t = t;
068: }
069:
070: public JBossLocalXAException(String message, int errorcode,
071: Throwable t) {
072: super (message);
073: this .errorCode = errorcode;
074: this .t = t;
075: }
076:
077: // Implementation of org.jboss.util.NestedThrowable
078:
079: public Throwable getNested() {
080: return t;
081: }
082:
083: public Throwable getCause() {
084: return t;
085: }
086:
087: /**
088: * Returns the composite throwable message.
089: *
090: * @return The composite throwable message.
091: */
092: public String getMessage() {
093: return NestedThrowable.Util.getMessage(super .getMessage(), t);
094: }
095:
096: /**
097: * Prints the composite message and the embedded stack trace to the
098: * specified print stream.
099: *
100: * @param stream Stream to print to.
101: */
102: public void printStackTrace(final PrintStream stream) {
103: if (t == null || NestedThrowable.PARENT_TRACE_ENABLED)
104: super .printStackTrace(stream);
105: NestedThrowable.Util.print(t, stream);
106: }
107:
108: /**
109: * Prints the composite message and the embedded stack trace to the
110: * specified print writer.
111: *
112: * @param writer Writer to print to.
113: */
114: public void printStackTrace(final PrintWriter writer) {
115: if (t == null || NestedThrowable.PARENT_TRACE_ENABLED)
116: super .printStackTrace(writer);
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: printStackTrace(System.err);
126: }
127: }
|