You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2003/11/06 20:59:15 UTC

cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service GeronimoAttributeInfo.java GeronimoOperationInfo.java

dain        2003/11/06 11:59:15

  Modified:    modules/kernel/src/java/org/apache/geronimo/kernel/service
                        GeronimoAttributeInfo.java
                        GeronimoOperationInfo.java
  Log:
  Changed java.lang.reflect.Method to cglib FastMethod.
  
  Revision  Changes    Path
  1.4       +46 -23    incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service/GeronimoAttributeInfo.java
  
  Index: GeronimoAttributeInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service/GeronimoAttributeInfo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GeronimoAttributeInfo.java	27 Oct 2003 21:34:28 -0000	1.3
  +++ GeronimoAttributeInfo.java	6 Nov 2003 19:59:15 -0000	1.4
  @@ -58,7 +58,8 @@
   import java.lang.reflect.Method;
   import javax.management.MBeanAttributeInfo;
   
  -import net.sf.cglib.MethodProxy;
  +import net.sf.cglib.reflect.FastMethod;
  +import net.sf.cglib.reflect.FastClass;
   
   /**
    * Describes an attibute of a GeronimoMBean.  This extension allows the properties to be mutable during setup,
  @@ -145,31 +146,51 @@
        * The method that will be called to get the attribute value.  If null, the cached value will
        * be returned.
        */
  -    final MethodProxy getterProxy;
  +    final FastMethod getterMethod;
   
       /**
        * The method that will be called to set the attribute value.  If null, the value will only be
        * set into the cache.
        */
  -    final MethodProxy setterProxy;
  +    final FastMethod setterMethod;
   
       /**
        * Time stamp from when the value field was last updated.
        */
       long lastUpdate;
  +
  +    /**
  +     * The hash code for this instance.  We are using identiy for the hash.
  +     */
       private final int hashCode = System.identityHashCode(this);
   
       /**
        * Creates an empty mutable GeronimoAttributeInfo.
        */
       public GeronimoAttributeInfo() {
  +        this(null);
  +    }
  +
  +    /**
  +     * Creates a mutable GeronimoAttributeInfo with the specified name
  +     */
  +    public GeronimoAttributeInfo(String name) {
  +        this(name, true, true);
  +    }
  +
  +    public GeronimoAttributeInfo(String name, boolean readable, boolean writable) {
           super("Ignore", "Ignore", null, true, true, false);
  +        this.name = name;
  +        this.readable = readable;
  +        this.writable = writable;
  +
           immutable = false;
  -        getterProxy = null;
  -        setterProxy = null;
  +        getterMethod = null;
  +        setterMethod = null;
           type = null;
       }
   
  +
       /**
        * Creates an immutable copy of the source GeronimoAttributeInfo.
        * @param source the source GeronimoAttributeInfo to copy
  @@ -203,9 +224,10 @@
           // Optional (derived)
           //
           if (source.target != null) {
  -            target = source.target;
               targetName = source.targetName;
  +            target = source.target;
           } else if (source.targetName == null) {
  +            targetName = GeronimoMBeanInfo.DEFAULT_TARGET_NAME;
               target = parent.getTarget();
           } else {
               targetName = source.targetName;
  @@ -218,7 +240,7 @@
           Method[] methods = target.getClass().getMethods();
           Class attributeType = null;
           if (readable) {
  -            Method getterMethod = null;
  +            Method getterJavaMethod = null;
               if (source.getterName == null) {
                   String getterName = "get" + name;
                   String isName = "is" + name;
  @@ -227,44 +249,44 @@
                       if (method.getParameterTypes().length == 0 &&
                               (getterName.equalsIgnoreCase(method.getName()) ||
                               isName.equalsIgnoreCase(method.getName()))) {
  -                        getterMethod = method;
  +                        getterJavaMethod = method;
                           break;
                       }
                   }
               } else {
                   try {
                       String methodName = source.getterName;
  -                    getterMethod = target.getClass().getMethod(methodName, null);
  +                    getterJavaMethod = target.getClass().getMethod(methodName, null);
                   } catch (Exception e) {
                       // we will throw the formatted exception below
                   }
               }
   
  -            if (getterMethod == null) {
  +            if (getterJavaMethod == null) {
                   throw new IllegalArgumentException("Getter method not found on target:" +
                           " name=" + name +
                           " targetClass=" + target.getClass().getName());
               }
   
  -            getterName = getterMethod.getName();
  +            getterName = getterJavaMethod.getName();
               is = getterName.startsWith("is");
  -            getterProxy = MethodProxy.create(getterMethod, getterMethod);
  -            attributeType = getterMethod.getReturnType();
  +            getterMethod = parent.getTargetFastClass(targetName).getMethod(getterJavaMethod);
  +            attributeType = getterJavaMethod.getReturnType();
           } else {
               getterName = null;
               readable = false;
  -            getterProxy = null;
  +            getterMethod = null;
           }
   
           if (writable) {
  -            Method setterMethod = null;
  +            Method setterJavaMethod = null;
               String methodName = null;
               if (source.setterName == null) {
                   methodName = "set" + name;
                   for (int i = 0; i < methods.length; i++) {
                       Method method = methods[i];
                       if (method.getParameterTypes().length == 1 && methodName.equalsIgnoreCase(method.getName())) {
  -                        setterMethod = method;
  +                        setterJavaMethod = method;
                           break;
                       }
                   }
  @@ -274,24 +296,25 @@
                   for (int i = 0; i < methods.length; i++) {
                       Method method = methods[i];
                       if (method.getParameterTypes().length == 1 && methodName.equals(method.getName())) {
  -                        setterMethod = method;
  +                        setterJavaMethod = method;
                           break;
                       }
                   }
               }
   
  -            if (setterMethod == null) {
  +            if (setterJavaMethod == null) {
                   throw new IllegalArgumentException("Setter method not found on target:" +
                           " setterName=" + methodName +
                           " targetClass=" + target.getClass().getName());
               }
   
  -            setterName = setterMethod.getName();
  -            setterProxy = MethodProxy.create(setterMethod, setterMethod);
  -            attributeType = setterMethod.getParameterTypes()[0];
  +            setterName = setterJavaMethod.getName();
  +
  +            setterMethod = parent.getTargetFastClass(targetName).getMethod(setterJavaMethod);
  +            attributeType = setterJavaMethod.getParameterTypes()[0];
           } else {
               setterName = null;
  -            setterProxy = null;
  +            setterMethod = null;
           }
           type = attributeType.getName();
       }
  
  
  
  1.3       +20 -9     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service/GeronimoOperationInfo.java
  
  Index: GeronimoOperationInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service/GeronimoOperationInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GeronimoOperationInfo.java	24 Oct 2003 22:45:01 -0000	1.2
  +++ GeronimoOperationInfo.java	6 Nov 2003 19:59:15 -0000	1.3
  @@ -64,7 +64,8 @@
   
   import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
   
  -import net.sf.cglib.MethodProxy;
  +import net.sf.cglib.reflect.FastMethod;
  +import net.sf.cglib.reflect.FastClass;
   
   /**
    * Describes an operation on a GeronimoMBean.  This extension allows the properties to be mutable during setup,
  @@ -138,7 +139,7 @@
       /**
        * The method that will be called on the target.
        */
  -    final MethodProxy methodProxy;
  +    final FastMethod method;
   
       /**
        * The cached result of the method.
  @@ -154,7 +155,16 @@
       public GeronimoOperationInfo() {
           super("Ignore", null, null, "Ignore", MBeanOperationInfo.UNKNOWN);
           immutable = false;
  -        methodProxy = null;
  +        method = null;
  +        returnType = null;
  +        parameterTypes = null;
  +    }
  +
  +    public GeronimoOperationInfo(String name) {
  +        super("Ignore", null, null, "Ignore", MBeanOperationInfo.UNKNOWN);
  +        this.name = name;
  +        immutable = false;
  +        method = null;
           returnType = null;
           parameterTypes = null;
       }
  @@ -183,9 +193,10 @@
           // Optional (derived)
           //
           if (source.target != null) {
  -            target = source.target;
               targetName = source.targetName;
  +            target = source.target;
           } else if (source.targetName == null) {
  +            targetName = GeronimoMBeanInfo.DEFAULT_TARGET_NAME;
               target = parent.getTarget();
           } else {
               targetName = source.targetName;
  @@ -211,9 +222,9 @@
           //
           // Derived
           //
  -        Method method = null;
  +        Method javaMethod = null;
           try {
  -            method = target.getClass().getMethod(targetMethodName, types);
  +            javaMethod = target.getClass().getMethod(targetMethodName, types);
           } catch (NoSuchMethodException e) {
               throw new IllegalArgumentException("Target does not have specifed method:" +
                       " target=" + target +
  @@ -221,8 +232,8 @@
           } catch (SecurityException e) {
               e.printStackTrace();  //To change body of catch statement use Options | File Templates.
           }
  -        returnType = method.getReturnType().getName();
  -        methodProxy = MethodProxy.create(method, method);
  +        returnType = javaMethod.getReturnType().getName();
  +        method = parent.getTargetFastClass(targetName).getMethod(javaMethod);
       }
   
       public String getName() {