Search in sources :

Example 1 with CompositeHttpConfigurer

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

the class GeoCoderEndpoint method createGeocoder.

Geocoder createGeocoder() throws InvalidKeyException {
    HttpConnectionManager connectionManager = this.httpConnectionManager;
    if (connectionManager == null) {
        connectionManager = new MultiThreadedHttpConnectionManager();
    }
    HttpClient httpClient = new HttpClient(connectionManager);
    if (proxyHost != null && proxyPort != null) {
        httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort);
    }
    // validate that if proxy auth username is given then the proxy auth method is also provided
    if (proxyAuthUsername != null && proxyAuthMethod == null) {
        throw new IllegalArgumentException("Option proxyAuthMethod must be provided to use proxy authentication");
    }
    CompositeHttpConfigurer configurer = new CompositeHttpConfigurer();
    if (proxyAuthMethod != null) {
        configureProxyAuth(configurer, proxyAuthMethod, proxyAuthUsername, proxyAuthPassword, proxyAuthDomain, proxyAuthHost);
    }
    if (httpClientConfigurer != null) {
        configurer.addConfigurer(httpClientConfigurer);
    }
    configurer.configureHttpClient(httpClient);
    Geocoder geocoder;
    if (clientId != null) {
        geocoder = new AdvancedGeoCoder(httpClient, clientId, clientKey);
    } else {
        geocoder = new AdvancedGeoCoder(httpClient);
    }
    return geocoder;
}
Also used : HttpClient(org.apache.commons.httpclient.HttpClient) AdvancedGeoCoder(com.google.code.geocoder.AdvancedGeoCoder) MultiThreadedHttpConnectionManager(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) HttpConnectionManager(org.apache.commons.httpclient.HttpConnectionManager) MultiThreadedHttpConnectionManager(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) CompositeHttpConfigurer(org.apache.camel.component.geocoder.http.CompositeHttpConfigurer) Geocoder(com.google.code.geocoder.Geocoder)

Aggregations

AdvancedGeoCoder (com.google.code.geocoder.AdvancedGeoCoder)1 Geocoder (com.google.code.geocoder.Geocoder)1 CompositeHttpConfigurer (org.apache.camel.component.geocoder.http.CompositeHttpConfigurer)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 HttpConnectionManager (org.apache.commons.httpclient.HttpConnectionManager)1 MultiThreadedHttpConnectionManager (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)1