User: user57  
  Date: 02/03/04 18:59:52

  Modified:    src/main/org/jboss/util/jmx MBeanProxy.java
  Added:       src/main/org/jboss/util/jmx JMXExceptionDecoder.java
  Log:
   o Adding JMXExceptionDecoder to decode/rethrow those pesky JMX exceptions
  
  Revision  Changes    Path
  1.2       +3 -20     jboss-common/src/main/org/jboss/util/jmx/MBeanProxy.java
  
  Index: MBeanProxy.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-common/src/main/org/jboss/util/jmx/MBeanProxy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MBeanProxy.java   15 Feb 2002 06:14:23 -0000      1.1
  +++ MBeanProxy.java   5 Mar 2002 02:59:52 -0000       1.2
  @@ -16,18 +16,13 @@
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
   import javax.management.MalformedObjectNameException;
  -import javax.management.MBeanException;
  -import javax.management.ReflectionException;
  -import javax.management.RuntimeOperationsException;
  -import javax.management.RuntimeMBeanException;
  -import javax.management.RuntimeErrorException;
   
   /**
    * A factory for producing MBean proxies.
    *      
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>.
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class MBeanProxy
      implements InvocationHandler
  @@ -77,20 +72,8 @@
         try {
            return server.invoke(name, method.getName(), args, sig);
         }
  -      catch (MBeanException e) {
  -         throw e.getTargetException();
  -      }
  -      catch (ReflectionException e) {
  -         throw e.getTargetException();
  -      }
  -      catch (RuntimeOperationsException e) {
  -         throw e.getTargetException();
  -      }
  -      catch (RuntimeMBeanException e) {
  -         throw e.getTargetException();
  -      }
  -      catch (RuntimeErrorException e) {
  -         throw e.getTargetError();
  +      catch (Exception e) {
  +         throw JMXExceptionDecoder.decode(e);
         }
      }
   
  
  
  
  1.1                  
jboss-common/src/main/org/jboss/util/jmx/JMXExceptionDecoder.java
  
  Index: JMXExceptionDecoder.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  
  package org.jboss.util.jmx;
  
  import javax.management.MalformedObjectNameException;
  import javax.management.MBeanException;
  import javax.management.ReflectionException;
  import javax.management.RuntimeOperationsException;
  import javax.management.RuntimeMBeanException;
  import javax.management.RuntimeErrorException;
  
  /**
   * A simple helper to rethrow and/or decode those pesky 
   * JMX exceptions.
   *      
   * @author <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
   * @version $Revision: 1.1 $
   */
  public class JMXExceptionDecoder
  {
     /**
      * Attempt to decode the given Throwable.  If it
      * is a container JMX exception, then the target
      * is returned.  Otherwise the argument is returned.
      */
     public static Throwable decode(final Exception e)
     {
        if (e instanceof MBeanException) {
           return ((MBeanException)e).getTargetException();
        }
        if (e instanceof ReflectionException) {
           return ((ReflectionException)e).getTargetException();
        }
        if (e instanceof RuntimeOperationsException) {
           return ((RuntimeOperationsException)e).getTargetException();
        }
        if (e instanceof RuntimeMBeanException) {
           return ((RuntimeMBeanException)e).getTargetException();
        }
        if (e instanceof RuntimeErrorException) {
           return ((RuntimeErrorException)e).getTargetError();
        }
  
        // can't decode
        return e;
     }
  
     /**
      * Decode and rethrow the given Throwable.  If it
      * is a container JMX exception, then the target
      * is thrown.  Otherwise the argument is thrown.
      */
     public static void rethrow(final Exception e)
        throws Exception
     {
        if (e instanceof MBeanException) {
           throw ((MBeanException)e).getTargetException();
        }
        if (e instanceof ReflectionException) {
           throw ((ReflectionException)e).getTargetException();
        }
        if (e instanceof RuntimeOperationsException) {
           throw ((RuntimeOperationsException)e).getTargetException();
        }
        if (e instanceof RuntimeMBeanException) {
           throw ((RuntimeMBeanException)e).getTargetException();
        }
        if (e instanceof RuntimeErrorException) {
           throw ((RuntimeErrorException)e).getTargetError();
        }
  
        // can't decode
        throw e;
     }
  }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to