From 04f2c58a48091b721b3ddc622f209d76b4ddbb0f Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Thu, 23 Aug 2007 12:08:44 +0000 Subject: updated from M2 branch git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@568950 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/util/CommandLineParser.java | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'java/common/src') diff --git a/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java b/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java index 9bb4a6635f..dc73bce28f 100644 --- a/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java +++ b/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java @@ -483,9 +483,9 @@ public class CommandLineParser } /** - * 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 @@ public class CommandLineParser String name = (String) propKey; String value = parsedProperties.getProperty(name); - System.setProperty(name, value); + properties.setProperty(name, value); } } } @@ -603,23 +603,16 @@ public class CommandLineParser } /** - * 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 null). * * @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 @@ public class CommandLineParser // 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) { -- cgit v1.2.1