diff --git a/core/java/src/net/i2p/I2PAppContext.java b/core/java/src/net/i2p/I2PAppContext.java index cac8cdb29e5ae185e9ddc11b835c0597ddf9618b..3e514ea18b3e9db7fdfa3fb06c944a73b9e9ccd0 100644 --- a/core/java/src/net/i2p/I2PAppContext.java +++ b/core/java/src/net/i2p/I2PAppContext.java @@ -179,6 +179,25 @@ public class I2PAppContext { return System.getProperty(propName, defaultValue); } + /** + * Return an int with an int default + */ + public int getProperty(String propName, int defaultVal) { + String val = null; + if (_overrideProps != null) { + val = _overrideProps.getProperty(propName); + if (val == null) + val = System.getProperty(propName); + } + int ival = defaultVal; + if (val != null) { + try { + ival = Integer.parseInt(val); + } catch (NumberFormatException nfe) {} + } + return ival; + } + /** * Access the configuration attributes of this context, listing the properties * provided during the context construction, as well as the ones included in diff --git a/router/java/src/net/i2p/router/RouterContext.java b/router/java/src/net/i2p/router/RouterContext.java index 8b34f636417fecf9f5d43345fb30cca459729e65..087cde91847cb313680452266920a3bc5b090f37 100644 --- a/router/java/src/net/i2p/router/RouterContext.java +++ b/router/java/src/net/i2p/router/RouterContext.java @@ -329,6 +329,23 @@ public class RouterContext extends I2PAppContext { return super.getProperty(propName, defaultVal); } + /** + * Return an int with an int default + */ + public int getProperty(String propName, int defaultVal) { + if (_router != null) { + String val = _router.getConfigSetting(propName); + if (val != null) { + int ival = defaultVal; + try { + ival = Integer.parseInt(val); + } catch (NumberFormatException nfe) {} + return ival; + } + } + return super.getProperty(propName, defaultVal); + } + /** * The context's synchronized clock, which is kept context specific only to * enable simulators to play with clock skew among different instances.