Access Java System Properties from JavaScript Code

You can access your Java system properties (.properties file) by adding the following code snippet to your Java Script code in API Creator:
lac40
You can access your Java system properties (
.properties
file) by adding the following code snippet to your Java Script code in API Creator:
var readProp = {}; // a common JavaScript technique for name-scoping readProp.readAPIProperties = function readAPIProperties(aPropFileName) { var response = {}; try { prop = java.util.Optional.of(new java.util.Properties()).map(function(p) { p.load(new java.io.FileInputStream(aPropFileName)); return p;}).get(); } catch (e) { print (title + "** readAPIProperties - exception reading properties [" + aPropFileName + "]: " + e); return null; } var propEnum = prop.propertyNames(); while (propEnum.hasMoreElements()) { // you could make these per-API var propName = propEnum.nextElement(); var propValue = prop.getProperty(propName); // + ""; // print(title + "......each prop: " + propName + " = " + propValue); if (propValue.startsWith("{")) response[propName] = JSON.parse(propValue); else response[propName] = propValue; } // print (title + "..readAPIProperties from file [" + propFileName + "] returns -->\n" + JSON.stringify(response)); return response; };
An ideal place to add access to your Java system properties is in startup listeners.
For more information about startup listeners, see Startup Listeners.