diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-08-18 00:32:44 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-08-18 00:32:44 +0000 |
| commit | f3e1ac2fd1570ed71293fa68673e6e8161aad8de (patch) | |
| tree | 64397986acb6ab5b2e2ad56a0b5fbf458469727a /qpid/java/broker | |
| parent | 01a5bda09ed63b7520959fc28bcd53ce6fb6eb9f (diff) | |
| download | qpid-python-f3e1ac2fd1570ed71293fa68673e6e8161aad8de.tar.gz | |
QPID-6011 : [Java Broker] provide a mechanism for disabling plugins and implementation types
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1618531 13f79535-47bb-0310-9956-ffa450edef68
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(); |
