01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management;
10:
11: import java.io.PrintStream;
12: import java.io.PrintWriter;
13:
14: /**
15: * Thrown when a RuntimeException is thrown by the MBeanServer when executing MBeanServer methods.
16: *
17: * @version $Revision: 1.9 $
18: */
19: public class RuntimeOperationsException extends JMRuntimeException {
20: private static final long serialVersionUID = -8408923047489133588L;
21:
22: /**
23: * @serial The nested RuntimeException
24: */
25: private RuntimeException runtimeException;
26:
27: /**
28: * Creates a new RuntimeOperationsException
29: *
30: * @param x The nested RuntimeException
31: */
32: public RuntimeOperationsException(RuntimeException x) {
33: this .runtimeException = x;
34: }
35:
36: /**
37: * Creates a new RuntimeOperationsException
38: *
39: * @param x The nested RuntimeException
40: * @param message The message
41: */
42: public RuntimeOperationsException(RuntimeException x, String message) {
43: super (message);
44: this .runtimeException = x;
45: }
46:
47: /**
48: * Returns the nested RuntimeException
49: */
50: public RuntimeException getTargetException() {
51: return runtimeException;
52: }
53:
54: /**
55: * Returns the nested RuntimeException
56: */
57: public Throwable getCause() {
58: return getTargetException();
59: }
60:
61: public String getMessage() {
62: return super .getMessage() + " nested runtime exception is "
63: + runtimeException;
64: }
65:
66: public void printStackTrace() {
67: if (runtimeException == null) {
68: super .printStackTrace();
69: } else {
70: synchronized (System.err) {
71: System.err.println(this );
72: runtimeException.printStackTrace();
73: }
74: }
75: }
76:
77: public void printStackTrace(PrintStream s) {
78: if (runtimeException == null) {
79: super .printStackTrace(s);
80: } else {
81: synchronized (s) {
82: s.println(this );
83: runtimeException.printStackTrace(s);
84: }
85: }
86: }
87:
88: public void printStackTrace(PrintWriter w) {
89: if (runtimeException == null) {
90: super.printStackTrace(w);
91: } else {
92: synchronized (w) {
93: w.println(this);
94: runtimeException.printStackTrace(w);
95: }
96: }
97: }
98: }
|