User: squirest
  Date: 02/01/17 17:20:08

  Modified:    src/main/org/jboss/mx/metadata StandardMetaData.java
  Log:
  ugly little interim fixes so that it passes compliance tests - this code will
  show up on radar again when I add the non-compliant-mbean tests
  
  Revision  Changes    Path
  1.4       +54 -46    jmx/src/main/org/jboss/mx/metadata/StandardMetaData.java
  
  Index: StandardMetaData.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/org/jboss/mx/metadata/StandardMetaData.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardMetaData.java     2002/01/12 20:05:51     1.3
  +++ StandardMetaData.java     2002/01/18 01:20:08     1.4
  @@ -1,26 +1,29 @@
   /*
  - * LGPL
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
    */
  -package org.jboss.mx.metadata;
  -
  -import java.util.Map;
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.List;
  -import java.util.ArrayList;
  -import java.lang.reflect.Method;
  -import java.lang.reflect.Constructor;
  -
  -import javax.management.NotCompliantMBeanException;
  -import javax.management.IntrospectionException;
  -import javax.management.MBeanInfo;
  -import javax.management.MBeanAttributeInfo;
  -import javax.management.MBeanOperationInfo;
  -import javax.management.MBeanConstructorInfo;
  -import javax.management.MBeanNotificationInfo;
  -import javax.management.NotificationBroadcaster;
  -
  -import javax.management.modelmbean.ModelMBeanAttributeInfo;
  +package org.jboss.mx.metadata;
  +
  +import java.util.Map;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.ArrayList;
  +import java.lang.reflect.Method;
  +import java.lang.reflect.Constructor;
  +
  +import javax.management.NotCompliantMBeanException;
  +import javax.management.IntrospectionException;
  +import javax.management.MBeanInfo;
  +import javax.management.MBeanAttributeInfo;
  +import javax.management.MBeanOperationInfo;
  +import javax.management.MBeanConstructorInfo;
  +import javax.management.MBeanNotificationInfo;
  +import javax.management.NotificationBroadcaster;
  +
  +import javax.management.modelmbean.ModelMBeanAttributeInfo;
   import javax.management.modelmbean.ModelMBeanOperationInfo;
   import javax.management.modelmbean.ModelMBeanNotificationInfo;
   import javax.management.modelmbean.ModelMBeanConstructorInfo;
  @@ -29,25 +32,29 @@
   
   import org.jboss.mx.server.StandardMBeanInvoker;
   
  +/**
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>.
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Trevor Squires</a>.
  + */
   public class StandardMetaData implements MetaDataBuilder
   {
   
      // Attributes ----------------------------------------------------
      private Object resource = null;
      private boolean isModelMetaData = false;
  -   
  +
      // Constructors --------------------------------------------------
      public StandardMetaData(Object resource)
      {
         this.resource = resource;
      }
   
  -   public StandardMetaData(Object resource, boolean isModelMetaData) 
  +   public StandardMetaData(Object resource, boolean isModelMetaData)
      {
         this(resource);
         this.isModelMetaData = isModelMetaData;
      }
  -   
  +
      // MetaDataBuilder implementation --------------------------------
      public MBeanInfo build() throws NotCompliantMBeanException
      {
  @@ -66,12 +73,13 @@
            {
               String methodName = methods[i].getName();
               Class[] signature = methods[i].getParameterTypes();
  -            
  -            if (methodName.startsWith("set"))
  +            Class returnType = methods[i].getReturnType();
  +
  +            if (methodName.startsWith("set") && signature.length == 1 && returnType 
== Void.TYPE)
                  setters.put(methodName.substring(3, methodName.length()), 
methods[i]);
  -            else if (methodName.startsWith("get") && signature.length == 0)
  +            else if (methodName.startsWith("get") && signature.length == 0 && 
returnType != Void.TYPE)
                  getters.put(methodName.substring(3, methodName.length()), 
methods[i]);
  -            else if (methodName.startsWith("is") && signature.length == 0)
  +            else if (methodName.startsWith("is") && signature.length == 0 && 
(returnType == Boolean.class || returnType == Boolean.TYPE))
                  getters.put(methodName.substring(2, methodName.length()), 
methods[i]);
               else
                  operInfo.add(new MBeanOperationInfo("MBean Operation.", methods[i]));
  @@ -112,28 +120,28 @@
                  (MBeanOperationInfo[])operInfo.toArray(new MBeanOperationInfo[0]),
                  notifInfo
            );
  -         
  +
            if (isModelMetaData)
               return (MBeanInfo)convertMetaDataToModelMetaData(info);
            else
  -            return info; 
  +            return info;
         }
         catch (IntrospectionException e)
  -      {
  +      { e.printStackTrace();
            throw new NotCompliantMBeanException(e.getMessage());
         }
      }
  -   
  +
      // Private -------------------------------------------------------
  -   private ModelMBeanInfo convertMetaDataToModelMetaData(MBeanInfo mi) 
  +   private ModelMBeanInfo convertMetaDataToModelMetaData(MBeanInfo mi)
      {
         MBeanAttributeInfo[] attributes = mi.getAttributes();
  -      ModelMBeanAttributeInfo[] mmbAttributes = new 
ModelMBeanAttributeInfo[attributes.length];   
  -      
  +      ModelMBeanAttributeInfo[] mmbAttributes = new 
ModelMBeanAttributeInfo[attributes.length];
  +
         for (int i = 0; i < attributes.length; ++i)
         {
            mmbAttributes[i] = new ModelMBeanAttributeInfo(
  -               attributes[i].getName(), 
  +               attributes[i].getName(),
                  attributes[i].getType(),
                  attributes[i].getDescription(),
                  attributes[i].isReadable(),
  @@ -141,10 +149,10 @@
                  attributes[i].isIs()
            );
         }
  -      
  +
         MBeanOperationInfo[] operations = mi.getOperations();
         ModelMBeanOperationInfo[] mmbOperations = new 
ModelMBeanOperationInfo[operations.length];
  -      
  +
         for (int i = 0; i < operations.length; ++i)
         {
            mmbOperations[i] = new ModelMBeanOperationInfo(
  @@ -155,10 +163,10 @@
                  operations[i].getImpact()
            );
         }
  -      
  +
         MBeanConstructorInfo[] constructors = mi.getConstructors();
         ModelMBeanConstructorInfo[] mmbConstructors = new 
ModelMBeanConstructorInfo[constructors.length];
  -      
  +
         for (int i = 0; i < constructors.length; ++i)
         {
            mmbConstructors[i] = new ModelMBeanConstructorInfo(
  @@ -167,10 +175,10 @@
                  constructors[i].getSignature()
            );
         }
  -      
  +
         MBeanNotificationInfo[] notifications = mi.getNotifications();
         ModelMBeanNotificationInfo[] mmbNotifications = new 
ModelMBeanNotificationInfo[notifications.length];
  -   
  +
         for (int i = 0; i < notifications.length; ++i)
         {
            mmbNotifications[i] = new ModelMBeanNotificationInfo(
  @@ -178,11 +186,11 @@
                  notifications[i].getName(),
                  notifications[i].getDescription()
            );
  -      }        
  -      
  +      }
  +
         return new ModelMBeanInfoSupport(mi.getClassName(), mi.getDescription(),
  -            mmbAttributes, mmbConstructors, mmbOperations, mmbNotifications); 
  +            mmbAttributes, mmbConstructors, mmbOperations, mmbNotifications);
      }
  -   
  +
   }
   
  
  
  

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

Reply via email to