You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ExtensionProvider.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.api;
  21. import org.sonar.api.ce.ComputeEngineSide;
  22. import org.sonar.api.server.ServerSide;
  23. /**
  24. * Factory of extensions. It allows to dynamically create extensions depending upon runtime context. One use-case is
  25. * to create one rule repository by language.
  26. *
  27. * <p>Notes :
  28. * <ul>
  29. * <li>the provider is declared in Plugin.getExtensions()</li>
  30. * <li>the provider must also add annotation {@link ServerSide}, {@link ComputeEngineSide} and/or {@link BatchSide}</li>
  31. * <li>the provider can accept dependencies (parameters) in its constructors.</li>
  32. * <li>the method provide() is executed once by the platform</li>
  33. * <li>the method provide() must return an object, a class or an Iterable of objects. <strong>Arrays are excluded</strong>.</li>
  34. * </ul>
  35. *
  36. *
  37. * <p>Example:
  38. * <pre>
  39. * {@code
  40. * {@literal @}ServerSide
  41. * public class RuleRepositoryProvider extends ExtensionProvider {
  42. * private Language[] languages;
  43. *
  44. * public RuleRepositoryProvider(Language[] languages) {
  45. * this.languages = languages;
  46. * }
  47. *
  48. * public List<RuleRepository> provide() {
  49. * List<RuleRepository> result = new ArrayList<RuleRepository>();
  50. * for(Language language: languages) {
  51. * result.add(new RuleRepository(..., language, ...));
  52. * }
  53. * return result;
  54. * }
  55. * }
  56. * }
  57. * </pre>
  58. *
  59. *
  60. * @since 2.3
  61. * @deprecated since 6.0 should no more be used
  62. */
  63. @Deprecated
  64. @ExtensionPoint
  65. public abstract class ExtensionProvider {
  66. public abstract Object provide();
  67. }