use of net.xeoh.plugins.base.util.PluginManagerUtil in project ANNIS by korpling.
the class ExportPanel method attach.
@Override
public void attach() {
super.attach();
this.ui = UI.getCurrent();
if (this.ui instanceof AnnisBaseUI) {
PluginManagerUtil util = new PluginManagerUtil(((AnnisBaseUI) getUI()).getPluginManager());
for (ExporterPlugin e : util.getPlugins(ExporterPlugin.class)) {
exporterClassContainer.addItem(e.getClass());
}
}
exporterClassContainer.sort(new Object[] { "simpleName" }, new boolean[] { true });
cbExporter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
cbExporter.setItemCaptionPropertyId("simpleName");
if (exporterClassContainer.size() > 0) {
cbExporter.setValue(exporterClassContainer.getIdByIndex(0));
}
}
use of net.xeoh.plugins.base.util.PluginManagerUtil in project ANNIS by korpling.
the class AnnisBaseUI method getExporter.
@Override
public ExporterPlugin getExporter(Class<? extends ExporterPlugin> clazz) {
if (exporterRegistryCache == null) {
exporterRegistryCache = MutableClassToInstanceMap.create();
PluginManagerUtil util = new PluginManagerUtil(getPluginManager());
for (ExporterPlugin e : util.getPlugins(ExporterPlugin.class)) {
exporterRegistryCache.put(e.getClass(), e);
}
}
return exporterRegistryCache.get(clazz);
}
use of net.xeoh.plugins.base.util.PluginManagerUtil in project ANNIS by korpling.
the class AnnisBaseUI method initPlugins.
private void initPlugins() {
log.info("Adding plugins");
pluginManager = PluginManagerFactory.createPluginManager();
addCustomUIPlugins(pluginManager);
File baseDir = VaadinService.getCurrent().getBaseDirectory();
File builtin = new File(baseDir, "WEB-INF/lib/annis-visualizers-" + VersionInfo.getReleaseName() + ".jar");
if (builtin.canRead()) {
pluginManager.addPluginsFrom(builtin.toURI());
log.info("added built-in plugins from {}", builtin.getPath());
} else {
log.warn("could not find built-in plugin file {}", builtin.getPath());
}
File basicPlugins = new File(baseDir, "WEB-INF/plugins");
if (basicPlugins.isDirectory()) {
pluginManager.addPluginsFrom(basicPlugins.toURI());
log.info("added plugins from {}", basicPlugins.getPath());
}
String globalPlugins = System.getenv("ANNIS_PLUGINS");
if (globalPlugins != null) {
pluginManager.addPluginsFrom(new File(globalPlugins).toURI());
log.info("added plugins from {}", globalPlugins);
}
StringBuilder listOfPlugins = new StringBuilder();
listOfPlugins.append("loaded plugins:\n");
PluginManagerUtil util = new PluginManagerUtil(pluginManager);
for (Plugin p : util.getPlugins()) {
listOfPlugins.append(p.getClass().getName()).append("\n");
}
log.info(listOfPlugins.toString());
Collection<VisualizerPlugin> visualizers = util.getPlugins(VisualizerPlugin.class);
for (VisualizerPlugin vis : visualizers) {
visualizerRegistry.put(vis.getShortName(), vis);
resourceAddedDate.put(vis.getShortName(), new Date());
}
}
Aggregations