KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > rmi > server > ServerCloneException


1 /*
2  * @(#)ServerCloneException.java 1.20 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.rmi.server;
9
10 /**
11  * A <code>ServerCloneException</code> is thrown if a remote exception occurs
12  * during the cloning of a <code>UnicastRemoteObject</code>.
13  *
14  * <p>As of release 1.4, this exception has been retrofitted to conform to
15  * the general purpose exception-chaining mechanism. The "nested exception"
16  * that may be provided at construction time and accessed via the public
17  * {@link #detail} field is now known as the <i>cause</i>, and may be
18  * accessed via the {@link Throwable#getCause()} method, as well as
19  * the aforementioned "legacy field."
20  *
21  * <p>Invoking the method {@link Throwable#initCause(Throwable)} on an
22  * instance of <code>ServerCloneException</code> always throws {@link
23  * IllegalStateException}.
24  *
25  * @version 1.20, 12/19/03
26  * @author Ann Wollrath
27  * @since JDK1.1
28  * @see java.rmi.server.UnicastRemoteObject#clone()
29  */

30 public class ServerCloneException extends CloneNotSupportedException JavaDoc {
31
32     /**
33      * The cause of the exception.
34      *
35      * <p>This field predates the general-purpose exception chaining facility.
36      * The {@link Throwable#getCause()} method is now the preferred means of
37      * obtaining this information.
38      *
39      * @serial
40      */

41     public Exception JavaDoc detail;
42
43     /* indicate compatibility with JDK 1.1.x version of class */
44     private static final long serialVersionUID = 6617456357664815945L;
45
46     /**
47      * Constructs a <code>ServerCloneException</code> with the specified
48      * detail message.
49      *
50      * @param s the detail message.
51      */

52     public ServerCloneException(String JavaDoc s) {
53     super(s);
54         initCause(null); // Disallow subsequent initCause
55
}
56
57     /**
58      * Constructs a <code>ServerCloneException</code> with the specified
59      * detail message and cause.
60      *
61      * @param s the detail message.
62      * @param cause the cause
63      */

64     public ServerCloneException(String JavaDoc s, Exception JavaDoc cause) {
65     super(s);
66         initCause(null); // Disallow subsequent initCause
67
detail = cause;
68     }
69
70     /**
71      * Returns the detail message, including the message from the cause, if
72      * any, of this exception.
73      *
74      * @return the detail message
75      */

76     public String JavaDoc getMessage() {
77     if (detail == null)
78         return super.getMessage();
79     else
80         return super.getMessage() +
81         "; nested exception is: \n\t" +
82         detail.toString();
83     }
84
85     /**
86      * Returns the cause of this exception. This method returns the value
87      * of the {@link #detail} field.
88      *
89      * @return the cause, which may be <tt>null</tt>.
90      * @since 1.4
91      */

92     public Throwable JavaDoc getCause() {
93         return detail;
94     }
95 }
96
Popular Tags