1 | private void populateCommandMap() {
| | 1 | private void populateCommandMap() {
|
2 | log.info("populateCommandMap called");
| | 2 | try {
|
3 | List<String> listClasses;
| | 3 | List<String> listClasses = ClassFinder.findClassesThatExtend(
|
4 | Command command;
| | 4 | JMeterUtils.getSearchPaths(), // strPathsOrJars - pathnames or jarfiles to search for classes
|
5 | Iterator<String> iterClasses;
| | 5 | // classNames - required parent class(es) or annotations
|
6 | Class<?> commandClass;
| | 6 | new Class[] {Class.forName("org.apache.jmeter.gui.action.Command") }, // $NON-NLS-1$
|
7 | try {
| | 7 | false, // innerClasses - should we include inner classes?
|
8 | listClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { Class
| | 8 | null, // contains - classname should contain this string
|
9 | .forName("org.apache.jmeter.gui.action.Command") });
| | 9 | // Ignore the classes which are specific to the reporting tool
|
10 | commands = new HashMap<String, Set<Command>>(listClasses.size());
| | 10 | "org.apache.jmeter.report.gui", // $NON-NLS-1$ // notContains - classname should not contain this string
|
11 | if (listClasses.size() == 0) {
| | 11 | false); // annotations - true if classnames are annotations
|
12 | log.warn("!!!!!Uh-oh, didn't find any action handlers!!!!!");
| | 12 | commands = new HashMap<String, Set<Command>>(listClasses.size());
|
13 | }
| | 13 | if (listClasses.isEmpty()) {
|
14 | iterClasses = listClasses.iterator();
| | 14 | log.fatalError("!!!!!Uh-oh, didn't find any action handlers!!!!!");
|
15 | while (iterClasses.hasNext()) {
| | 15 | throw new JMeterError("No action handlers found - check JMeterHome and libraries");
|
16 | String strClassName = iterClasses.next();
| | 16 | }
|
17 | if (strClassName.startsWith("org.apache.jmeter.report.gui.action")) {
| | 17 | for (String strClassName : listClasses) {
|
18 | // log.info("classname:: " + strClassName);
| | 18 | Class<?> commandClass = Class.forName(strClassName);
|
19 | commandClass = Class.forName(strClassName);
| | 19 | Command command = (Command) commandClass.newInstance();
|
20 | if (!Modifier.isAbstract(commandClass.getModifiers())) {
| | 20 | for (String commandName : command.getActionNames()) {
|
21 | command = (Command) commandClass.newInstance();
| | 21 | Set<Command> commandObjects = commands.get(commandName);
|
22 | Iterator<String> iter = command.getActionNames().iterator();
| | 22 | if (commandObjects == null) {
|
23 | while (iter.hasNext()) {
| | 23 | commandObjects = new HashSet<Command>();
|
24 | String commandName = iter.next();
| | 24 | commands.put(commandName, commandObjects);
|
25 | Set<Command> commandObjects = commands.get(commandName);
| | 25 | }
|
26 | if (commandObjects == null) {
| | 26 | commandObjects.add(command);
|
27 | commandObjects = new HashSet<Command>();
| | 27 | }
|
28 | commands.put(commandName, commandObjects);
| | 28 | }
|
29 | }
| | 29 | } catch (HeadlessException e){
|
30 | commandObjects.add(command);
| | 30 | log.warn(e.toString());
|
31 | }
| | 31 | } catch (Exception e) {
|
32 | }
| | 32 | log.error("exception finding action handlers", e);
|
33 | }
| | 33 | }
|
34 | }
| | 34 | } |
35 | } catch (HeadlessException e){
| | | |
36 | log.warn(e.toString());
| | | |
37 | } catch (Exception e) {
| | | |
38 | log.error("exception finding action handlers", e);
| | | |
39 | }
| | | |
40 | } | | | |