001/*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2012 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019 */
020package org.sonar.api.batch;
021
022import org.sonar.api.BatchExtension;
023import org.sonar.api.resources.Project;
024
025/**
026 * <p>
027 * A Sensor is invoked once during the analysis of a project. The sensor can parse a flat file, connect to a web server... Sensor are
028 * generally used to add measure at the lowest level of the resource tree. A sensor can access and save measures on the whole tree of
029 * resources.
030 * </p>
031 * 
032 * <p>
033 * For example the Cobertura Sensor parses Cobertura report and saves the first-level of measures on resources.
034 * </p>
035 * 
036 * <p>
037 * A particular attention should be given to resource exclusion. Sonar already manages exclusions at file level : if you try to save a
038 * measure on a resource that is excluded in the settings, then Sonar will not save the measure. When handling a plugin or an external tool,
039 * you should make sure that exclusions are passed if you are going to get back consolidated data.
040 * </p>
041 * 
042 * @since 1.10
043 */
044public interface Sensor extends BatchExtension, CheckProject {
045
046  /**
047   * Sensors that depend upon Squid must declare the following method :
048   * 
049   * <pre>
050   * &#064;DependsUpon
051   * public String dependsUponSquidAnalysis() {
052   *   return Sensor.FLAG_SQUID_ANALYSIS;
053   * }
054   * </pre>
055   */
056  String FLAG_SQUID_ANALYSIS = "squid";
057
058  /**
059   * The method that is going to be run when the sensor is called
060   * 
061   * @param project the project the sensor runs on
062   * @param context the context
063   */
064  void analyse(Project project, SensorContext context);
065
066}