use of com.ibm.java.diagnostics.utils.plugins.PluginConfig in project openj9 by eclipse.
the class DTFJContext method refresh.
/**
* Refresh this context.
*/
public void refresh() {
// used to detect command name clashes
ArrayList<String> names = new ArrayList<String>();
commands.clear();
loadedPlugins.clear();
failedPlugins.clear();
// these are the only hardwired commands that are always available within any context
addGlobalCommandsToContext();
PluginManager pluginManager = PluginManagerLocator.getManager();
DTFJPluginManager manager = new DTFJPluginManager(pluginManager);
try {
pluginManager.refreshSearchPath();
pluginManager.scanForClassFiles();
} catch (CommandException e) {
// may catch a CommandException when loading plugins
logger.log(Level.FINE, "Problem loading DTFJ View plugins: " + e.getMessage());
logger.log(Level.FINEST, "Problem loading DTFJ View plugins: ", e);
}
ClassLoader thisloader = this.getClass().getClassLoader();
if (thisloader == null) {
thisloader = ClassLoader.getSystemClassLoader();
}
LocalPriorityClassloader loader = new LocalPriorityClassloader(pluginManager.getClasspath(), thisloader);
for (PluginConfig config : manager.getPlugins(apiLevel, hasImage, (rt != null))) {
try {
ICommand cmd = config.newInstance(loader);
loadedPlugins.add(config);
for (String cmdname : cmd.getCommandNames()) {
// check for a name space clash i.e. two plugins could potentially be invoked by a single command
if (names.contains(cmdname)) {
logger.fine("Name space clash detected for " + config.getClassName() + ". The command name " + cmdname + " is already in use");
} else {
names.add(cmdname);
}
}
commands.add(cmd);
} catch (CommandException e) {
failedPlugins.add(config);
logger.log(Level.FINE, "Failed to create a new plugin instance for " + config.getClassName());
logger.log(Level.FINEST, "Failed to create a new plugin instance: ", e);
}
}
}
Aggregations