use of com.qlangtech.tis.extension.impl.ExtensionRefreshException in project tis by qlangtech.
the class PluginManager method start.
public void start(List<PluginWrapper> plugins) throws Exception {
Map<String, PluginWrapper> pluginsByName = plugins.stream().collect(Collectors.toMap(PluginWrapper::getShortName, p -> p));
// recalculate dependencies of plugins optionally depending the newly deployed ones.
for (PluginWrapper depender : this.plugins) {
if (plugins.contains(depender)) {
// skip itself.
continue;
}
for (PluginWrapper.Dependency d : depender.getOptionalDependencies()) {
PluginWrapper dependee = pluginsByName.get(d.shortName);
if (dependee != null) {
// this plugin depends on the newly loaded one!
// recalculate dependencies!
getPluginStrategy().updateDependency(depender, dependee);
break;
}
}
}
// Redo who depends on who.
resolveDependentPlugins();
try {
TIS.get().refreshExtensions();
} catch (ExtensionRefreshException e) {
throw new IOException("Failed to refresh extensions after installing some plugins", e);
}
for (PluginWrapper p : plugins) {
// TODO:According to the postInitialize() documentation, one may expect that
// p.getPluginOrFail() NPE will continue the initialization. Keeping the original behavior ATM
p.getPluginOrFail().postInitialize();
}
// run initializers in the added plugins
Reactor r = new Reactor(InitMilestone.ordering());
Set<ClassLoader> loaders = plugins.stream().map(p -> p.classLoader).collect(Collectors.toSet());
r.addAll(new InitializerFinder(uberClassLoader) {
@Override
protected boolean filter(Method e) {
return !loaders.contains(e.getDeclaringClass().getClassLoader()) || super.filter(e);
}
}.discoverTasks(r));
new InitReactorRunner().run(r);
}
Aggregations