Jar plugin loading refactor as generic ServerPlugin

Now that we have a fully pluggable ServerPlugin mechanism
with registered providers, there is no reason why the jar
plugins cannot be loaded using the same interface.

Removing all the custom code managing the jar plugins
and creating a new pre-defined JarPluginProvider.

NOTE: A limitation still exists on init-steps as they
can only be provided by jar plugins. This is due to
the fact that Gerrit init runs without having a fully
configured plugin loader and full set of Guice injectors.

Change-Id: I793570735376be3a40f3204af6e82820191caac6
This commit is contained in:
Luca Milanesio
2014-04-28 00:45:34 +01:00
parent 94007f6af7
commit 9faf177526
6 changed files with 216 additions and 141 deletions

View File

@@ -18,6 +18,7 @@ import com.google.common.base.Objects;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.pgm.util.ConsoleUI;
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.plugins.JarPluginProvider;
import com.google.gerrit.server.plugins.PluginLoader;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
@@ -95,9 +96,9 @@ public class InitPluginStepsLoader {
}
}
private Injector getPluginInjector(File jarFile) throws IOException {
private Injector getPluginInjector(final File jarFile) throws IOException {
final String pluginName =
Objects.firstNonNull(PluginLoader.getGerritJarPluginName(jarFile),
Objects.firstNonNull(JarPluginProvider.getJarPluginName(jarFile),
PluginLoader.nameOf(jarFile));
return initInjector.createChildInjector(new AbstractModule() {
@Override

View File

@@ -18,7 +18,7 @@ import com.google.common.collect.Lists;
import com.google.gerrit.common.PluginData;
import com.google.gerrit.pgm.util.ConsoleUI;
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.plugins.PluginLoader;
import com.google.gerrit.server.plugins.JarPluginProvider;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -52,7 +52,7 @@ public class InitPlugins implements InitStep {
pluginsDistribution.foreach(new PluginsDistribution.Processor() {
@Override
public void process(String pluginName, InputStream in) throws IOException {
File tmpPlugin = PluginLoader.storeInTemp(pluginName, in, site);
File tmpPlugin = JarPluginProvider.storeInTemp(pluginName, in, site);
String pluginVersion = getVersion(tmpPlugin);
if (deleteTempPluginFile) {
tmpPlugin.delete();