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; 021 022/** 023 * Factory of extensions. It allows to dynamically create extensions depending upon runtime context. A use-case is 024 * to create one rule repository by language. 025 * 026 * <p>Notes : 027 * <ul> 028 * <li>the provider is declared in Plugin.getExtensions()</li> 029 * <li>the provider must also implement ServerExtension and/or BatchExtension</li> 030 * <li>the provider can accept dependencies (parameters) in its constructors.</li> 031 * <li>the method provide() is executed once by sonar</li> 032 * <li>the method provide() must return an object, a class or an Iterable of objects. <strong>Arrays are excluded</strong>.</li> 033 * </ul> 034 * </p> 035 * 036 * <p>Example: 037 * <pre> 038 * public class RuleRepositoryProvider extends ExtensionProvider implements ServerExtension { 039 * private Language[] languages; 040 * 041 * public RuleRepositoryProvider(Language[] languages) { 042 * this.languages = languages; 043 * } 044 * 045 * public List<RuleRepository> provide() { 046 * List<RuleRepository> result = new ArrayList<RuleRepository>(); 047 * for(Language language: languages) { 048 * result.add(new RuleRepository(..., language, ...)); 049 * } 050 * return result; 051 * } 052 * } 053 * </pre> 054 * </p> 055 * 056 * @since 2.3 057 */ 058public abstract class ExtensionProvider implements Extension { 059 060 public abstract Object provide(); 061}