/* Choice 2: as a created MBean */
// server.createMBean(ConfigurationLoader.class.getName(), ObjectName.getInstance("config:service=loader"), null);
/* Choice 3: as a registered MBean */
ConfigurationLoader loader = new ConfigurationLoader();
server.registerMBean(loader, ObjectName.getInstance("config:service=loader"));
// The XML file
/* Choice 1: read it from classpath using classloaders
Note: the directory that contains the XML file must be in the classpath */
// InputStream stream = ConfigurationStartup.class.getClassLoader().getResourceAsStream("config.xml");
// Reader reader = new BufferedReader(new InputStreamReader(stream));
/* Choice 2: read it from a file
Note: requires file path to be passed as program argument */
String path = args[0];
Reader reader = new BufferedReader(new FileReader(path));
// Read and execute the 'startup' section of the XML file
loader.startup(reader);
reader.close();
System.out.println("Application configured successfully");
}