001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: EJBException.java 1100 2006-08-16 13:05:31Z benoitf $
023: * --------------------------------------------------------------------------
024: */package javax.ejb;
025:
026: import java.io.PrintStream;
027: import java.io.PrintWriter;
028:
029: /**
030: * Thrown for unexpected exception.
031: * @see <a href="http://www.jcp.org/en/jsr/detail?id=220">EJB 3.0 specification</a>
032: * @author Florent Benoit
033: */
034: public class EJBException extends RuntimeException {
035:
036: /**
037: * UID for serialization.
038: */
039: private static final long serialVersionUID = 796770993296843510L;
040:
041: /**
042: * Keep the root cause of the exception.
043: */
044: private Exception causeException = null; // name of this field shouldn't be changed for serialization
045:
046: /**
047: * Default constructor : builds an exception with an empty message.
048: */
049: public EJBException() {
050: super ();
051: }
052:
053: /**
054: * Builds an exception with a given exception.
055: * @param causedByException the cause of this exception.
056: */
057: public EJBException(final Exception causedByException) {
058: super (causedByException);
059: this .causeException = causedByException;
060: }
061:
062: /**
063: * Builds an exception with a given message.
064: * @param message the message of this exception.
065: */
066: public EJBException(final String message) {
067: super (message);
068: }
069:
070: /**
071: * Builds an exception with a given message and given exception.
072: * @param message the message of this exception.
073: * @param causedByException the cause of this exception.
074: */
075: public EJBException(final String message,
076: final Exception causedByException) {
077: super (message, causedByException);
078: this .causeException = causedByException;
079: }
080:
081: /**
082: * @return the cause of this exception.
083: */
084: public Exception getCausedByException() {
085: return causeException;
086: }
087:
088: /**
089: * @return the message of this exception.
090: */
091: @Override
092: public String getMessage() {
093: return super .getMessage();
094: }
095:
096: /**
097: * Prints the stack trace on the default stream (System.err).
098: */
099: @Override
100: public void printStackTrace() {
101: super .printStackTrace();
102: }
103:
104: /**
105: * Print the stack trace on the given stream.
106: * @param printStream the given stream.
107: */
108: @Override
109: public void printStackTrace(final PrintStream printStream) {
110: super .printStackTrace(printStream);
111: }
112:
113: /**
114: * Print the stack trace on the given writer.
115: * @param printWriter the given writer.
116: */
117: @Override
118: public void printStackTrace(final PrintWriter printWriter) {
119: super.printStackTrace(printWriter);
120: }
121:
122: }
|