From a9d57ad9c11567c9cb2a5759899d9fb073a72e06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Wed, 30 Mar 2016 15:37:36 +0200 Subject: [PATCH] SONAR-7441 load ServerSide components in CE for backward compatibility --- .../ComputeEngineExtensionInstaller.java | 3 ++- .../plugins/ServerExtensionInstaller.java | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/platform/ComputeEngineExtensionInstaller.java b/server/sonar-ce/src/main/java/org/sonar/ce/platform/ComputeEngineExtensionInstaller.java index 70c0d74cbb4..dce28460820 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/platform/ComputeEngineExtensionInstaller.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/platform/ComputeEngineExtensionInstaller.java @@ -21,11 +21,12 @@ package org.sonar.ce.platform; import org.sonar.api.SonarQubeVersion; import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.server.ServerSide; import org.sonar.core.platform.PluginRepository; import org.sonar.server.plugins.ServerExtensionInstaller; public class ComputeEngineExtensionInstaller extends ServerExtensionInstaller { public ComputeEngineExtensionInstaller(SonarQubeVersion sonarQubeVersion, PluginRepository pluginRepository) { - super(sonarQubeVersion, pluginRepository, ComputeEngineSide.class); + super(sonarQubeVersion, pluginRepository, ServerSide.class, ComputeEngineSide.class); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java index 5ed1fac8f05..931b3e7779c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java @@ -41,14 +41,14 @@ public abstract class ServerExtensionInstaller { private final SonarQubeVersion sonarQubeVersion; private final PluginRepository pluginRepository; - private final Class supportedAnnotationType; + private final Class[] supportedAnnotationTypes; protected ServerExtensionInstaller(SonarQubeVersion sonarQubeVersion, PluginRepository pluginRepository, - Class supportedAnnotationType) { - requireNonNull(supportedAnnotationType, "At least one supported annotation type must be specified"); + Class... supportedAnnotationTypes) { + requireNonNull(supportedAnnotationTypes, "At least one supported annotation type must be specified"); this.sonarQubeVersion = sonarQubeVersion; this.pluginRepository = pluginRepository; - this.supportedAnnotationType = supportedAnnotationType; + this.supportedAnnotationTypes = supportedAnnotationTypes; } public void installExtensions(ComponentContainer container) { @@ -103,12 +103,14 @@ public abstract class ServerExtensionInstaller { } Object installExtension(ComponentContainer container, PluginInfo pluginInfo, Object extension, boolean acceptProvider) { - if (AnnotationUtils.getAnnotation(extension, supportedAnnotationType) != null) { - if (!acceptProvider && isExtensionProvider(extension)) { - throw new IllegalStateException("ExtensionProvider can not include providers itself: " + extension); + for (Class supportedAnnotationType : supportedAnnotationTypes) { + if (AnnotationUtils.getAnnotation(extension, supportedAnnotationType) != null) { + if (!acceptProvider && isExtensionProvider(extension)) { + throw new IllegalStateException("ExtensionProvider can not include providers itself: " + extension); + } + container.addExtension(pluginInfo, extension); + return extension; } - container.addExtension(pluginInfo, extension); - return extension; } return null; } -- 2.39.5