001 /*
002 * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.rmi.activation;
027
028 /**
029 * General exception used by the activation interfaces.
030 *
031 * <p>As of release 1.4, this exception has been retrofitted to conform to
032 * the general purpose exception-chaining mechanism. The "detail exception"
033 * that may be provided at construction time and accessed via the public
034 * {@link #detail} field is now known as the <i>cause</i>, and may be
035 * accessed via the {@link Throwable#getCause()} method, as well as
036 * the aforementioned "legacy field."
037 *
038 * <p>Invoking the method {@link Throwable#initCause(Throwable)} on an
039 * instance of <code>ActivationException</code> always throws {@link
040 * IllegalStateException}.
041 *
042 * @author Ann Wollrath
043 * @version 1.31, 05/05/07
044 * @since 1.2
045 */
046 public class ActivationException extends Exception {
047
048 /**
049 * The cause of the activation exception.
050 *
051 * <p>This field predates the general-purpose exception chaining facility.
052 * The {@link Throwable#getCause()} method is now the preferred means of
053 * obtaining this information.
054 *
055 * @serial
056 */
057 public Throwable detail;
058
059 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
060 private static final long serialVersionUID = -4320118837291406071L;
061
062 /**
063 * Constructs an <code>ActivationException</code>.
064 */
065 public ActivationException() {
066 initCause(null); // Disallow subsequent initCause
067 }
068
069 /**
070 * Constructs an <code>ActivationException</code> with the specified
071 * detail message.
072 *
073 * @param s the detail message
074 */
075 public ActivationException(String s) {
076 super (s);
077 initCause(null); // Disallow subsequent initCause
078 }
079
080 /**
081 * Constructs an <code>ActivationException</code> with the specified
082 * detail message and cause. This constructor sets the {@link #detail}
083 * field to the specified <code>Throwable</code>.
084 *
085 * @param s the detail message
086 * @param cause the cause
087 */
088 public ActivationException(String s, Throwable cause) {
089 super (s);
090 initCause(null); // Disallow subsequent initCause
091 detail = cause;
092 }
093
094 /**
095 * Returns the detail message, including the message from the cause, if
096 * any, of this exception.
097 *
098 * @return the detail message
099 */
100 public String getMessage() {
101 if (detail == null)
102 return super .getMessage();
103 else
104 return super .getMessage() + "; nested exception is: \n\t"
105 + detail.toString();
106 }
107
108 /**
109 * Returns the cause of this exception. This method returns the value
110 * of the {@link #detail} field.
111 *
112 * @return the cause, which may be <tt>null</tt>.
113 * @since 1.4
114 */
115 public Throwable getCause() {
116 return detail;
117 }
118 }
|