tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r740575 - in /tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher: NodeLauncher.java NodeMain.java
Date Wed, 04 Feb 2009 01:56:50 GMT
Author: rfeng
Date: Wed Feb  4 01:56:50 2009
New Revision: 740575

URL: http://svn.apache.org/viewvc?rev=740575&view=rev
Log:
Cleanup the CLI processing

Modified:
    tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
    tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java

Modified: tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java?rev=740575&r1=740574&r2=740575&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
(original)
+++ tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
Wed Feb  4 01:56:50 2009
@@ -39,6 +39,11 @@
 
 /**
  * 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 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 @@
                     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 @@
         }
     }
 
+    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();

Modified: tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java?rev=740575&r1=740574&r2=740575&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java
(original)
+++ tuscany/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java
Wed Feb  4 01:56:50 2009
@@ -22,14 +22,15 @@
 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 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")) {



Mime
View raw message