options.addOption(option("h", "help", "cmd.start.opt.help"));
options.addOption(option(null, "conf", "file", "cmd.start.opt.conf"));
options.addOption(option(null, "local-copy", "boolean", "cmd.start.opt.localCopy"));
options.addOption(option(null, "examples", "cmd.start.opt.examples"));
ResourceFinder finder = new ResourceFinder("META-INF/");
Set<String> services = null;
try {
Map<String, Properties> serviceEntries = finder.mapAvailableProperties(ServerService.class.getName());
services = serviceEntries.keySet();
for (String service : services) {
options.addOption(option(null, service + "-port", "int", "cmd.start.opt.port", service));
options.addOption(option(null, service + "-bind", "host", "cmd.start.opt.bind", service));
}
} catch (Exception e) {
services = Collections.EMPTY_SET;
}
CommandLine line = null;
try {
// parse the command line arguments
line = parser.parse(options, args);
} catch (ParseException exp) {
help(options);
throw new SystemExitException(-1);
}
if (line.hasOption("help")) {
help(options);
return;
} else if (line.hasOption("version")) {
OpenEjbVersion.get().print(System.out);
return;
} else if (line.hasOption("examples")) {
try {
String text = finder.findString("org.apache.openejb.cli/start.examples");
System.out.println(text);
return;
} catch (Exception e) {
System.err.println("Unable to print examples:");
e.printStackTrace(System.err);