User: user57  
  Date: 02/03/01 17:16:37

  Modified:    src/main/org/jboss/system ServiceConfigurator.java
  Log:
   o deal with those pesk JMX exceptions when setting an attribute
  
  Revision  Changes    Path
  1.3       +36 -5     jboss-system/src/main/org/jboss/system/ServiceConfigurator.java
  
  Index: ServiceConfigurator.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss-system/src/main/org/jboss/system/ServiceConfigurator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceConfigurator.java  1 Mar 2002 05:13:34 -0000       1.2
  +++ ServiceConfigurator.java  2 Mar 2002 01:16:37 -0000       1.3
  @@ -19,6 +19,7 @@
   import java.util.LinkedList;
   import java.util.ArrayList;
   import java.util.Hashtable;
  +
   import javax.management.Attribute;
   import javax.management.InstanceNotFoundException;
   import javax.management.MBeanAttributeInfo;
  @@ -27,6 +28,12 @@
   import javax.management.MalformedObjectNameException;
   import javax.management.ObjectInstance;
   import javax.management.ObjectName;
  +import javax.management.MBeanException;
  +import javax.management.ReflectionException;
  +import javax.management.RuntimeOperationsException;
  +import javax.management.RuntimeMBeanException;
  +import javax.management.RuntimeErrorException;
  +
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
   
  @@ -45,7 +52,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    *
    * <p><b>20010830 marc fleury:</b>
    * <ul>
  @@ -88,6 +95,30 @@
      
      // Public  -------------------------------------------------------
      
  +   /** A helper to deal with those pesky JMX exceptions. */
  +   private void setAttribute(ObjectName name, Attribute attr)
  +      throws Exception
  +   {
  +      try {
  +         server.setAttribute(name, attr);
  +      }
  +      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();
  +      }
  +   }
  +
      /**
      * Builds a string that consists of the configuration elements of
      * the currently running MBeans registered in the server.
  @@ -273,7 +304,7 @@
                        if (debug)
                           log.debug(attributeName + " set to " + value + " in " + 
objectName);
                     
  -                     server.setAttribute(objectName, new Attribute(attributeName, 
value));
  +                     setAttribute(objectName, new Attribute(attributeName, value));
                     
                        break attrfound;
                     }//if name matches
  @@ -312,7 +343,7 @@
               if (mbeanRefName != null) 
               {
                  //if if doesn't exist or has wrong type, we'll get an exception
  -               server.setAttribute(objectName, new Attribute(mbeanRefName, 
dependsObjectName));
  +               setAttribute(objectName, new Attribute(mbeanRefName, 
dependsObjectName));
               } // end of if ()
            }  
            //end of depends
  @@ -350,7 +381,7 @@
               } // end of for ()
               if (dependsListName != null) 
               {
  -               server.setAttribute(objectName, new Attribute(dependsListName, 
dependsListNames));
  +               setAttribute(objectName, new Attribute(dependsListName, 
dependsListNames));
               } // end of if ()
            }//end of depends-list
         }
  @@ -443,7 +474,7 @@
         
         return false;
      }
  -   
  +
      /**
      * Check if the given method is a "setter" method.
      *
  
  
  

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

Reply via email to