import org.sonar.server.es.EsModule;
import org.sonar.server.es.ProjectIndexersImpl;
import org.sonar.server.event.NewAlerts;
+import org.sonar.server.extension.CoreExtensionBootstraper;
+import org.sonar.server.extension.CoreExtensionStopper;
import org.sonar.server.favorite.FavoriteUpdater;
import org.sonar.server.issue.IssueFieldsSetter;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
import org.sonar.server.plugins.InstalledPluginReferentialFactory;
import org.sonar.server.plugins.ServerExtensionInstaller;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsBootstraper;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsStopper;
import org.sonar.server.property.InternalPropertiesImpl;
import org.sonar.server.qualitygate.QualityGateModule;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
// privileged plugins
CECoreExtensionsInstaller.class,
- PrivilegedPluginsBootstraper.class,
- PrivilegedPluginsStopper.class,
+ CoreExtensionBootstraper.class,
+ CoreExtensionStopper.class,
// Compute engine (must be after Views and Developer Cockpit)
CeConfigurationModule.class,
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info 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.plugin;
-
-import org.sonar.core.platform.ComponentContainer;
-
-/**
- * Interface implemented by the Extension point exposed by the Privileged plugin that serves as the unique access
- * point from the whole SQ instance into the Privileged plugin.
- */
-public interface PrivilegedPluginBridge {
-
- String getPluginName();
-
- /**
- * Bootstraps the plugin.
- *
- * @param parent the parent ComponentContainer which provides Platform components for the Privileged plugin to use.
- *
- * @throws IllegalStateException if called more than once
- */
- void startPlugin(ComponentContainer parent);
-
- /**
- * This method is called when Platform is shutting down.
- */
- void stopPlugin();
-
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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.extension;
+
+import java.util.List;
+import org.sonar.api.platform.Server;
+import org.sonar.api.platform.ServerStartHandler;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.utils.log.Profiler;
+import org.sonar.core.platform.ComponentContainer;
+
+import static java.lang.String.format;
+
+/**
+ * Startup task responsible to bootstrap installed Core Extensions (if any).
+ */
+public class CoreExtensionBootstraper implements ServerStartHandler {
+ private static final Logger LOGGER = Loggers.get(CoreExtensionBootstraper.class);
+
+ private final ComponentContainer componentContainer;
+
+ public CoreExtensionBootstraper(ComponentContainer componentContainer) {
+ this.componentContainer = componentContainer;
+ }
+
+ @Override
+ public void onServerStart(Server server) {
+ List<CoreExtensionBridge> bridges = componentContainer.getComponentsByType(CoreExtensionBridge.class);
+ for (CoreExtensionBridge bridge : bridges) {
+ Profiler profiler = Profiler.create(LOGGER).startInfo(format("Bootstrapping %s", bridge.getPluginName()));
+ bridge.startPlugin(componentContainer);
+ profiler.stopInfo();
+ }
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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.extension;
+
+import org.sonar.core.platform.ComponentContainer;
+
+/**
+ * Interface implemented by the Extension point exposed by the Core Extensions that serves as the unique access
+ * point from the whole SQ instance into the Core Extension.
+ */
+public interface CoreExtensionBridge {
+
+ String getPluginName();
+
+ /**
+ * Bootstraps the plugin.
+ *
+ * @param parent the parent ComponentContainer which provides Platform components for the Privileged plugin to use.
+ *
+ * @throws IllegalStateException if called more than once
+ */
+ void startPlugin(ComponentContainer parent);
+
+ /**
+ * This method is called when Platform is shutting down.
+ */
+ void stopPlugin();
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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.extension;
+
+import java.util.List;
+import org.picocontainer.Startable;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.utils.log.Profiler;
+import org.sonar.core.platform.ComponentContainer;
+
+import static java.lang.String.format;
+
+/**
+ * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the installed Core Extensions
+ * (if any).
+ */
+public class CoreExtensionStopper implements Startable {
+ private static final Logger LOGGER = Loggers.get(CoreExtensionStopper.class);
+
+ private final ComponentContainer platformContainer;
+
+ public CoreExtensionStopper(ComponentContainer platformContainer) {
+ this.platformContainer = platformContainer;
+ }
+
+ @Override
+ public void start() {
+ // nothing to do, privileged plugins are started by CoreExtensionBootstraper
+ }
+
+ @Override
+ public void stop() {
+ List<CoreExtensionBridge> bridges = platformContainer.getComponentsByType(CoreExtensionBridge.class);
+ for (CoreExtensionBridge bridge : bridges) {
+ Profiler profiler = Profiler.create(LOGGER).startInfo(format("Stopping %s", bridge.getPluginName()));
+ bridge.stopPlugin();
+ profiler.stopInfo();
+ }
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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.server.extension;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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.extension;
+
+import org.junit.Test;
+import org.sonar.api.platform.Server;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+public class CoreExtensionBootstraperTest {
+ private ComponentContainer componentContainer = new ComponentContainer();
+ private CoreExtensionBridge bridge = mock(CoreExtensionBridge.class);
+
+ private CoreExtensionBootstraper underTest = new CoreExtensionBootstraper(componentContainer);
+
+ @Test
+ public void onServerStart_calls_startPlugin_if_Bridge_exists_in_container() {
+ componentContainer.add(bridge);
+ componentContainer.startComponents();
+
+ underTest.onServerStart(mock(Server.class));
+
+ verify(bridge).getPluginName();
+ verify(bridge).startPlugin(componentContainer);
+ verifyNoMoreInteractions(bridge);
+ }
+
+ @Test
+ public void onServerStart_does_not_call_startPlugin_if_Bridge_does_not_exist_in_container() {
+ underTest.onServerStart(mock(Server.class));
+
+ verifyNoMoreInteractions(bridge);
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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.extension;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+public class CoreExtensionStopperTest {
+ private ComponentContainer componentContainer = new ComponentContainer();
+ private CoreExtensionBridge bridge = mock(CoreExtensionBridge.class);
+
+ private CoreExtensionStopper underTest = new CoreExtensionStopper(componentContainer);
+
+ @Test
+ public void stop_calls_stopPlugin_if_Bridge_exists_in_container() {
+ componentContainer.add(bridge);
+ componentContainer.startComponents();
+
+ underTest.stop();
+
+ verify(bridge).getPluginName();
+ verify(bridge).stopPlugin();
+ verifyNoMoreInteractions(bridge);
+ }
+
+ @Test
+ public void stop_does_not_call_stopPlugin_if_Bridge_does_not_exist_in_container() {
+ underTest.stop();
+
+ verifyNoMoreInteractions(bridge);
+ }
+}
import org.sonar.server.es.metadata.MetadataIndex;
import org.sonar.server.es.metadata.MetadataIndexDefinition;
import org.sonar.server.event.NewAlerts;
+import org.sonar.server.extension.CoreExtensionBootstraper;
+import org.sonar.server.extension.CoreExtensionStopper;
import org.sonar.server.favorite.FavoriteModule;
import org.sonar.server.health.NodeHealthModule;
import org.sonar.server.issue.AddTagsAction;
import org.sonar.server.plugins.PluginDownloader;
import org.sonar.server.plugins.PluginUninstaller;
import org.sonar.server.plugins.ServerExtensionInstaller;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsBootstraper;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsStopper;
import org.sonar.server.plugins.ws.AvailableAction;
import org.sonar.server.plugins.ws.CancelAllAction;
import org.sonar.server.plugins.ws.DownloadAction;
// Project badges
ProjectBadgesWsModule.class,
- // privileged plugins
+ // Core Extensions
WebCoreExtensionsInstaller.class,
- PrivilegedPluginsBootstraper.class,
- PrivilegedPluginsStopper.class,
+ CoreExtensionBootstraper.class,
+ CoreExtensionStopper.class,
// Compute engine (must be after Views and Developer Cockpit)
ReportAnalysisFailureNotificationModule.class,
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info 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.privileged;
-
-import java.util.List;
-import org.sonar.api.platform.Server;
-import org.sonar.api.platform.ServerStartHandler;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.utils.log.Profiler;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static java.lang.String.format;
-
-/**
- * Startup task to responsible to bootstrap installed Privileged plugins (if any).
- */
-public class PrivilegedPluginsBootstraper implements ServerStartHandler {
- private static final Logger LOGGER = Loggers.get(PrivilegedPluginsBootstraper.class);
-
- private final ComponentContainer componentContainer;
-
- public PrivilegedPluginsBootstraper(ComponentContainer componentContainer) {
- this.componentContainer = componentContainer;
- }
-
- @Override
- public void onServerStart(Server server) {
- List<PrivilegedPluginBridge> bridges = componentContainer.getComponentsByType(PrivilegedPluginBridge.class);
- for (PrivilegedPluginBridge bridge : bridges) {
- Profiler profiler = Profiler.create(LOGGER).startInfo(format("Bootstrapping %s", bridge.getPluginName()));
- bridge.startPlugin(componentContainer);
- profiler.stopInfo();
- }
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info 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.privileged;
-
-import java.util.List;
-import org.picocontainer.Startable;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.utils.log.Profiler;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static java.lang.String.format;
-
-/**
- * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the installed Privileged plugins
- * (if any) when its installed.
- */
-public class PrivilegedPluginsStopper implements Startable {
- private static final Logger LOGGER = Loggers.get(PrivilegedPluginsStopper.class);
-
- private final ComponentContainer platformContainer;
-
- public PrivilegedPluginsStopper(ComponentContainer platformContainer) {
- this.platformContainer = platformContainer;
- }
-
- @Override
- public void start() {
- // nothing to do, privileged plugins are started by PrivilegedPluginsBootstraper
- }
-
- @Override
- public void stop() {
- List<PrivilegedPluginBridge> bridges = platformContainer.getComponentsByType(PrivilegedPluginBridge.class);
- for (PrivilegedPluginBridge bridge : bridges) {
- Profiler profiler = Profiler.create(LOGGER).startInfo(format("Stopping %s", bridge.getPluginName()));
- bridge.stopPlugin();
- profiler.stopInfo();
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info 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.server.plugins.privileged;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info 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.privileged;
-
-import org.junit.Test;
-import org.sonar.api.platform.Server;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class PrivilegedPluginsBootstraperTest {
- private ComponentContainer componentContainer = new ComponentContainer();
- private PrivilegedPluginBridge bridge = mock(PrivilegedPluginBridge.class);
-
- private PrivilegedPluginsBootstraper underTest = new PrivilegedPluginsBootstraper(componentContainer);
-
- @Test
- public void onServerStart_calls_startPlugin_if_Bridge_exists_in_container() {
- componentContainer.add(bridge);
- componentContainer.startComponents();
-
- underTest.onServerStart(mock(Server.class));
-
- verify(bridge).getPluginName();
- verify(bridge).startPlugin(componentContainer);
- verifyNoMoreInteractions(bridge);
- }
-
- @Test
- public void onServerStart_does_not_call_startPlugin_if_Bridge_does_not_exist_in_container() {
- underTest.onServerStart(mock(Server.class));
-
- verifyNoMoreInteractions(bridge);
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info 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.privileged;
-
-import org.junit.Test;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class PrivilegedPluginsStopperTest {
- private ComponentContainer componentContainer = new ComponentContainer();
- private PrivilegedPluginBridge bridge = mock(PrivilegedPluginBridge.class);
-
- private PrivilegedPluginsStopper underTest = new PrivilegedPluginsStopper(componentContainer);
-
- @Test
- public void stop_calls_stopPlugin_if_Bridge_exists_in_container() {
- componentContainer.add(bridge);
- componentContainer.startComponents();
-
- underTest.stop();
-
- verify(bridge).getPluginName();
- verify(bridge).stopPlugin();
- verifyNoMoreInteractions(bridge);
- }
-
- @Test
- public void stop_does_not_call_stopPlugin_if_Bridge_does_not_exist_in_container() {
- underTest.stop();
-
- verifyNoMoreInteractions(bridge);
- }
-}
*/
private boolean compatibilityMode = false;
- private boolean privileged = false;
-
PluginClassLoaderDef(String basePluginKey) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(basePluginKey));
this.basePluginKey = basePluginKey;
this.compatibilityMode = b;
}
- boolean isPrivileged() {
- return privileged;
- }
-
- void setPrivileged(boolean privileged) {
- this.privileged = privileged;
- }
-
@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
for (PluginClassLoaderDef def : defs) {
builder.newClassloader(def.getBasePluginKey());
- if (def.isPrivileged()) {
- builder.setParent(def.getBasePluginKey(), baseClassLoader, new Mask());
- } else {
- builder.setParent(def.getBasePluginKey(), API_CLASSLOADER_KEY, new Mask());
- }
+ builder.setParent(def.getBasePluginKey(), API_CLASSLOADER_KEY, new Mask());
builder.setLoadingOrder(def.getBasePluginKey(), def.isSelfFirstStrategy() ? SELF_FIRST : PARENT_FIRST);
for (File jar : def.getFiles()) {
builder.addURL(def.getBasePluginKey(), fileToUrl(jar));
import java.io.Closeable;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import org.apache.commons.lang.SystemUtils;
import org.sonar.api.Plugin;
import org.sonar.api.utils.log.Loggers;
import org.sonar.updatecenter.common.Version;
import static java.util.Arrays.asList;
-import static java.util.Collections.unmodifiableSet;
/**
* Loads the plugin JAR files by creating the appropriate classloaders and by instantiating
public class PluginLoader {
private static final String[] DEFAULT_SHARED_RESOURCES = {"org/sonar/plugins", "com/sonar/plugins", "com/sonarsource/plugins"};
- /**
- * Defines the base keys (defined by {@link #basePluginKey(PluginInfo, Map)}) of the plugins which are allowed to
- * run a full server extensions.
- */
- private static final Set<String> PRIVILEGED_PLUGINS_BASE_KEYS = unmodifiableSet(new HashSet<>(asList("billing", "branch", "developer", "governance", "ha", "license")));
public static final Version COMPATIBILITY_MODE_MAX_VERSION = Version.create("5.2");
Version minSqVersion = info.getMinimalSqVersion();
boolean compatibilityMode = minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
def.setCompatibilityMode(compatibilityMode);
- def.setPrivileged(isPrivileged(baseKey));
if (compatibilityMode) {
Loggers.get(getClass()).debug("API compatibility mode is enabled on plugin {} [{}] " +
"(built with API lower than {})",
return classloadersByBasePlugin.values();
}
- private static boolean isPrivileged(String basePluginKey) {
- return PRIVILEGED_PLUGINS_BASE_KEYS.contains(basePluginKey);
- }
-
/**
* Instantiates collection of {@link org.sonar.api.Plugin} according to given metadata and classloaders
*
// TODO test mask - require change in sonar-classloader
}
- @Test
- public void plugin_is_recognised_as_privileged_if_key_is_views_and_extends_no_other_plugins() throws IOException {
- PluginInfo governance = createPluginInfo("governance");
-
- Collection<PluginClassLoaderDef> defs = loader.defineClassloaders(ImmutableMap.of("governance", governance));
-
- assertThat(defs.iterator().next().isPrivileged()).isTrue();
- }
-
@Test
public void plugin_is_not_recognised_as_system_extension_if_key_is_governance_and_extends_another_plugin() throws IOException {
PluginInfo foo = createPluginInfo("foo");
private static boolean isRunningInSQ() {
try {
- Class.forName("org.sonar.plugin.PrivilegedPluginBridge");
+ Class.forName("org.sonar.server.plugins.privileged.CoreExtensionBridge");
return true;
} catch (ClassNotFoundException e) {
return false;
private static boolean isRunningInSQ() {
try {
- Class.forName("org.sonar.plugin.PrivilegedPluginBridge");
+ Class.forName("org.sonar.server.plugins.privileged.CoreExtensionBridge");
return true;
} catch (ClassNotFoundException e) {
return false;