jstrachan    2002/06/14 03:28:16

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/ant
                        TaskTag.java
  Log:
  Patched to use the MethodUtils method from beanutils rather than the reflection 
methods on Class 
  since throwing an exception when a method is not there is an unnecessary performance 
overhead.
  
  Revision  Changes    Path
  1.9       +8 -11     
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/TaskTag.java
  
  Index: TaskTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/TaskTag.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TaskTag.java      14 Jun 2002 10:24:14 -0000      1.8
  +++ TaskTag.java      14 Jun 2002 10:28:16 -0000      1.9
  @@ -65,6 +65,7 @@
   
   import org.apache.commons.beanutils.ConvertingWrapDynaBean;
   import org.apache.commons.beanutils.DynaBean;
  +import org.apache.commons.beanutils.MethodUtils;
   
   import org.apache.commons.jelly.DynaBeanTagSupport;
   import org.apache.commons.jelly.JellyContext;
  @@ -126,18 +127,14 @@
   
           String text = getBodyText();
   
  -        // if the task has an addText()
  -             try {
  -                     Method method = taskType.getMethod("addText", 
addTaskParamTypes);
  -                     if (method != null) {
  -                             Object[] args = { text };
  -                             method.invoke(task, args);
  -                     }
  +             // if the task has an addText()
  +             Method method = MethodUtils.getAccessibleMethod(
  +            taskType, "addText", addTaskParamTypes
  +        );            
  +             if (method != null) {
  +                     Object[] args = { text };
  +                     method.invoke(task, args);
                }
  -        catch (NoSuchMethodException e) {
  -            // this is hardly an exceptional case unfortunately
  -            // the JDK should just return null!
  -        }
           
           task.perform();   
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to