// Enclose the following code block (most likely part of the constructor) that loads the default configuration with the following if-statement:
// load initial configuration from properties file only if there is no persistent data for the default context:
moXodusPersistence = new MOXodusPersistence(moServers, Environments.newInstance(configFile)); // <--- ADD THIS LINE
if (!moXodusPersistence.isContextLoadable(null)) { // <--- ADD THIS LINE
InputStream configInputStream =
SampleAgent.class.getResourceAsStream("SampleAgentConfig.properties");
if (args.containsKey("cfg")) {
String configFilename = (String) ArgumentParser.getValue(args, "cfg", 0);
try {
configInputStream = new FileInputStream(configFilename);
} catch (FileNotFoundException ex1) {
logger.error("Config file '" + configFilename + "' not found: " + ex1.getMessage(), ex1);
throw new RuntimeException(ex1);
}
}
final Properties props = new Properties();
try {
props.load(configInputStream);
} catch (IOException ex) {
ex.printStackTrace();
}
configurationFactory = () -> new PropertyMOInput(props, agent);
}
|