use of gnu.getopt.Getopt in project jbossws-cxf by jbossws.
the class Runner method parseArguments.
private static BenchmarkTest parseArguments(String[] args) throws Exception {
String shortOpts = "t:r:s:i:a:vh";
LongOpt[] longOpts = { new LongOpt("deployment", LongOpt.REQUIRED_ARGUMENT, null, 'd'), new LongOpt("threads", LongOpt.REQUIRED_ARGUMENT, null, 't'), new LongOpt("runs", LongOpt.REQUIRED_ARGUMENT, null, 'r'), new LongOpt("sleep", LongOpt.REQUIRED_ARGUMENT, null, 's'), new LongOpt("iterations", LongOpt.REQUIRED_ARGUMENT, null, 'i'), new LongOpt("address", LongOpt.REQUIRED_ARGUMENT, null, 'a'), new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'), new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h') };
Getopt getopt = new Getopt("Benchmark-runner", args, shortOpts, longOpts);
int c;
while ((c = getopt.getopt()) != -1) {
switch(c) {
case 't':
threadCount = Integer.parseInt(getopt.getOptarg());
break;
case 'r':
runs = Integer.parseInt(getopt.getOptarg());
break;
case 's':
sleep = Long.parseLong(getopt.getOptarg());
break;
case 'i':
iterations = Integer.parseInt(getopt.getOptarg());
break;
case 'a':
address = getopt.getOptarg();
break;
case 'v':
verbose = true;
break;
case 'h':
printHelp();
System.exit(0);
case '?':
System.exit(1);
}
}
int classPos = getopt.getOptind();
if (classPos >= args.length) {
System.err.println("Error: test-class was not specified!");
printHelp();
System.exit(1);
}
try {
Class<?> clazz = Class.forName(args[classPos]);
System.out.println(BenchmarkTest.class.isAssignableFrom(clazz));
System.out.println(clazz.isAssignableFrom(BenchmarkTest.class));
return (BenchmarkTest) clazz.newInstance();
} catch (Exception e) {
System.out.println("Cannot instanciate " + args[classPos]);
throw e;
}
}
Aggregations