use of com.igormaznitsa.commons.version.Version in project netbeans-mmd-plugin by raydac.
the class ExternalPlugins method init.
public void init() {
final Collection<File> plugins = FileUtils.listFiles(this.pluginsFolder, new String[] { PLUGIN_EXTENSION, PLUGIN_EXTENSION.toUpperCase(Locale.ENGLISH) }, false);
LOGGER.info("Detected " + plugins.size() + " plugin(s)");
for (final File plugin : plugins) {
try {
final PluginClassLoader loader = new PluginClassLoader(plugin);
final String pluginTitle = GetUtils.ensureNonNull(loader.getAttributes(Attribute.TITLE), "<unknown>");
final Version pluginVersion = new Version(loader.getAttributes(Attribute.VERSION));
LOGGER.info(String.format("Detected plugin %s [%s]", pluginTitle, pluginVersion.toString()));
final Version pluginApiVersion = loader.getApiVersion();
if (this.pluginApiValidator.isValid(pluginApiVersion)) {
LOGGER.info(String.format("Plugin %s [%s] is valid for API", pluginTitle, pluginVersion.toString()));
final String[] classes = loader.extractPluginClassNames();
for (final String klazzName : classes) {
LOGGER.info(String.format("Loading plugin class %s from %s", klazzName, pluginTitle));
final MindMapPlugin pluginInstance = (MindMapPlugin) loader.loadClass(klazzName).newInstance();
MindMapPluginRegistry.getInstance().registerPlugin(pluginInstance);
}
} else {
LOGGER.warn(String.format("Plugin %s [%s] is not valid for API : %s", pluginTitle, pluginVersion.toString(), pluginApiVersion.toString()));
}
} catch (Exception ex) {
LOGGER.error("Can't load plugin from : " + plugin.getAbsolutePath(), ex);
}
}
}
Aggregations