Example usage for org.apache.http.conn.routing HttpRoute toString

List of usage examples for org.apache.http.conn.routing HttpRoute toString

Introduction

In this page you can find the example usage for org.apache.http.conn.routing HttpRoute toString.

Prototype

@Override
public final String toString() 

Source Link

Document

Obtains a description of this route.

Usage

From source file:com.anaplan.client.transport.ApacheHttpProvider.java

protected ApacheHttpProvider() {
    super();/*from  ww w .j a v  a 2  s.  c  o m*/
    httpClient = new DefaultHttpClient();
    httpClient.getParams().setParameter(ClientPNames.HANDLE_AUTHENTICATION, Boolean.TRUE);
    httpClient.setCredentialsProvider(new ApacheCredentialsProvider());
    try {
        Class<?> engineClass = Class.forName("com.anaplan.client.transport.JCIFSEngine");
        final NTLMEngine ntlmEngine = (NTLMEngine) engineClass.newInstance();

        httpClient.getAuthSchemes().register("ntlm", new AuthSchemeFactory() {
            public AuthScheme newInstance(final HttpParams params) {
                return new NTLMScheme(ntlmEngine);
            }
        });
    } catch (InstantiationException instantiationException) {
        // Normal - the jcifs jar file is not present in the lib folder.
    } catch (Throwable thrown) {
        // Abnormal
        thrown.printStackTrace();
    }
    routePlanner = new ProxySelectorRoutePlanner(httpClient.getConnectionManager().getSchemeRegistry(),
            getProxySelector()) {
        private boolean suppressed;

        @Override
        public HttpRoute determineRoute(HttpHost target, HttpRequest request, HttpContext context)
                throws HttpException {
            HttpRoute httpRoute = super.determineRoute(target, request, context);
            if (getDebugLevel() >= 1 && !suppressed) {
                System.err.println(
                        httpRoute.toString() + " (" + getProxySelector().getClass().getSimpleName() + ")");
                if (getDebugLevel() == 1)
                    suppressed = true;
            }
            return httpRoute;
        }
    };
    httpClient.setRoutePlanner(routePlanner);
}