Skip to content

Instantly share code, notes, and snippets.

@tedsparc
Created August 29, 2012 13:00
Show Gist options
  • Save tedsparc/3512123 to your computer and use it in GitHub Desktop.
Save tedsparc/3512123 to your computer and use it in GitHub Desktop.
AWS Elastic Beanstalk limits JVM properties to 200 chars, so to get more system properties than that, pack them into the other properties that are supported
import java.util.Properties;
import java.util.Enumeration;
public class PreprocessSystemProperties {
public static void main(String[] args) {
System.out.println("Before preprocessing");
print_properties();
String[] property_list = {"PARAM1", "PARAM2", "PARAM3", "PARAM4", "PARAM5"};
for (String this_property : property_list) {
System.out.println("Processing: " + this_property);
preprocess_property(this_property);
}
System.out.println("After preprocessing");
print_properties();
}
static void preprocess_property(String property_name) {
// PARAM1=foo=bar,bar=quux
String raw_property = System.getProperty(property_name);
if (raw_property == null) return;
for (String this_pair : raw_property.split(",")) {
String[] left_right = this_pair.split("=");
System.setProperty(left_right[0], left_right[1]);
}
}
static void print_properties() {
Properties systemProperties = System.getProperties();
Enumeration enuProp = systemProperties.propertyNames();
while (enuProp.hasMoreElements()) {
String propertyName = (String) enuProp.nextElement();
String propertyValue = systemProperties.getProperty(propertyName);
System.out.println(propertyName + ": " + propertyValue);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment