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 javax.management;
023:
024: /**
025: * Thrown by the MBeanServer when an exception occurs using the
026: * java.lang.reflect package to invoke methods on MBeans.
027: *
028: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
029: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
030: * @version $Revision: 57200 $
031: *
032: * <p><b>Revisions:</b>
033: *
034: * <p><b>20020313 Juha Lindfors:</b>
035: * <ul>
036: * <li> Overriding toString() to print out the root exception </li>
037: * </ul>
038: * <p><b>20020711 Adrian Brock:</b>
039: * <ul>
040: * <li> Serialization </li>
041: * </ul>
042: */
043: public class ReflectionException extends JMException {
044: // Constants -----------------------------------------------------
045:
046: private static final long serialVersionUID = 9170809325636915553L;
047:
048: // Attributes ----------------------------------------------------
049:
050: /**
051: * The wrapped exception.
052: */
053: private Exception exception = null;
054:
055: // Constructors --------------------------------------------------
056:
057: /**
058: * Construct a new ReflectionException from a given exception.
059: *
060: * @param e the exception to wrap.
061: */
062: public ReflectionException(Exception e) {
063: super ();
064: this .exception = e;
065: }
066:
067: /**
068: * Construct a new ReflectionException from a given exception and message.
069: *
070: * @param e the exception to wrap.
071: * @param message the specified message.
072: */
073: public ReflectionException(Exception e, String message) {
074: super (message);
075: this .exception = e;
076: }
077:
078: // Public --------------------------------------------------------
079:
080: /**
081: * Retrieves the wrapped exception.
082: *
083: * @return the wrapped exception.
084: */
085: public Exception getTargetException() {
086: return exception;
087: }
088:
089: /**
090: * Retrieves the wrapped exception.
091: *
092: * @return the wrapped exception.
093: */
094: public Throwable getCause() {
095: return exception;
096: }
097:
098: // JMException overrides -----------------------------------------
099:
100: /**
101: * Returns a string representation of this exception. The returned string
102: * contains this exception name, message and a string representation of the
103: * target exception if it has been set.
104: *
105: * @return string representation of this exception
106: */
107: public String toString() {
108: return "ReflectionException: "
109: + getMessage()
110: + ((exception == null) ? "" : " Cause: "
111: + exception.toString());
112: }
113:
114: }
|