Interface LocalConnector


  • public interface LocalConnector
    This class allows a web service to call another web service through the sonar-ws library. The call is in-process, synchronous and does not involve the HTTP stack.

    Example of a web service that loads some issues:

     import org.sonar.api.server.ws.RequestHandler;
     import org.sonarqube.ws.client.WsClientFactories;
    
     public class MyRequestHandler implements RequestHandler {
       @Override
       public void handle(Request request, Response response) {
         WsClient wsClient = WsClientFactories.getLocal().newClient(request.localConnector());
         SearchWsResponse issues = wsClient.issues().search(new SearchWsRequest());
         // ...
       }
     }
     

    It requires to use the sonar-ws library which Maven ids are:

       <dependency>
         <groupId>org.sonarsource.sonarqube</groupId>
         <artifactId>sonar-ws</artifactId>
       </dependency>
     
    Since:
    5.5