Skip to content

Commit

Permalink
SONAR-6746 Drop Plugin interface + batch cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Jul 28, 2015
1 parent 1d15500 commit 70c24eb
Show file tree
Hide file tree
Showing 31 changed files with 68 additions and 446 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Maps;
import org.picocontainer.Startable;
import org.sonar.api.Plugin;
import org.sonar.api.server.ServerSide;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginRepository;

import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.picocontainer.Startable;
import org.sonar.api.SonarPlugin;
import org.sonar.api.server.ServerSide;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginRepository;

import static com.google.common.collect.Lists.newArrayList;

Expand Down Expand Up @@ -90,7 +89,7 @@ protected void findAvailableXMLFiles() {
contributingPluginKeyToClassLoader.put(DEFAULT_MODEL, getClass().getClassLoader());
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
String pluginKey = pluginInfo.getKey();
Plugin plugin = pluginRepository.getPluginInstance(pluginKey);
SonarPlugin plugin = pluginRepository.getPluginInstance(pluginKey);
ClassLoader classLoader = plugin.getClass().getClassLoader();
if (classLoader.getResource(getXMLFilePath(pluginKey)) != null) {
contributingPluginKeyToClassLoader.put(pluginKey, classLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import java.io.File;
import java.io.IOException;
import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.picocontainer.Startable;
import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginRepository;

import javax.annotation.Nullable;

import java.io.File;
import java.io.IOException;

/**
* Ruby on Rails requires the files to be on filesystem but not in Java classpath (JAR). This component extracts
* all the needed files from plugins and copy them to $SONAR_HOME/temp
Expand All @@ -62,7 +60,7 @@ public void start() {

for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
String pluginKey = pluginInfo.getKey();
Plugin plugin = pluginRepository.getPluginInstance(pluginKey);
SonarPlugin plugin = pluginRepository.getPluginInstance(pluginKey);
try {
deployRailsApp(appsDir, pluginKey, plugin.getClass().getClassLoader());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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.server.ServerSide;
import org.sonar.api.utils.AnnotationUtils;
import org.sonar.core.platform.ComponentContainer;
Expand All @@ -49,7 +49,7 @@ public void installExtensions(ComponentContainer container) {
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
try {
String pluginKey = pluginInfo.getKey();
Plugin plugin = pluginRepository.getPluginInstance(pluginKey);
SonarPlugin plugin = pluginRepository.getPluginInstance(pluginKey);
container.addExtension(pluginInfo, plugin);

for (Object extension : plugin.getExtensions()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import javax.annotation.Nonnull;
import org.apache.commons.io.FileUtils;
import org.picocontainer.Startable;
import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.api.platform.Server;
import org.sonar.api.platform.ServerUpgradeStatus;
import org.sonar.api.utils.MessageException;
Expand Down Expand Up @@ -83,7 +83,7 @@ public class ServerPluginRepository implements PluginRepository, Startable {

// following fields are available after startup
private final Map<String, PluginInfo> pluginInfosByKeys = new HashMap<>();
private final Map<String, Plugin> pluginInstancesByKeys = new HashMap<>();
private final Map<String, SonarPlugin> pluginInstancesByKeys = new HashMap<>();

public ServerPluginRepository(Server server, ServerUpgradeStatus upgradeStatus,
DefaultServerFileSystem fs, PluginLoader loader) {
Expand Down Expand Up @@ -348,8 +348,8 @@ public PluginInfo getPluginInfo(String key) {
}

@Override
public Plugin getPluginInstance(String key) {
Plugin plugin = pluginInstancesByKeys.get(key);
public SonarPlugin getPluginInstance(String key) {
SonarPlugin plugin = pluginInstancesByKeys.get(key);
if (plugin == null) {
throw new IllegalArgumentException(format("Plugin [%s] does not exist", key));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.api.config.License;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
Expand Down Expand Up @@ -285,7 +285,7 @@ public Object getCoreComponentByClassname(String className) {
}

public Object getComponentByClassname(String pluginKey, String className) {
Plugin plugin = get(PluginRepository.class).getPluginInstance(pluginKey);
SonarPlugin plugin = get(PluginRepository.class).getPluginInstance(pluginKey);
try {
Class componentClass = plugin.getClass().getClassLoader().loadClass(className);
return get(componentClass);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
38 changes: 0 additions & 38 deletions sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@
*/
package org.sonar.batch.bootstrap;

import com.google.common.io.Files;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;

import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.CharUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
Expand Down Expand Up @@ -82,7 +79,7 @@ public Map<String, PluginInfo> installRemotes() {
* @see org.sonar.batch.mediumtest.BatchMediumTester
*/
@Override
public Map<String, Plugin> installLocals() {
public Map<String, SonarPlugin> installLocals() {
return Collections.emptyMap();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.Map;
import org.picocontainer.Startable;
import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginLoader;
import org.sonar.core.platform.PluginRepository;

import java.util.Collection;
import java.util.Map;

/**
* Orchestrates the installation and loading of plugins
*/
Expand All @@ -38,7 +37,7 @@ public class BatchPluginRepository implements PluginRepository, Startable {
private final PluginInstaller installer;
private final PluginLoader loader;

private Map<String, Plugin> pluginInstancesByKeys;
private Map<String, SonarPlugin> pluginInstancesByKeys;
private Map<String, PluginInfo> infosByKeys;

public BatchPluginRepository(PluginInstaller installer, PluginLoader loader) {
Expand All @@ -52,7 +51,7 @@ public void start() {
pluginInstancesByKeys = Maps.newHashMap(loader.load(infosByKeys));

// this part is only used by tests
for (Map.Entry<String, Plugin> entry : installer.installLocals().entrySet()) {
for (Map.Entry<String, SonarPlugin> entry : installer.installLocals().entrySet()) {
String pluginKey = entry.getKey();
infosByKeys.put(pluginKey, new PluginInfo(pluginKey));
pluginInstancesByKeys.put(pluginKey, entry.getValue());
Expand Down Expand Up @@ -81,8 +80,8 @@ public PluginInfo getPluginInfo(String key) {
}

@Override
public Plugin getPluginInstance(String key) {
Plugin instance = pluginInstancesByKeys.get(key);
public SonarPlugin getPluginInstance(String key) {
SonarPlugin instance = pluginInstancesByKeys.get(key);
Preconditions.checkState(instance != null, String.format("Plugin [%s] does not exist", key));
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
package org.sonar.batch.bootstrap;

import java.util.List;

import javax.annotation.Nullable;

import org.sonar.api.ExtensionProvider;
import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.core.platform.PluginInfo;
Expand All @@ -51,7 +49,7 @@ public ExtensionInstaller install(ComponentContainer container, ExtensionMatcher

// plugin extensions
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin plugin = pluginRepository.getPluginInstance(pluginInfo.getKey());
SonarPlugin plugin = pluginRepository.getPluginInstance(pluginInfo.getKey());
for (Object extension : plugin.getExtensions()) {
doInstall(container, matcher, pluginInfo, extension);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@

import java.util.List;
import java.util.Map;

import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.utils.Durations;
import org.sonar.api.SonarPlugin;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
import org.sonar.batch.index.CachesManager;
Expand All @@ -41,8 +39,6 @@
import org.sonar.batch.repository.user.UserRepository;
import org.sonar.batch.scan.ProjectScanContainer;
import org.sonar.core.config.Logback;
import org.sonar.core.i18n.DefaultI18n;
import org.sonar.core.i18n.RuleI18nManager;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.core.platform.PluginClassloaderFactory;
import org.sonar.core.platform.PluginInfo;
Expand Down Expand Up @@ -82,7 +78,7 @@ private void addBootstrapComponents() {
BatchPluginPredicate.class,
ExtensionInstaller.class,

CachesManager.class,
CachesManager.class,
GlobalMode.class,
GlobalSettings.class,
ServerClient.class,
Expand All @@ -95,9 +91,6 @@ private void addBootstrapComponents() {
new PersistentCacheProvider(),
new WSLoaderGlobalProvider(),
System2.INSTANCE,
DefaultI18n.class,
Durations.class,
RuleI18nManager.class,
new GlobalRepositoriesProvider(),
UserRepository.class);
addIfMissing(BatchPluginInstaller.class, PluginInstaller.class);
Expand All @@ -121,7 +114,7 @@ protected void doAfterStart() {
private void installPlugins() {
PluginRepository pluginRepository = getComponentByType(PluginRepository.class);
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin instance = pluginRepository.getPluginInstance(pluginInfo.getKey());
SonarPlugin instance = pluginRepository.getPluginInstance(pluginInfo.getKey());
addExtension(pluginInfo, instance);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
*/
package org.sonar.batch.bootstrap;

import java.util.Map;
import org.sonar.api.SonarPlugin;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.Plugin;
import org.sonar.core.platform.PluginInfo;

import java.util.Map;

@BatchSide
public interface PluginInstaller {

Expand All @@ -39,5 +38,5 @@ public interface PluginInstaller {
* Used only by tests.
* @see org.sonar.batch.mediumtest.BatchMediumTester
*/
Map<String, Plugin> installLocals();
Map<String, SonarPlugin> installLocals();
}

This file was deleted.

23 changes: 0 additions & 23 deletions sonar-batch/src/main/java/org/sonar/batch/debt/package-info.java

This file was deleted.

Loading

0 comments on commit 70c24eb

Please sign in to comment.