Package org.sonar.api
Class Plugin.Context
- java.lang.Object
-
- org.sonar.api.Plugin.Context
-
- 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 Deprecated Methods Modifier and Type Method Description Plugin.Context
addExtension(java.lang.Object extension)
Plugin.Context
addExtensions(java.lang.Object first, java.lang.Object second, java.lang.Object... others)
Plugin.Context
addExtensions(java.util.Collection extensions)
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.java.util.List
getExtensions()
SonarRuntime
getRuntime()
Runtime environment.Version
getSonarQubeVersion()
Deprecated.since 10.0.
-
-
-
Constructor Detail
-
Context
public Context(SonarRuntime sonarRuntime)
For unit tests only. It's recommended to useorg.sonar.api.internal.PluginContextImpl.Builder
to create instances ofPlugin.Context
. The configuration returned by {@see #getBootConfiguration()} is empty.
-
-
Method Detail
-
getSonarQubeVersion
@Deprecated(since="10.0") public Version getSonarQubeVersion()
Deprecated.since 10.0. The name is confusing: the API version is different from the SonarQube version since the extraction. Use the advised replacementShortcut 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 used 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
,ServerSide
orComputeEngineSide
. The extension will be instantiated once. Its dependencies are injected through constructor parameters. - an instance that is annotated with
ScannerSide
,ServerSide
orComputeEngineSide
.
- 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
-
-