Browse Source

SONAR-7441 load ServerSide components in CE for backward compatibility

tags/5.5-M12
Sébastien Lesaint 8 years ago
parent
commit
a9d57ad9c1

+ 2
- 1
server/sonar-ce/src/main/java/org/sonar/ce/platform/ComputeEngineExtensionInstaller.java View File

@@ -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);
}
}

+ 11
- 9
server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java View File

@@ -41,14 +41,14 @@ public abstract class ServerExtensionInstaller {

private final SonarQubeVersion sonarQubeVersion;
private final PluginRepository pluginRepository;
private final Class<? extends Annotation> supportedAnnotationType;
private final Class<? extends Annotation>[] supportedAnnotationTypes;

protected ServerExtensionInstaller(SonarQubeVersion sonarQubeVersion, PluginRepository pluginRepository,
Class<? extends Annotation> supportedAnnotationType) {
requireNonNull(supportedAnnotationType, "At least one supported annotation type must be specified");
Class<? extends Annotation>... 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<? extends Annotation> 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;
}

Loading…
Cancel
Save