@@ -38,6 +38,7 @@ import org.sonar.api.utils.UriReader; | |||
import org.sonar.ce.db.CeDbClient; | |||
import org.sonar.ce.db.ReadOnlyPropertiesDao; | |||
import org.sonar.ce.es.EsIndexerEnabler; | |||
import org.sonar.ce.platform.ComputeEngineExtensionInstaller; | |||
import org.sonar.ce.property.CePropertyDefinitions; | |||
import org.sonar.ce.settings.ComputeEngineSettings; | |||
import org.sonar.ce.user.CeUserSession; | |||
@@ -191,7 +192,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { | |||
PluginLoader.class, | |||
CePluginRepository.class, | |||
InstalledPluginReferentialFactory.class, | |||
ServerExtensionInstaller.class, | |||
ComputeEngineExtensionInstaller.class, | |||
// depends on plugins | |||
// RailsAppsDeployer.class, |
@@ -0,0 +1,31 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.ce.platform; | |||
import org.sonar.api.SonarQubeVersion; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
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); | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.ce.platform; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -30,9 +30,9 @@ import org.sonar.server.db.migrations.PlatformDatabaseMigrationExecutorServiceIm | |||
import org.sonar.server.platform.DefaultServerUpgradeStatus; | |||
import org.sonar.server.platform.RailsAppsDeployer; | |||
import org.sonar.server.plugins.InstalledPluginReferentialFactory; | |||
import org.sonar.server.plugins.ServerExtensionInstaller; | |||
import org.sonar.server.plugins.ServerPluginJarExploder; | |||
import org.sonar.server.plugins.ServerPluginRepository; | |||
import org.sonar.server.plugins.WebServerExtensionInstaller; | |||
import org.sonar.server.ruby.PlatformRubyBridge; | |||
import org.sonar.server.ui.JRubyI18n; | |||
@@ -56,7 +56,7 @@ public class PlatformLevel2 extends PlatformLevel { | |||
PluginLoader.class, | |||
PluginClassloaderFactory.class, | |||
InstalledPluginReferentialFactory.class, | |||
ServerExtensionInstaller.class, | |||
WebServerExtensionInstaller.class, | |||
// depends on plugins | |||
RailsAppsDeployer.class, |
@@ -21,30 +21,34 @@ package org.sonar.server.plugins; | |||
import com.google.common.collect.ArrayListMultimap; | |||
import com.google.common.collect.ListMultimap; | |||
import java.lang.annotation.Annotation; | |||
import java.util.Map; | |||
import org.sonar.api.Extension; | |||
import org.sonar.api.ExtensionProvider; | |||
import org.sonar.api.Plugin; | |||
import org.sonar.api.SonarPlugin; | |||
import org.sonar.api.SonarQubeVersion; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.api.utils.AnnotationUtils; | |||
import org.sonar.core.platform.ComponentContainer; | |||
import org.sonar.core.platform.PluginInfo; | |||
import org.sonar.core.platform.PluginRepository; | |||
import static java.util.Objects.requireNonNull; | |||
/** | |||
* Loads the plugins server extensions and injects them to DI container | |||
*/ | |||
@ServerSide | |||
public class ServerExtensionInstaller { | |||
public abstract class ServerExtensionInstaller { | |||
private final SonarQubeVersion sonarQubeVersion; | |||
private final PluginRepository pluginRepository; | |||
private final Class<? extends Annotation> supportedAnnotationType; | |||
public ServerExtensionInstaller(SonarQubeVersion sonarQubeVersion, PluginRepository pluginRepository) { | |||
protected ServerExtensionInstaller(SonarQubeVersion sonarQubeVersion, PluginRepository pluginRepository, | |||
Class<? extends Annotation> supportedAnnotationType) { | |||
requireNonNull(supportedAnnotationType, "At least one supported annotation type must be specified"); | |||
this.sonarQubeVersion = sonarQubeVersion; | |||
this.pluginRepository = pluginRepository; | |||
this.supportedAnnotationType = supportedAnnotationType; | |||
} | |||
public void installExtensions(ComponentContainer container) { | |||
@@ -99,7 +103,7 @@ public class ServerExtensionInstaller { | |||
} | |||
Object installExtension(ComponentContainer container, PluginInfo pluginInfo, Object extension, boolean acceptProvider) { | |||
if (AnnotationUtils.getAnnotation(extension, ServerSide.class) != null) { | |||
if (AnnotationUtils.getAnnotation(extension, supportedAnnotationType) != null) { | |||
if (!acceptProvider && isExtensionProvider(extension)) { | |||
throw new IllegalStateException("ExtensionProvider can not include providers itself: " + extension); | |||
} |
@@ -0,0 +1,31 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.plugins; | |||
import org.sonar.api.SonarQubeVersion; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.core.platform.PluginRepository; | |||
@ServerSide | |||
public class WebServerExtensionInstaller extends ServerExtensionInstaller { | |||
public WebServerExtensionInstaller(SonarQubeVersion sonarQubeVersion, PluginRepository pluginRepository) { | |||
super(sonarQubeVersion, pluginRepository, ServerSide.class); | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.ce; | |||
import com.google.common.annotations.Beta; | |||
import java.lang.annotation.ElementType; | |||
import java.lang.annotation.Retention; | |||
import java.lang.annotation.RetentionPolicy; | |||
import java.lang.annotation.Target; | |||
import org.sonar.api.batch.BatchSide; | |||
/** | |||
* Same as {@link BatchSide} but for components for the Compute Engine Server. | |||
* | |||
* @since 5.5 | |||
*/ | |||
@Retention(RetentionPolicy.RUNTIME) | |||
@Target(ElementType.TYPE) | |||
@Beta | |||
public @interface ComputeEngineSide { | |||
} |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2016 SonarSource SA | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.api.ce; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -23,6 +23,7 @@ import org.junit.Test; | |||
import org.sonar.api.BatchComponent; | |||
import org.sonar.api.batch.BatchSide; | |||
import org.sonar.api.batch.InstantiationStrategy; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.api.server.ServerSide; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -57,6 +58,8 @@ public class ExtensionUtilsTest { | |||
assertThat(ExtensionUtils.isBatchSide(ServerService.class)).isFalse(); | |||
assertThat(ExtensionUtils.isBatchSide(new ServerService())).isFalse(); | |||
assertThat(ExtensionUtils.isBatchSide(new WebServerService())).isFalse(); | |||
assertThat(ExtensionUtils.isBatchSide(new ComputeEngineService())).isFalse(); | |||
} | |||
@BatchSide | |||
@@ -85,4 +88,14 @@ public class ExtensionUtilsTest { | |||
} | |||
@ServerSide | |||
public static class WebServerService { | |||
} | |||
@ComputeEngineSide | |||
public static class ComputeEngineService { | |||
} | |||
} |