jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1338954 - in /jmeter/trunk/src/core/org/apache/jmeter: engine/util/CompoundVariable.java functions/gui/FunctionHelper.java
Date Tue, 15 May 2012 23:55:55 GMT
Author: sebb
Date: Tue May 15 23:55:54 2012
New Revision: 1338954

URL: http://svn.apache.org/viewvc?rev=1338954&view=rev
Log:
Bug 53226 - Faster startup
FunctionHelper can use function list created by CompoundVariable

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java
    jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java?rev=1338954&r1=1338953&r2=1338954&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java Tue May 15 23:55:54
2012
@@ -198,6 +198,16 @@ public class CompoundVariable implements
         return new SimpleVariable(functionName);
     }
 
+    // For use by FunctionHelper
+    public static Class<? extends Function> getFunctionClass(String className) {
+        return functions.get(className);
+    }
+
+    // For use by FunctionHelper
+    public static String[] getFunctionNames() {
+        return functions.keySet().toArray(new String[functions.size()]);
+    }
+
     public boolean hasFunction() {
         return hasFunction;
     }

Modified: jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java?rev=1338954&r1=1338953&r2=1338954&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java Tue May 15 23:55:54
2012
@@ -22,11 +22,7 @@ import java.awt.BorderLayout;
 import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.io.IOException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-
 import javax.swing.JButton;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
@@ -37,6 +33,7 @@ import javax.swing.event.ChangeListener;
 import org.apache.jmeter.config.Argument;
 import org.apache.jmeter.config.Arguments;
 import org.apache.jmeter.config.gui.ArgumentsPanel;
+import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.functions.Function;
 import org.apache.jmeter.gui.action.ActionRouter;
 import org.apache.jmeter.gui.action.Help;
@@ -47,7 +44,6 @@ import org.apache.jmeter.util.LocaleChan
 import org.apache.jorphan.gui.ComponentUtil;
 import org.apache.jorphan.gui.JLabeledChoice;
 import org.apache.jorphan.gui.JLabeledTextField;
-import org.apache.jorphan.reflect.ClassFinder;
 
 public class FunctionHelper extends JDialog implements ActionListener, ChangeListener, LocaleChangeListener
{
     private static final long serialVersionUID = 240L;
@@ -58,9 +54,6 @@ public class FunctionHelper extends JDia
 
     private JLabeledTextField cutPasteFunction;
 
-    // Not modified after initial setup
-    private final Map<String, Class<?>> functionMap = new HashMap<String,
Class<?>>();
-
     private JButton generateButton;
 
     public FunctionHelper() {
@@ -92,30 +85,14 @@ public class FunctionHelper extends JDia
     }
 
     private void initializeFunctionList() {
-        try {
-            List<String> functionClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(),
-                    new Class[] { Function.class }, true);
-            String[] functionNames = new String[functionClasses.size()];
-            int count = 0;
-            for (String clazz : functionClasses) {
-                Class<?> cl = Class.forName(clazz);
-                functionNames[count] = ((Function) cl.newInstance()).getReferenceKey();
-                functionMap.put(functionNames[count], cl);
-                count++;
-            }
-            functionList = new JLabeledChoice(JMeterUtils.getResString("choose_function"),
functionNames); //$NON-NLS-1$
-            functionList.addChangeListener(this);
-        } catch (IOException e) {
-        } catch (ClassNotFoundException e) {
-        } catch (InstantiationException e) {
-        } catch (IllegalAccessException e) {
-        }
+        functionList = new JLabeledChoice(JMeterUtils.getResString("choose_function"), CompoundVariable.getFunctionNames());
//$NON-NLS-1$
+        functionList.addChangeListener(this);
     }
 
     public void stateChanged(ChangeEvent event) {
         try {
             Arguments args = new Arguments();
-            Function function = (Function) ((Class<?>) functionMap.get(functionList.getText())).newInstance();
+            Function function = CompoundVariable.getFunctionClass(functionList.getText()).newInstance();
             List<String> argumentDesc = function.getArgumentDesc();
             for (String help : argumentDesc) {
                 args.addArgument(help, ""); //$NON-NLS-1$



Mime
View raw message