use of ro.fortsoft.pf4j.Version in project gitblit by gitblit.
the class PluginManager method start.
@Override
public PluginManager start() {
File dir = runtimeManager.getFileOrFolder(Keys.plugins.folder, "${baseFolder}/plugins");
dir.mkdirs();
pf4j = new DefaultPluginManager(dir) {
@Override
protected PluginFactory createPluginFactory() {
return new GuicePluginFactory();
}
@Override
protected ExtensionFactory createExtensionFactory() {
return new GuiceExtensionFactory();
}
};
try {
Version systemVersion = Version.createVersion(Constants.getVersion());
pf4j.setSystemVersion(systemVersion);
} catch (Exception e) {
logger.error(null, e);
}
pf4j.loadPlugins();
logger.debug("Starting plugins");
pf4j.startPlugins();
return this;
}
use of ro.fortsoft.pf4j.Version in project gitblit by gitblit.
the class PluginManager method getRegisteredPlugins.
@Override
public synchronized List<PluginRegistration> getRegisteredPlugins() {
List<PluginRegistration> list = new ArrayList<PluginRegistration>();
Map<String, PluginRegistration> map = new TreeMap<String, PluginRegistration>();
for (PluginRegistry registry : getRegistries()) {
list.addAll(registry.registrations);
for (PluginRegistration reg : list) {
reg.installedRelease = null;
map.put(reg.id, reg);
}
}
for (PluginWrapper pw : pf4j.getPlugins()) {
String id = pw.getDescriptor().getPluginId();
Version pv = pw.getDescriptor().getVersion();
PluginRegistration reg = map.get(id);
if (reg != null) {
reg.installedRelease = pv.toString();
}
}
return list;
}
use of ro.fortsoft.pf4j.Version in project gitblit by gitblit.
the class PluginManager method upgradePlugin.
@Override
public synchronized boolean upgradePlugin(String pluginId, String url, boolean verifyChecksum) throws IOException {
// ensure we can download the update BEFORE we remove the existing one
File file = download(url, verifyChecksum);
if (file == null || !file.exists()) {
logger.error("Failed to download plugin {}", url);
return false;
}
Version oldVersion = pf4j.getPlugin(pluginId).getDescriptor().getVersion();
if (removePlugin(pluginId, false)) {
String newPluginId = pf4j.loadPlugin(file);
if (StringUtils.isEmpty(newPluginId)) {
logger.error("Failed to load plugin {}", file);
return false;
}
// the plugin to handle an upgrade
PluginWrapper pluginWrapper = pf4j.getPlugin(newPluginId);
if (pluginWrapper.getPlugin() instanceof GitblitPlugin) {
((GitblitPlugin) pluginWrapper.getPlugin()).onUpgrade(oldVersion);
}
PluginState state = pf4j.startPlugin(newPluginId);
return PluginState.STARTED.equals(state);
} else {
logger.error("Failed to delete plugin {}", pluginId);
}
return false;
}
Aggregations