You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ch...@apache.org on 2003/11/17 01:46:39 UTC

cvs commit: incubator-geronimo/modules/common/src/java/org/apache/geronimo/common Classes.java

chirino     2003/11/16 16:46:39

  Modified:    modules/common/src/java/org/apache/geronimo/common
                        Classes.java
  Log:
  Added some helper reflection methods.
  
  Revision  Changes    Path
  1.8       +22 -1     incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/Classes.java
  
  Index: Classes.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/Classes.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Classes.java	27 Sep 2003 20:18:37 -0000	1.7
  +++ Classes.java	17 Nov 2003 00:46:39 -0000	1.8
  @@ -462,5 +462,26 @@
           type = loadClass(typeName, cl);
           return getValue(type, value, baseURI);
       }
  +    
  +    static public Method getMethod(Class source, String name) {
  +        Method[] methods = source.getMethods();
  +        for (int i = 0; i < methods.length; i++) {
  +            Method method = methods[i];
  +            if( method.getName().equals(name) )
  +                return method;
  +        }
  +        throw new RuntimeException("Method name not found: "+name+", in class: "+source.getName());
  +    }
  +
  +    static public Method getMethod(Class source, String name, Class args[] ) {
  +        try {
  +            return  source.getMethod(name, args);
  +        } catch (SecurityException e) {
  +            throw new RuntimeException("Method could not be found.", e);
  +        } catch (NoSuchMethodException e) {
  +            throw new RuntimeException("Method could not be found.", e);
  +        }
  +    }
  +    
   }