@Override public Object getProperty(String key, Object defaultValue) { String value = SecurityActions.getSystemProperty(key, null); return value != null ? value : defaultValue; } }
@Override public Object getProperty(String key, Object defaultValue) { String envVar = SecurityActions.getEnv(toEnvVariable(environmentVariablePrefix, key), null); return envVar != null ? envVar : defaultValue; }
private static Properties getDefaultProperties() { URL configURL = null; // #1 Use the explicit system property String sysprop = SecurityActions.getSystemProperty(org.jboss.gravia.Constants.GRAVIA_PROPERTIES, null); if (sysprop != null) { try { configURL = new URL(sysprop); } catch (MalformedURLException ex) { throw new IllegalStateException("Invalid configuration URL: " + sysprop); } } // #2 discover the config file as resource if (configURL == null) { ClassLoader classLoader = DefaultPropertiesProvider.class.getClassLoader(); configURL = classLoader.getResource(org.jboss.gravia.Constants.GRAVIA_PROPERTIES); } Properties props = new Properties(); if (configURL != null) { try { props.load(configURL.openStream()); } catch (IOException ex) { throw new IllegalStateException("Cannot load configuration from: " + configURL, ex); } } return props; }