You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ar...@apache.org on 2007/08/23 14:08:45 UTC
svn commit: r568950 -
/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java
Author: arnaudsimon
Date: Thu Aug 23 05:08:44 2007
New Revision: 568950
URL: http://svn.apache.org/viewvc?rev=568950&view=rev
Log:
updated from M2 branch
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java?rev=568950&r1=568949&r2=568950&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java Thu Aug 23 05:08:44 2007
@@ -483,9 +483,9 @@
}
/**
- * If a command line has been parsed, calling this method sets all of its parsed options as system properties.
+ * If a command line has been parsed, calling this method sets all of its parsed options into the specified properties.
*/
- public void addCommandLineToSysProperties()
+ public void addCommandLineToProperties(Properties properties)
{
if (parsedProperties != null)
{
@@ -494,7 +494,7 @@
String name = (String) propKey;
String value = parsedProperties.getProperty(name);
- System.setProperty(name, value);
+ properties.setProperty(name, value);
}
}
}
@@ -603,23 +603,16 @@
}
/**
- * Parses the command line arguments against the specified command line format, printing errors and usage
- * instrucitons and calling System.exit on errors. Extracts all trailing name=value pairs from the command line,
- * and sets them all as system properties and also returns a map of properties containing them.
+ * Extracts all name=value pairs from the command line, sets them all as system properties and also returns
+ * a map of properties containing them.
*
- * @param args The command line.
+ * @param args The command line.
+ * @param commandLine The command line parser.
+ * @param properties The properties object to inject all parsed properties into (optional may be <tt>null</tt>).
*
* @return A set of properties containing all name=value pairs from the command line.
- *
- * @todo Replace the call to System.exit with throwing an exception. Gives caller the option to decide how to
- * handle the error.
- *
- * @todo Pass in the location to write the usage to as an argument, instead of hard-coding System.out.
- *
- * @todo Allow the Properties to add trailing options to be specified as an argument rather than hard coding
- * system properties. Again, gives the caller the option to decide.
*/
- public static Properties processCommandLine(String[] args, CommandLineParser commandLine)
+ public static Properties processCommandLine(String[] args, CommandLineParser commandLine, Properties properties)
{
// Capture the command line arguments or display errors and correct usage and then exit.
Properties options = null;
@@ -630,7 +623,7 @@
// Add all the trailing command line options (name=value pairs) to system properties. They may be picked up
// from there.
- commandLine.addCommandLineToSysProperties();
+ commandLine.addCommandLineToProperties(properties);
}
catch (IllegalArgumentException e)
{