henning 2003/07/10 05:40:45
Modified: src/java/org/apache/turbine/modules ActionEvent.java
src/java/org/apache/turbine/util/velocity
VelocityActionEvent.java
Log:
Some minor optimizations of the reflection call in the ActionEvent Code
Revision Changes Path
1.13 +8 -5
jakarta-turbine-2/src/java/org/apache/turbine/modules/ActionEvent.java
Index: ActionEvent.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/ActionEvent.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ActionEvent.java 10 Jul 2003 12:33:24 -0000 1.12
+++ ActionEvent.java 10 Jul 2003 12:40:45 -0000 1.13
@@ -117,6 +117,10 @@
/** Logging */
protected Log log = LogFactory.getLog(this.getClass());
+ /** Constant needed for Reflection */
+ private static final Class [] methodParams
+ = new Class [] { RunData.class };
+
/**
* You need to implement this in your classes that extend this class.
*
@@ -213,11 +217,10 @@
throw new NoSuchMethodException("ActionEvent: The button was null");
}
- Class[] classes = new Class[]{RunData.class};
- Method method = getClass().getMethod(theButton, classes);
- Object[] args = new Object[]{data};
+ Method method = getClass().getMethod(theButton, methodParams);
+ Object[] methodArgs = new Object[] { data };
- method.invoke(this, args);
+ method.invoke(this, methodArgs);
}
/**
1.13 +10 -14
jakarta-turbine-2/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java
Index: VelocityActionEvent.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- VelocityActionEvent.java 10 Jul 2003 12:33:24 -0000 1.12
+++ VelocityActionEvent.java 10 Jul 2003 12:40:45 -0000 1.13
@@ -87,6 +87,10 @@
*/
public abstract class VelocityActionEvent extends ActionEvent
{
+ /** Constant needed for Reflection */
+ private static final Class [] methodParams
+ = new Class [] { RunData.class, Context.class };
+
/**
* You need to implement this in your classes that extend this
* class.
@@ -157,26 +161,18 @@
try
{
- // The arguments to the method to find.
- Class[] classes = new Class[2];
- classes[0] = RunData.class;
- classes[1] = Context.class;
-
- // The arguments to pass to the method to execute.
- Object[] args = new Object[2];
-
- Method method = getClass().getMethod(theButton, classes);
- args[0] = data;
- args[1] = context;
+ Method method = getClass().getMethod(theButton, methodParams);
+ Object[] methodArgs = new Object[] { data, context };
log.debug("Invoking " + method);
- method.invoke(this, args);
+ method.invoke(this, methodArgs);
}
catch (NoSuchMethodException nsme)
{
// Attempt to execute things the old way..
- log.debug("Couldn't locate the Event ( " + theButton + "), running
executeEvents() in "
+ log.debug("Couldn't locate the Event ( " + theButton
+ + "), running executeEvents() in "
+ super.getClass().getName());
super.executeEvents(data);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]