001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program 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 * This program 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 License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api;
021
022import org.sonar.api.batch.BatchSide;
023import org.sonar.api.ce.ComputeEngineSide;
024import org.sonar.api.server.ServerSide;
025
026/**
027 * Factory of extensions. It allows to dynamically create extensions depending upon runtime context. One use-case is
028 * to create one rule repository by language.
029 *
030 * <p>Notes :
031 * <ul>
032 * <li>the provider is declared in Plugin.getExtensions()</li>
033 * <li>the provider must also add annotation {@link ServerSide}, {@link ComputeEngineSide} and/or {@link BatchSide}</li>
034 * <li>the provider can accept dependencies (parameters) in its constructors.</li>
035 * <li>the method provide() is executed once by the platform</li>
036 * <li>the method provide() must return an object, a class or an Iterable of objects. <strong>Arrays are excluded</strong>.</li>
037 * </ul>
038 * 
039 *
040 * <p>Example:
041 * <pre>
042 * {@code
043 * {@literal @}ServerSide
044 * public class RuleRepositoryProvider extends ExtensionProvider {
045 *   private Language[] languages;
046 *
047 *   public RuleRepositoryProvider(Language[] languages) {
048 *     this.languages = languages;
049 *   }
050 *
051 *   public List<RuleRepository> provide() {
052 *     List<RuleRepository> result = new ArrayList<RuleRepository>();
053 *     for(Language language: languages) {
054 *       result.add(new RuleRepository(..., language, ...));
055 *     }
056 *     return result;
057 *   }
058 * }
059 * }
060 * </pre>
061 * 
062 *
063 * @since 2.3
064 * @deprecated since 6.0 should no more be used
065 */
066@Deprecated
067@ExtensionPoint
068public abstract class ExtensionProvider {
069
070  public abstract Object provide();
071}