Search in sources :

Example 1 with CompositeHttpConfigurer

use of org.apache.camel.component.weather.http.CompositeHttpConfigurer in project camel by apache.

the class WeatherComponent method createHttpClient.

private HttpClient createHttpClient(WeatherConfiguration configuration) {
    HttpConnectionManager connectionManager = configuration.getHttpConnectionManager();
    if (connectionManager == null) {
        connectionManager = new MultiThreadedHttpConnectionManager();
    }
    HttpClient httpClient = new HttpClient(connectionManager);
    if (configuration.getProxyHost() != null && configuration.getProxyPort() != null) {
        httpClient.getHostConfiguration().setProxy(configuration.getProxyHost(), configuration.getProxyPort());
    }
    if (configuration.getProxyAuthUsername() != null && configuration.getProxyAuthMethod() == null) {
        throw new IllegalArgumentException("Option proxyAuthMethod must be provided to use proxy authentication");
    }
    CompositeHttpConfigurer configurer = new CompositeHttpConfigurer();
    if (configuration.getProxyAuthMethod() != null) {
        configureProxyAuth(configurer, configuration.getProxyAuthMethod(), configuration.getProxyAuthUsername(), configuration.getProxyAuthPassword(), configuration.getProxyAuthDomain(), configuration.getProxyAuthHost());
    }
    configurer.configureHttpClient(httpClient);
    return httpClient;
}
Also used : HttpClient(org.apache.commons.httpclient.HttpClient) MultiThreadedHttpConnectionManager(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) HttpConnectionManager(org.apache.commons.httpclient.HttpConnectionManager) MultiThreadedHttpConnectionManager(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) CompositeHttpConfigurer(org.apache.camel.component.weather.http.CompositeHttpConfigurer)

Aggregations

CompositeHttpConfigurer (org.apache.camel.component.weather.http.CompositeHttpConfigurer)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 HttpConnectionManager (org.apache.commons.httpclient.HttpConnectionManager)1 MultiThreadedHttpConnectionManager (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)1