Search in sources :

Example 1 with RegistryHttpClient

use of org.apache.jena.http.RegistryHttpClient in project jena by apache.

the class Service method chooseHttpClient.

private static HttpClient chooseHttpClient(String serviceURL, Context context) {
    // [QExec] Done in HttpLib?
    // -- RegistryHttpClient : preferred way to set a custom HttpClient
    HttpClient httpClient = RegistryHttpClient.get().find(serviceURL);
    if (httpClient == null && context != null) {
        // Check for old setting.
        if (context.isDefined(oldQueryClient))
            LOGGER.warn("Deprecated context symbol " + oldQueryClient + ". See " + httpQueryClient + ".");
        Object client = context.get(httpQueryClient);
        if (client != null) {
            // Check for old HttpClient
            if (client.getClass().getName().equals("org.apache.http.client.HttpClient")) {
                LOGGER.warn("Found Apache HttpClient for context symbol " + httpQueryClient + ". Jena now uses java.net.http.HttpClient");
                client = null;
            } else if (client instanceof HttpClient) {
                httpClient = (HttpClient) client;
            } else {
                LOGGER.warn("Not recognized " + httpQueryClient + " -> " + client);
            }
        }
    }
    // -- Default : common case.
    if (httpClient == null)
        httpClient = HttpEnv.getDftHttpClient();
    return httpClient;
}
Also used : HttpClient(java.net.http.HttpClient) RegistryHttpClient(org.apache.jena.http.RegistryHttpClient)

Aggregations

HttpClient (java.net.http.HttpClient)1 RegistryHttpClient (org.apache.jena.http.RegistryHttpClient)1