diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-04 01:56:50 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-04 01:56:50 +0000 |
commit | 0c3b68d0ba3a19ce7b4371d5abda6dd2034b72fc (patch) | |
tree | 57ab73e4ee339176783eef9b8e2a4ac227bacee8 /java/sca/modules/node-launcher-equinox | |
parent | 54bec0b997ffd6d92efdd209071ce230b2e24099 (diff) |
Cleanup the CLI processing
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@740575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-launcher-equinox')
2 files changed, 32 insertions, 25 deletions
diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java index 510fe62c71..6ce2efda72 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java @@ -39,6 +39,11 @@ import org.osgi.framework.BundleContext; /** * A launcher for SCA nodes. + * + * Agruments: + * [-config <equinoxConfiguration>]: The configuration folder for Equinox + * [-c <compositeURI>]: The composite URI + * contribution1 ... contributionN: A list of contribution files or URLs * * @version $Rev$ $Date$ */ @@ -109,16 +114,7 @@ public class NodeLauncher { public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); - Options options = new Options(); - Option opt1 = new Option("c", "composite", true, "URI for the composite"); - opt1.setArgName("compositeURI"); - options.addOption(opt1); - Option opt2 = new Option("n", "node", true, "URI for the node configuration"); - opt2.setArgName("nodeConfigurationURI"); - options.addOption(opt2); - Option opt3 = new Option("config", "configuration", true, "Configuration"); - opt3.setArgName("equinoxConfiguration"); - options.addOption(opt3); + Options options = getCommandLineOptions(); CommandLine cli = parser.parse(options, args); Object node = null; @@ -162,7 +158,7 @@ public class NodeLauncher { HelpFormatter formatter = new HelpFormatter(); formatter.setSyntaxPrefix("Usage: "); formatter.printHelp("java " + NodeLauncher.class.getName() - + " -c <compositeURI> contributionURL1 ... contributionURLN", options); + + " [-config <equinoxConfiguration>] [-c <compositeURI>] contribution1 ... contributionN", options); return; } // Create a node launcher @@ -215,6 +211,20 @@ public class NodeLauncher { } } + static Options getCommandLineOptions() { + Options options = new Options(); + Option opt1 = new Option("c", "composite", true, "URI for the composite"); + opt1.setArgName("compositeURI"); + options.addOption(opt1); + Option opt2 = new Option("n", "node", true, "URI for the node configuration"); + opt2.setArgName("nodeConfigurationURI"); + options.addOption(opt2); + Option opt3 = new Option("config", "configuration", true, "Configuration"); + opt3.setArgName("equinoxConfiguration"); + options.addOption(opt3); + return options; + } + public void destroy() { if (equinoxHost != null) { equinoxHost.stop(); diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java index 44f92dee7d..4b4c4a8978 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java @@ -22,14 +22,15 @@ package org.apache.tuscany.sca.node.equinox.launcher; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionGroup; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; /** * Main class for this JAR. - * With no arguments this class launches the SCA Node Daemon. - * With a "domain" argument it launches the SCA domain admin node. + * With a "-nodeDaemon or -nd" this class launches the SCA Node Daemon. + * With a "-domainManager or -dm" argument it launches the SCA domain admin node. * With any other argument it launches an SCA Node. * * @version $Rev$ $Date$ @@ -39,21 +40,17 @@ public class NodeMain { public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); Options options = new Options(); - options.addOption("dm", "domainManager", false, "Domain Manager"); - options.addOption("nd", "nodeDaemon", false, "Node Domain"); + OptionGroup group = new OptionGroup(); + group.addOption(new Option("dm", "domainManager", false, "Domain Manager")); + group.addOption(new Option("nd", "nodeDaemon", false, "Node Domain")); + options.addOptionGroup(group); // Add options from NodeLauncher to avoid UnrecognizedOptionException - Option opt1 = new Option("c", "composite", true, "URI for the composite"); - opt1.setArgName("compositeURI"); - options.addOption(opt1); - Option opt2 = new Option("n", "node", true, "URI for the node configuration"); - opt2.setArgName("nodeConfigurationURI"); - options.addOption(opt2); - Option opt3 = new Option("config", "configuration", true, "Configuration"); - opt3.setArgName("equinoxConfiguration"); - options.addOption(opt3); + for (Object o : NodeLauncher.getCommandLineOptions().getOptions()) { + options.addOption((Option)o); + } - CommandLine cli = parser.parse(options, args, false); + CommandLine cli = parser.parse(options, args); if (cli.hasOption("nd")) { NodeDaemonLauncher.main(args); } else if (cli.hasOption("dm")) { |