Package org.sonar.api
Class Plugin.Context
- java.lang.Object
-
- org.sonar.api.Plugin.Context
-
- Direct Known Subclasses:
PluginContextImpl
- Enclosing interface:
- Plugin
public static class Plugin.Context extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Context(SonarRuntime sonarRuntime)For unit tests only.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Plugin.ContextaddExtension(java.lang.Object extension)Plugin.ContextaddExtensions(java.lang.Object first, java.lang.Object second, java.lang.Object... others)Plugin.ContextaddExtensions(java.util.Collection extensions)ConfigurationgetBootConfiguration()The configuration that contains only the few properties required to bootstrap the process, for example: - conf/sonar.properties and persisted properties on web server and Compute Engine sides.java.util.ListgetExtensions()SonarRuntimegetRuntime()Runtime environment.VersiongetSonarQubeVersion()Shortcut ongetRuntime().getApiVersion()since version 6.0.
-
-
-
Constructor Detail
-
Context
public Context(SonarRuntime sonarRuntime)
For unit tests only. It's recommended to usePluginContextImpl.Builderto create instances ofPlugin.Context. The configuration returned by {@see #getBootConfiguration()} is empty.
-
-
Method Detail
-
getSonarQubeVersion
public Version getSonarQubeVersion()
Shortcut ongetRuntime().getApiVersion()since version 6.0.- Returns:
- the version of SonarQube API at runtime, not at compilation time
- Since:
- 5.5
- See Also:
getRuntime()
-
getRuntime
public SonarRuntime getRuntime()
Runtime environment. Can be use to add some extensions only on some conditions.- Since:
- 6.0
-
addExtension
public Plugin.Context addExtension(java.lang.Object extension)
Add an extension as :- a Class that is annotated with
ScannerSide,ServerSideorComputeEngineSide. The extension will be instantiated once. Its dependencies are injected through constructor parameters. - an instance that is annotated with
ScannerSide,ServerSideorComputeEngineSide.
- two MyExtension.class
- MyExtension.class and new MyExtension()
- a Class that is annotated with
-
addExtensions
public Plugin.Context addExtensions(java.util.Collection extensions)
- See Also:
addExtension(Object)
-
addExtensions
public Plugin.Context addExtensions(java.lang.Object first, java.lang.Object second, java.lang.Object... others)
- See Also:
addExtension(Object)
-
getExtensions
public java.util.List getExtensions()
-
getBootConfiguration
public Configuration getBootConfiguration()
The configuration that contains only the few properties required to bootstrap the process, for example: - conf/sonar.properties and persisted properties on web server and Compute Engine sides. The default values defined by plugins are ignored. - command-line arguments on scanner side. Default values or properties persisted in server are ignored.- Since:
- 7.1
-
-