diff options
Diffstat (limited to 'qpid/java/broker')
| -rw-r--r-- | qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java index 72550128b7..43b0f9da67 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java @@ -25,6 +25,9 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; @@ -94,6 +97,9 @@ public class Main private static final Option OPTION_MM_PASSWORD = OptionBuilder.withArgName("password").hasArg() .withDescription("Set the password for the management mode user " + BrokerOptions.MANAGEMENT_MODE_USER_NAME).withLongOpt("management-mode-password").create("mmpass"); + private static final Option OPTION_INITIAL_SYSTEM_PROPERTIES = OptionBuilder.withArgName("path").hasArg() + .withDescription("set the location of initial properties file to set otherwise unset system properties").withLongOpt("system-properties-file").create("props"); + private static final Options OPTIONS = new Options(); static @@ -114,6 +120,7 @@ public class Main OPTIONS.addOption(OPTION_MM_HTTP_PORT); OPTIONS.addOption(OPTION_MM_PASSWORD); OPTIONS.addOption(OPTION_CONFIGURATION_PROPERTY); + OPTIONS.addOption(OPTION_INITIAL_SYSTEM_PROPERTIES); } protected CommandLine _commandLine; @@ -168,7 +175,11 @@ public class Main protected void execute() throws Exception { + String initialProperties = _commandLine.getOptionValue(OPTION_INITIAL_SYSTEM_PROPERTIES.getOpt()); + populateSystemPropertiesFromDefaults(initialProperties); + BrokerOptions options = new BrokerOptions(); + String initialConfigLocation = _commandLine.getOptionValue(OPTION_INITIAL_CONFIGURATION_PATH.getOpt()); if (initialConfigLocation != null) { @@ -304,6 +315,28 @@ public class Main } } + private void populateSystemPropertiesFromDefaults(final String initialProperties) throws IOException + { + URL initialPropertiesLocation; + if(initialProperties == null) + { + initialPropertiesLocation = getClass().getClassLoader().getResource("system.properties"); + } + else + { + initialPropertiesLocation = (new File(initialProperties)).toURI().toURL(); + } + + Properties props = new Properties(); + props.load(initialPropertiesLocation.openStream()); + Set<String> propertyNames = new HashSet<>(props.stringPropertyNames()); + propertyNames.removeAll(System.getProperties().stringPropertyNames()); + for(String propName : propertyNames) + { + System.setProperty(propName, props.getProperty(propName)); + } + } + private void copyInitialConfigFile(final BrokerOptions options, final File destinationFile) { String initialConfigLocation = options.getInitialConfigurationLocation(); |
