Package com.sun.jersey.client.apache4.config

Examples of com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config


        HttpClient httpClient = new HttpClientBuilder(metrics).using(configuration).build("dictionary");
        ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
        ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
        Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
        config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), validator));
        return new ApacheHttpClient4(handler, config);
    }
View Full Code Here


    private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) {
        HttpClient httpClient = new HttpClientBuilder().using(configuration).build();
        ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
        ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
        config.getSingletons().add(new JacksonMessageBodyProvider(new ObjectMapper(), new Validator()));
        return new ApacheHttpClient4(handler, config);
    }
View Full Code Here

    cm.setMaxTotal(1000);
    // Increase default max connection per route
    cm.setDefaultMaxPerRoute(1000);

    HttpClient httpClient = new DefaultHttpClient(cm);
    client = new ApacheHttpClient4(new ApacheHttpClient4Handler(httpClient, null, false), clientConfig);

    client.setReadTimeout(10000);
    //Experimental support for unix sockets:
    //client = new UnixSocketClient(clientConfig);
View Full Code Here

    cm.setMaxTotal(1000);
    // Increase default max connection per route
    cm.setDefaultMaxPerRoute(1000);

    HttpClient httpClient = new DefaultHttpClient(cm);
    client = new ApacheHttpClient4(new ApacheHttpClient4Handler(httpClient, null, false), clientConfig);

    client.setReadTimeout(10000);
    //Experimental support for unix sockets:
    //client = new UnixSocketClient(clientConfig);
View Full Code Here

    // obey JSSE defined system properties
    config.getProperties().put(ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER,
        new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault()));

    final ApacheHttpClient4 client = ApacheHttpClient4.create(config);

    // set UA
    client.getClientHandler().getHttpClient().getParams().setParameter(
        CoreProtocolPNames.USER_AGENT, "Nexus-Client/" + discoverClientVersion()
    );

    // "tweak" HTTPS scheme as requested
    final TrustStrategy trustStrategy;
    switch (connectionInfo.getSslCertificateValidation()) {
      case NONE:
        trustStrategy = new TrustStrategy()
        {
          @Override
          public boolean isTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
            return true;
          }
        };
        break;
      case LAX:
        trustStrategy = new TrustSelfSignedStrategy();
        break;
      default:
        trustStrategy = null;
    }

    final X509HostnameVerifier hostnameVerifier;
    switch (connectionInfo.getSslCertificateHostnameValidation()) {
      case NONE:
        hostnameVerifier = new AllowAllHostnameVerifier();
        break;
      case STRICT:
        hostnameVerifier = new StrictHostnameVerifier();
        break;
      default:
        hostnameVerifier = new BrowserCompatHostnameVerifier();
    }

    try {
      final SSLSocketFactory ssf = new SSLSocketFactory(trustStrategy, hostnameVerifier);
      final Scheme tweakedHttpsScheme = new Scheme("https", 443, ssf);
      client.getClientHandler().getHttpClient().getConnectionManager().getSchemeRegistry().register(tweakedHttpsScheme);
    }
    catch (Exception e) {
      Throwables.propagate(e);
    }

    // NXCM-4547 JERSEY-1293 Enforce proxy setting on httpclient
    enforceProxyUri(config, client);

    if (LOG.isDebugEnabled()) {
      client.addFilter(new LoggingFilter());
    }

    client.addFilter(new RequestFilters());

    return client;
  }
View Full Code Here

    when(proxyInfo.getProxyHost()).thenReturn("somehost");
    when(proxyInfo.getProxyPort()).thenReturn(8888);
    when(proxyInfo.getProxyProtocol()).thenReturn(HTTP);

    final ApacheHttpClient4 client = underTest.doCreateHttpClientFor(connection, xstream);

    assertThat(client.getClientHandler().getHttpClient().getParams().getParameter(ConnRoutePNames.DEFAULT_PROXY),
        (Matcher) allOf(
            Matchers.isA(HttpHost.class),
            Matchers.hasProperty("hostName", is("somehost")),
            Matchers.hasProperty("port", is(8888))
        ));
View Full Code Here

    cm.setMaxTotal(1000);
    // Increase default max connection per route
    cm.setDefaultMaxPerRoute(1000);

    HttpClient httpClient = new DefaultHttpClient(cm);
    client = new ApacheHttpClient4(new ApacheHttpClient4Handler(httpClient, null, false), clientConfig);

    client.setReadTimeout(10000);
    //Experimental support for unix sockets:
    //client = new UnixSocketClient(clientConfig);
View Full Code Here

    cm.setMaxTotal(1000);
    // Increase default max connection per route
    cm.setDefaultMaxPerRoute(1000);

    HttpClient httpClient = new DefaultHttpClient(cm);
    client = new ApacheHttpClient4(new ApacheHttpClient4Handler(httpClient, null, false), clientConfig);

    client.setReadTimeout(10000);
    //Experimental support for unix sockets:
    //client = new UnixSocketClient(clientConfig);
View Full Code Here

    private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) {
        HttpClient httpClient = new HttpClientBuilder().using(configuration).build();
        ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
        ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
        config.getSingletons().add(new JacksonMessageBodyProvider(new ObjectMapper(), new Validator()));
        return new ApacheHttpClient4(handler, config);
    }
View Full Code Here

    cm.setMaxTotal(1000);
    // Increase default max connection per route
    cm.setDefaultMaxPerRoute(1000);

    HttpClient httpClient = new DefaultHttpClient(cm);
    client = new ApacheHttpClient4(new ApacheHttpClient4Handler(httpClient, null, false), clientConfig);

    client.setReadTimeout(10000);
    //Experimental support for unix sockets:
    //client = new UnixSocketClient(clientConfig);
View Full Code Here

TOP

Related Classes of com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.