]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3895 remove unused code and fix quality flaws
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 26 Oct 2012 22:29:44 +0000 (00:29 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 26 Oct 2012 22:29:44 +0000 (00:29 +0200)
25 files changed:
plugins/sonar-cobertura-plugin/pom.xml
plugins/sonar-jacoco-plugin/pom.xml
plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefireSensor.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java
sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchModuleTest.java [new file with mode: 0644]
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapExtensionExecutorTest.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/Plugins.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java
sonar-plugin-api/src/main/java/org/sonar/api/platform/ComponentContainer.java
sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginRepository.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/IocContainer.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java [deleted file]
sonar-server/src/main/java/org/sonar/server/platform/Platform.java
sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java
sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/system_updates.html.erb
sonar-server/src/test/java/org/sonar/server/plugins/DefaultServerPluginRepositoryTest.java

index bd9c6d1e54eb5cb3d461d9d2ed19798872e559bd..8533e1158d15c5ed264ac83979a01cd40da02ca7 100644 (file)
@@ -22,7 +22,6 @@
     <dependency>
       <groupId>org.codehaus.sonar-plugins.java</groupId>
       <artifactId>sonar-java-plugin</artifactId>
-      <type>sonar-plugin</type>
       <version>${sonarJava.version}</version>
       <scope>provided</scope>
     </dependency>
index 40f5e3afde63c6d16733d5fae14f87391bf2ecc5..985a5d5a0d53d98c6780747c56d090fd33b3a529 100644 (file)
@@ -63,7 +63,6 @@
     <dependency>
       <groupId>org.codehaus.sonar-plugins.java</groupId>
       <artifactId>sonar-java-plugin</artifactId>
-      <type>sonar-plugin</type>
       <version>${sonarJava.version}</version>
       <scope>provided</scope>
     </dependency>
index 1456df4c2591913d39336dfcfb10c9c587d82ed1..a6978f5d6a4eae79bbd3dbfadec34bdda9077cdc 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.plugins.surefire;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.AbstractCoverageExtension;
 import org.sonar.api.batch.CoverageExtension;
 import org.sonar.api.batch.DependsUpon;
 import org.sonar.api.batch.Sensor;
index f7db951df26994c61a4e4cf105ff4b57ef3f6311..e005e4f948f0bcc6c80d0c4203099c6c7ee68500 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.batch.bootstrap;
 
-import org.sonar.api.Plugins;
 import org.sonar.api.batch.InstantiationStrategy;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.ResourceTypes;
@@ -69,7 +68,6 @@ public class BatchModule extends Module {
     container.addSingleton(MemoryOptimizer.class);
     container.addSingleton(DefaultResourcePersister.class);
     container.addSingleton(SourcePersister.class);
-    container.addSingleton(Plugins.class);
     container.addSingleton(MeasuresDao.class);
     container.addSingleton(CacheRuleFinder.class);
     container.addSingleton(CacheMetricFinder.class);
index 69a74c8f91dead599915dcf44af4006698c3727a..64fbb25f8e7d90bfe2ac5aef3fe3e38e3c5c91e1 100644 (file)
@@ -99,29 +99,10 @@ public class BatchPluginRepository implements PluginRepository {
     }
   }
 
-  public Collection<Plugin> getPlugins() {
-    return pluginsByKey.values();
-  }
-
   public Plugin getPlugin(String key) {
     return pluginsByKey.get(key);
   }
 
-  public Map<String, Plugin> getPluginsByKey() {
-    return Collections.unmodifiableMap(pluginsByKey);
-  }
-
-  // TODO remove this method. Not used in batch.
-  public Property[] getProperties(Plugin plugin) {
-    if (plugin != null) {
-      Class<? extends Plugin> classInstance = plugin.getClass();
-      if (classInstance.isAnnotationPresent(Properties.class)) {
-        return classInstance.getAnnotation(Properties.class).value();
-      }
-    }
-    return new Property[0];
-  }
-
   public Collection<PluginMetadata> getMetadata() {
     return metadataByKey.values();
   }
index 8e75b5518191250ab765852260f6c85203909610..d170217cc389f313fc655433da8ec43335d67415 100644 (file)
@@ -139,7 +139,7 @@ public class JdbcDriverHolder {
         Class<?> lpClass = defineClass("org.sonar.batch.bootstrap.JdbcLeakPrevention", classBytes, 0, offset, this.getClass().getProtectionDomain());
         Object obj = lpClass.newInstance();
 
-        List<String> driverNames = (List<String>) obj.getClass().getMethod("clearJdbcDriverRegistrations").invoke(obj);
+        List<String> driverNames = (List<String>) obj.getClass().getMethod("unregisterDrivers").invoke(obj);
 
         for (String name : driverNames) {
           LOG.debug("To prevent a memory leak, the JDBC Driver [{}] has been forcibly deregistered", name);
index f067a2c08aeac959edd8b75bc840e3057622dbf2..001ecc3cf57237365da59a46a25120c612aeabf4 100644 (file)
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * Companion of {@link JdbcDriverHolder} and allows it to deregister JDBC drivers.
@@ -38,27 +39,33 @@ import java.util.List;
 public class JdbcLeakPrevention {
 
   /**
-   * @return list of names of deregistered drivers
+   * @return names of the drivers that have been unregistered
    */
-  public List<String> clearJdbcDriverRegistrations() throws SQLException {
-    List<String> driverNames = new ArrayList<String>();
-    HashSet<Driver> originalDrivers = new HashSet<Driver>();
+  public List<String> unregisterDrivers() throws SQLException {
+    Set<Driver> registeredDrivers = registeredDrivers();
+
+    List<String> unregisteredNames = new ArrayList<String>();
     Enumeration<Driver> drivers = DriverManager.getDrivers();
-    while (drivers.hasMoreElements()) {
-      originalDrivers.add(drivers.nextElement());
-    }
-    drivers = DriverManager.getDrivers();
     while (drivers.hasMoreElements()) {
       Driver driver = drivers.nextElement();
       if (driver.getClass().getClassLoader() != this.getClass().getClassLoader()) {
         continue;
       }
-      if (originalDrivers.contains(driver)) {
-        driverNames.add(driver.getClass().getCanonicalName());
+      if (registeredDrivers.contains(driver)) {
+        unregisteredNames.add(driver.getClass().getCanonicalName());
       }
       DriverManager.deregisterDriver(driver);
     }
-    return driverNames;
+    return unregisteredNames;
+  }
+
+  private Set<Driver> registeredDrivers() {
+    Set<Driver> registeredDrivers = new HashSet<Driver>();
+    Enumeration<Driver> drivers = DriverManager.getDrivers();
+    while (drivers.hasMoreElements()) {
+      registeredDrivers.add(drivers.nextElement());
+    }
+    return registeredDrivers;
   }
 
 }
index 105a3f693b5e7025b7143bb0bcc3c45b5accf719..fcafd4856a8a86c8f73c9632ffed8a2ccf11dbde 100644 (file)
  */
 package org.sonar.batch.bootstrap;
 
-import org.picocontainer.ComponentAdapter;
 import org.sonar.api.platform.ComponentContainer;
-import org.sonar.api.platform.PluginMetadata;
-
-import javax.annotation.Nullable;
-
-import java.util.List;
 
 /**
  * Module describes group of components - {@link #configure()}.
- * Several modules can be grouped together - {@link #install(Module)}, {@link #installChild(Module)}.
+ * Several modules can be grouped together - {@link #installChild(Module)}.
  * <p/>
  */
 public abstract class Module {
@@ -52,16 +46,6 @@ public abstract class Module {
     return this;
   }
 
-  /**
-   * Installs module into this module.
-   *
-   * @return this
-   */
-  public final Module install(Module module) {
-    module.init(container);
-    return this;
-  }
-
   /**
    * Installs module into new scope - see http://picocontainer.org/scopes.html
    *
index 13bde69f4dad60e025285e1a388c766343c57fc8..8ddbf991cf5a700c1a8f38b7978600aec5b64ddc 100644 (file)
@@ -27,7 +27,6 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.resources.Project;
-import org.sonar.api.utils.IocContainer;
 import org.sonar.batch.DefaultProfileLoader;
 import org.sonar.batch.DefaultProjectClasspath;
 import org.sonar.batch.DefaultProjectFileSystem2;
@@ -73,7 +72,6 @@ public class ProjectModule extends Module {
     container.addSingleton(project.getConfiguration());
     container.addSingleton(ProjectSettings.class);
     container.addSingleton(UnsupportedProperties.class);
-    container.addSingleton(IocContainer.class);
 
     for (Object component : projectDefinition.getContainerExtensions()) {
       container.addSingleton(component);
index f90c60d348069bdeae9cadde48c15a6ceb7ac6e2..de4ace57ffc029f54fcb826e560e71a2807f2380 100644 (file)
@@ -22,20 +22,18 @@ package org.sonar.batch.phases;
 import com.google.common.collect.Lists;
 import org.sonar.api.batch.SensorContext;
 import org.sonar.api.resources.Project;
-import org.sonar.batch.phases.ProjectInitializer;
 import org.sonar.batch.events.EventBus;
 import org.sonar.batch.index.DefaultIndex;
 import org.sonar.batch.index.PersistenceManager;
 
 import java.util.Collection;
-import java.util.List;
 
 public final class Phases {
 
   public static Collection<Class> getPhaseClasses() {
     return Lists.<Class>newArrayList(DecoratorsExecutor.class, MavenPhaseExecutor.class, MavenPluginsConfigurator.class,
-        PostJobsExecutor.class, SensorsExecutor.class,
-        InitializersExecutor.class, ProjectInitializer.class, UpdateStatusJob.class);
+      PostJobsExecutor.class, SensorsExecutor.class,
+      InitializersExecutor.class, ProjectInitializer.class, UpdateStatusJob.class);
   }
 
   private EventBus eventBus;
@@ -76,7 +74,7 @@ public final class Phases {
                 PersistenceManager persistenceManager, SensorContext sensorContext, DefaultIndex index,
                 EventBus eventBus, ProjectInitializer pi) {
     this(decoratorsExecutor, mavenPhaseExecutor, mavenPluginsConfigurator, initializersExecutor, postJobsExecutor,
-        sensorsExecutor, persistenceManager, sensorContext, index, eventBus, null, pi);
+      sensorsExecutor, persistenceManager, sensorContext, index, eventBus, null, pi);
   }
 
   /**
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchModuleTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchModuleTest.java
new file mode 100644 (file)
index 0000000..9f297a7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.batch.bootstrap;
+
+import org.junit.Test;
+import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.platform.ComponentContainer;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class BatchModuleTest {
+  @Test
+  public void should_register_batch_extensions() {
+    final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class);
+    Module bootstrapModule = new Module() {
+      @Override
+      protected void configure() {
+        // used to install project extensions
+        container.addSingleton(extensionInstaller);
+      }
+    };
+    bootstrapModule.init();
+    BatchModule module = new BatchModule();
+    bootstrapModule.installChild(module);
+
+    verify(extensionInstaller).install(any(ComponentContainer.class), eq(InstantiationStrategy.BATCH));
+    assertThat(module.container.getComponentByType(MetricProvider.class)).isNotNull();
+  }
+}
index 080e48c767c75ae0b49e76d5f0536cdf0a83b19f..c1a56e96f06f33bc51b949c14b225d56e2e34a1a 100644 (file)
@@ -62,7 +62,6 @@ public class BatchPluginRepositoryTest {
 
     repository.doStart(Arrays.asList(checkstyle));
 
-    assertThat(repository.getPlugins().size(), Matchers.is(1));
     assertThat(repository.getPlugin("checkstyle"), not(nullValue()));
     assertThat(repository.getMetadata().size(), Matchers.is(1));
     assertThat(repository.getMetadata("checkstyle").getName(), Matchers.is("Checkstyle"));
@@ -82,7 +81,6 @@ public class BatchPluginRepositoryTest {
 
     repository.doStart(Arrays.asList(checkstyle, checkstyleExt));
 
-    assertThat(repository.getPlugins().size(), Matchers.is(2));
     assertThat(repository.getPlugin("checkstyle"), not(nullValue()));
     assertThat(repository.getPlugin("checkstyleextensions"), not(nullValue()));
     assertThat(repository.getMetadata().size(), Matchers.is(2));
@@ -93,7 +91,7 @@ public class BatchPluginRepositoryTest {
   @Test
   public void shouldLoadPluginDeprecatedExtensions() throws IOException {
     RemotePlugin checkstyle = new RemotePlugin("checkstyle", true)
-        .addFilename("checkstyle-ext.xml");
+      .addFilename("checkstyle-ext.xml");
 
     PluginDownloader downloader = mock(PluginDownloader.class);
     when(downloader.downloadPlugin(checkstyle)).thenReturn(copyFiles("sonar-checkstyle-plugin-2.8.jar", "checkstyle-ext.xml"));
@@ -102,12 +100,11 @@ public class BatchPluginRepositoryTest {
 
     repository.doStart(Arrays.asList(checkstyle));
 
-    assertThat(repository.getPlugins().size(), Matchers.is(1));
     assertThat(repository.getPlugin("checkstyle"), not(nullValue()));
     assertThat(repository.getMetadata().size(), Matchers.is(1));
     assertThat(repository.getMetadata("checkstyle").getName(), Matchers.is("Checkstyle"));
     assertThat(repository.getMetadata("checkstyle").getDeployedFiles().size(), Matchers.is(5)); // plugin + 3 dependencies + 1 deprecated
-                                                                                                // extension
+    // extension
   }
 
   @Test
@@ -125,7 +122,6 @@ public class BatchPluginRepositoryTest {
 
     repository.doStart(Arrays.asList(checkstyle, checkstyleExt));
 
-    assertThat(repository.getPlugins().size(), Matchers.is(0));
     assertThat(repository.getMetadata().size(), Matchers.is(0));
   }
 
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapExtensionExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapExtensionExecutorTest.java
new file mode 100644 (file)
index 0000000..6ee1a68
--- /dev/null
@@ -0,0 +1,55 @@
+package org.sonar.batch.bootstrap;
+
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.picocontainer.Startable;
+import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.Settings;
+import org.sonar.api.platform.ComponentContainer;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class BootstrapExtensionExecutorTest {
+  private ProjectReactor reactor = new ProjectReactor(ProjectDefinition.create().setKey("foo"));
+
+  @Test
+  public void start() {
+    ComponentContainer container = new ComponentContainer();
+    // dependencies required for ProjectExclusions
+    container.addSingleton(reactor);
+    container.addSingleton(new Settings());
+
+    // declare a bootstrap component
+    final Startable bootstrapComponent = mock(Startable.class);
+    ExtensionInstaller installer = mock(ExtensionInstaller.class);
+    doAnswer(new Answer() {
+      public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
+        ComponentContainer childContainer = (ComponentContainer) invocationOnMock.getArguments()[0];
+        childContainer.addSingleton(bootstrapComponent);
+        return null;
+      }
+    }).when(installer).install(any(ComponentContainer.class), eq(InstantiationStrategy.BOOTSTRAP));
+
+    BootstrapExtensionExecutor executor = new BootstrapExtensionExecutor(container, installer);
+    executor.start();
+
+    // should install bootstrap components into a ephemeral container
+    verify(installer).install(any(ComponentContainer.class), eq(InstantiationStrategy.BOOTSTRAP));
+    verify(bootstrapComponent).start();
+    verify(bootstrapComponent).stop();
+
+    // the ephemeral container is destroyed
+    assertThat(container.getComponentByType(ProjectExclusions.class)).isNull();
+    assertThat(container.getChild()).isNull();
+  }
+
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Plugins.java b/sonar-plugin-api/src/main/java/org/sonar/api/Plugins.java
deleted file mode 100644 (file)
index 6cab9b9..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api;
-
-import org.sonar.api.platform.PluginRepository;
-
-import java.util.Collection;
-
-/**
- * Plugins dictionary. This class is for internal use
- * 
- * @since 1.10
- * @deprecated since 2.1
- */
-@Deprecated
-public class Plugins {
-
-  private PluginRepository pluginProvider;
-
-  /**
-   * Creates the dictionnary of plugins
-   */
-  public Plugins(PluginRepository pluginProvider) {
-    this.pluginProvider = pluginProvider;
-  }
-
-  /**
-   * Gives a collection of available plugins in the Sonar instance
-   */
-  public Collection<Plugin> getPlugins() {
-    return pluginProvider.getPlugins();
-  }
-
-  /**
-   * Returns a plugin based on its key
-   */
-  public Plugin getPlugin(String key) {
-    return pluginProvider.getPlugin(key);
-  }
-  /**
-   * Returns the list of properties of a plugin
-   */
-  public Property[] getProperties(Plugin plugin) {
-    return pluginProvider.getProperties(plugin);
-  }
-}
\ No newline at end of file
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java
deleted file mode 100644 (file)
index a9f2356..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.batch;
-
-import org.sonar.api.Plugins;
-import org.sonar.api.resources.Project;
-
-/**
- * This class implements the management of the code coverage engine if there are several.
- * It is a pre-implementation for Sensors and Decorators
- * 
- * @since 1.10
- * @deprecated since 2.6 was superseded by interface {@link CoverageExtension}
- */
-@Deprecated
-public abstract class AbstractCoverageExtension implements CoverageExtension {
-
-  /**
-   * The plugin key to retrieve the coverage engine to be used
-   */
-  public static final String PARAM_PLUGIN = "sonar.core.codeCoveragePlugin";
-
-  /**
-   * The default value for the code coverage plugin
-   */
-  public static final String DEFAULT_PLUGIN = "cobertura";
-
-  /**
-   * Default constructor
-   * 
-   * @param plugins the list of plugins available
-   * @deprecated since 2.3. Use the default constructor
-   */
-  @Deprecated
-  public AbstractCoverageExtension(Plugins plugins) {
-  }
-
-  public AbstractCoverageExtension() {
-  }
-
-  /**
-   * Whether to implement the extension on the project
-   */
-  public boolean shouldExecuteOnProject(Project project) {
-    return project.getAnalysisType().isDynamic(true);
-  }
-}
index fa03621d73305fe16abc8b3bba70a74ea84534ab..9f3a7f94e3e9212eac4712152544ddbb8e48e5a5 100644 (file)
@@ -34,7 +34,7 @@ import java.util.Properties;
  *
  * @since 2.9
  */
-public final class ProjectDefinition {
+public class ProjectDefinition {
 
   public static final String SOURCE_DIRS_PROPERTY = "sonar.sources";
   public static final String SOURCE_FILES_PROPERTY = "sonar.sourceFiles";
index 20ce3d21fbb65e0bf018157d57d8e3650dfc2815..7a4a971deea4242f4d5148a1edcb94cd3f2e9150 100644 (file)
  */
 package org.sonar.api.batch.bootstrap;
 
+import org.sonar.api.BatchComponent;
+
 import java.util.ArrayList;
 import java.util.List;
 
 /**
  * @since 2.9
  */
-public class ProjectReactor {
+public class ProjectReactor implements BatchComponent {
 
   private ProjectDefinition root;
 
index c95e320ac921561e1c35d25855309ca95157140b..b807fb30cf6631dbc6ed9e9bbf5b04a4a43f9afd 100644 (file)
@@ -154,13 +154,4 @@ public class ComponentContainer implements BatchComponent, ServerComponent {
   public ComponentContainer getChild() {
     return child;
   }
-
-  /**
-   * Warning - do not use. This method exists only for the backward-compatibility due to the suppression
-   * of {@link org.sonar.api.utils.IocContainer}
-   * @return
-   */
-  public MutablePicoContainer getPicoContainer() {
-    return pico;
-  }
 }
index 0acd4c40798b6c7bb30a14945fe2af77ebb9b875..f76d40def19e44a4e21ef5a9f54ac6993a99af65 100644 (file)
@@ -27,12 +27,8 @@ import org.sonar.api.ServerComponent;
 import java.util.Collection;
 
 public interface PluginRepository extends BatchComponent, ServerComponent {
-  Collection<Plugin> getPlugins();
-
   Plugin getPlugin(String key);
 
-  Property[] getProperties(Plugin plugin);
-
   /**
    * Metadata of installed plugins. Metadata includes all the fields available in update center
    * (plugin key, name, version, description, license, ...) and some technical information like
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/IocContainer.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/IocContainer.java
deleted file mode 100644 (file)
index 19ae894..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.utils;
-
-import org.picocontainer.Characteristics;
-import org.picocontainer.DefaultPicoContainer;
-import org.picocontainer.MutablePicoContainer;
-import org.picocontainer.behaviors.OptInCaching;
-import org.picocontainer.lifecycle.ReflectionLifecycleStrategy;
-import org.picocontainer.monitors.NullComponentMonitor;
-import org.sonar.api.platform.ComponentContainer;
-
-
-/**
- * Proxy to inject the container as a component$
- *
- * @since 1.10
- * @deprecated since 2.12. To be replaced by {@link org.sonar.api.platform.ComponentContainer}
- */
-@Deprecated
-public class IocContainer {
-  private final MutablePicoContainer pico;
-
-  public IocContainer(MutablePicoContainer pico) {
-    this.pico = pico;
-  }
-
-  public IocContainer(ComponentContainer container) {
-    this.pico = container.getPicoContainer();
-  }
-
-  public MutablePicoContainer getPicoContainer() {
-    return pico;
-  }
-
-  public static MutablePicoContainer buildPicoContainer() {
-    ReflectionLifecycleStrategy lifecycleStrategy = new ReflectionLifecycleStrategy(new
-        NullComponentMonitor(), "start", "stop", "dispose");
-
-    DefaultPicoContainer result = new DefaultPicoContainer(new OptInCaching(), lifecycleStrategy, null);
-    result.as(Characteristics.CACHE).addComponent(new IocContainer(result)); // for components that directly inject other components (eg Plugins)
-    return result;
-  }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java
deleted file mode 100644 (file)
index 35d3c1b..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.batch;
-
-import org.junit.Test;
-import org.sonar.api.resources.Project;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AbstractCoverageExtensionTest {
-
-  @Test
-  public void doNotExecuteIfStaticAnalysis() {
-    Project project = mock(Project.class);
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC);
-    FakeCoverageSensor sensor = new FakeCoverageSensor();
-
-    assertThat(sensor.shouldExecuteOnProject(project), is(false));
-  }
-
-  protected static class FakeCoverageSensor extends AbstractCoverageExtension {
-
-  }
-}
index eb261aa6f7a557d68b333ac6e545646ce15d9be0..23557e765744be3d3684c3791b7f37baa9e1a2e3 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.platform;
 
 import org.apache.commons.configuration.BaseConfiguration;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.Plugins;
 import org.sonar.api.config.EmailSettings;
 import org.sonar.api.platform.ComponentContainer;
 import org.sonar.api.platform.Server;
@@ -33,7 +32,6 @@ import org.sonar.api.resources.ResourceTypes;
 import org.sonar.api.rules.AnnotationRuleParser;
 import org.sonar.api.rules.XMLRuleParser;
 import org.sonar.api.utils.HttpDownloader;
-import org.sonar.api.utils.IocContainer;
 import org.sonar.api.utils.TimeProfiler;
 import org.sonar.api.utils.UriReader;
 import org.sonar.api.workflow.internal.DefaultWorkflow;
@@ -157,7 +155,6 @@ public final class Platform {
   private void startDatabaseConnectors(ServletContext servletContext) {
     rootContainer = new ComponentContainer();
     rootContainer.addSingleton(servletContext);
-    rootContainer.addSingleton(IocContainer.class); // for backward compatibility
     rootContainer.addSingleton(new BaseConfiguration());
     rootContainer.addSingleton(ServerSettings.class);
     rootContainer.addSingleton(ServerImpl.class);
@@ -219,7 +216,6 @@ public final class Platform {
     servicesContainer.addSingleton(ServerIdGenerator.class);
     servicesContainer.addSingleton(DefaultModelFinder.class); // depends on plugins
     servicesContainer.addSingleton(DefaultModelManager.class);
-    servicesContainer.addSingleton(Plugins.class);
     servicesContainer.addSingleton(ChartFactory.class);
     servicesContainer.addSingleton(Languages.class);
     servicesContainer.addSingleton(Views.class);
index 7ba9f79f6ed637ed4752cd4d1cf8058758ff9e8c..9b678016e9e983f9b624e123af7db5f007e55a21 100644 (file)
@@ -72,10 +72,6 @@ public class DefaultServerPluginRepository implements ServerPluginRepository {
     return disabledPlugins.contains(pluginKey);
   }
 
-  public Collection<Plugin> getPlugins() {
-    return pluginsByKey.values();
-  }
-
   public Plugin getPlugin(String key) {
     return pluginsByKey.get(key);
   }
@@ -98,18 +94,7 @@ public class DefaultServerPluginRepository implements ServerPluginRepository {
     return clazz;
   }
 
-
-  public Property[] getProperties(Plugin plugin) {
-    if (plugin != null) {
-      Class<? extends Plugin> classInstance = plugin.getClass();
-      if (classInstance.isAnnotationPresent(Properties.class)) {
-        return classInstance.getAnnotation(Properties.class).value();
-      }
-    }
-    return new Property[0];
-  }
-
-  public Collection<PluginMetadata> getMetadata() {
+public Collection<PluginMetadata> getMetadata() {
     return deployer.getMetadata();
   }
 
index a4f707b32f5f1bd86a0cfc039b4f5635edbf849e..11f0b26e8625a9b335c3ab688884dce80c79c559 100644 (file)
@@ -27,8 +27,8 @@
         </tr>
         </thead>
         <tbody>
-        <tr>
-          <td>System is up to date</td>
+        <tr class="even">
+          <td>System is up to date.</td>
         </tr>
         </tbody>
       </table>
index 39b991dd3e0c88ed94ff3f4fd962a6c8f1f3a3c9..0793b0b8e79c53781dbab96f176841c8389f9433 100644 (file)
@@ -66,7 +66,6 @@ public class DefaultServerPluginRepositoryTest {
     repository = new DefaultServerPluginRepository(deployer);
     repository.start();
 
-    assertThat(repository.getPlugins().size(), Is.is(1));
     assertThat(repository.getPlugin("artifactsize"), not(nullValue()));
     assertThat(repository.getClassLoader("artifactsize"), not(nullValue()));
     assertThat(repository.getClass("artifactsize", "org.sonar.plugins.artifactsize.ArtifactSizeMetrics"), not(nullValue()));