.build(); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
.build(); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
private ApacheHttpClient4Engine createEngine() { PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build(); cm.setMaxTotal(200); // Increase max total connection to 200 cm.setDefaultMaxPerRoute(20); // Increase default max connection per route to 20 ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient); return engine; }
public static ClientHttpEngine create(HttpClient httpClient, HttpContext httpContext) { if(isUsingOldStyleConfiguration(httpClient)) { return new ApacheHttpClient4Engine(httpClient,httpContext); } else { return new ApacheHttpClient43Engine(httpClient, httpContext); } }
public static ClientHttpEngine create(HttpClient httpClient) { if(isUsingOldStyleConfiguration(httpClient)) { return new ApacheHttpClient4Engine(httpClient); } else { return new ApacheHttpClient43Engine(httpClient); } }
public static ClientHttpEngine create(HttpClient httpClient, boolean closeHttpClient) { if(isUsingOldStyleConfiguration(httpClient)) { return new ApacheHttpClient4Engine(httpClient,closeHttpClient); } else { return new ApacheHttpClient43Engine(httpClient, closeHttpClient); } }
public static ClientHttpEngine create(HttpClient httpClient, HttpContext httpContext) { if(isUsingOldStyleConfiguration(httpClient)) { return new ApacheHttpClient4Engine(httpClient,httpContext); } else { return new ApacheHttpClient43Engine(httpClient, httpContext); } }
public static ClientHttpEngine create(HttpClient httpClient, boolean closeHttpClient) { if(isUsingOldStyleConfiguration(httpClient)) { return new ApacheHttpClient4Engine(httpClient,closeHttpClient); } else { return new ApacheHttpClient43Engine(httpClient, closeHttpClient); } }
public static ClientHttpEngine create(HttpClient httpClient) { if(isUsingOldStyleConfiguration(httpClient)) { return new ApacheHttpClient4Engine(httpClient); } else { return new ApacheHttpClient43Engine(httpClient); } }
// create here a normal Apache HttpClient with all parameters, that you need HttpClient httpClient = createHttpClient(connectTimeout, socketTimeout, connectionRequestTimeout, maxTotalHTTPConnections); // Deprecated Apache classes cleanup https://issues.jboss.org/browse/RESTEASY-1357 // Client Framework not honoring connection timeouts Apache Client 4.3 https://issues.jboss.org/browse/RESTEASY-975 ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient) { @Override protected void loadHttpMethod(ClientInvocation request, HttpRequestBase httpMethod) throws Exception { super.loadHttpMethod(request, httpMethod); httpMethod.setParams(new BasicHttpParams()); } }; return new ResteasyClientBuilder().httpEngine(engine).build();
public static ClientHttpEngine createWithDefaultProxy(HttpHost defaultProxy) { if(isConfigurableAvailable()) { ApacheHttpClient4Engine engine = new ApacheHttpClient43Engine(defaultProxy); //We have to check that the HttpClient to be used has the configurable interface if(isUsingOldStyleConfiguration(engine.getHttpClient())) { LogMessages.LOGGER.warn(Messages.MESSAGES.pleaseConsiderUnpdating()); engine.close(); return new ApacheHttpClient4Engine(defaultProxy); } return engine; } else { return new ApacheHttpClient4Engine(defaultProxy); } }
public KubernetesAPI createAPI(URI uri, String userName, String password) { // Configure HttpClient to authenticate preemptively // by prepopulating the authentication data cache. // http://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html/RESTEasy_Client_Framework.html#transport_layer // http://hc.apache.org/httpcomponents-client-4.2.x/tutorial/html/authentication.html#d5e1032 HttpHost targetHost = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getCredentialsProvider().setCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials(userName, password)); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local auth cache BasicScheme basicAuth = new BasicScheme(); authCache.put(targetHost, basicAuth); // Add AuthCache to the execution context BasicHttpContext localcontext = new BasicHttpContext(); localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); // 4. Create client executor and proxy ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpclient, localcontext); ResteasyClient client = new ResteasyClientBuilder().connectionPoolSize(connectionPoolSize).httpEngine(engine) .build(); client.register(JacksonJaxbJsonProvider.class).register(JacksonConfig.class); ProxyBuilder<KubernetesAPI> proxyBuilder = client.target(uri).proxyBuilder(KubernetesAPI.class); if (classLoader != null) { proxyBuilder = proxyBuilder.classloader(classLoader); } return proxyBuilder.build(); }
public static ClientHttpEngine createWithDefaultProxy(HttpHost defaultProxy) { if(isConfigurableAvailable()) { ApacheHttpClient4Engine engine = new ApacheHttpClient43Engine(defaultProxy); //We have to check that the HttpClient to be used has the configurable interface if(isUsingOldStyleConfiguration(engine.getHttpClient())) { LogMessages.LOGGER.warn(Messages.MESSAGES.pleaseConsiderUnpdating()); engine.close(); return new ApacheHttpClient4Engine(defaultProxy); } return engine; } else { return new ApacheHttpClient4Engine(defaultProxy); } }
@Override public Client create(final RestClientConfiguration configuration) { checkNotNull(configuration); try (TcclBlock tccl = TcclBlock.begin(ResteasyClientBuilder.class)) { HttpContext httpContext = new BasicHttpContext(); if (configuration.getUseTrustStore()) { httpContext.setAttribute(SSLContextSelector.USE_TRUST_STORE, true); } HttpClient client; if (configuration.getHttpClient() != null) { client = checkNotNull(configuration.getHttpClient().get()); } else { client = httpClient.get(); } ClientHttpEngine httpEngine = new ApacheHttpClient4Engine(client, httpContext); ResteasyClientBuilder builder = new ResteasyClientBuilder().httpEngine(httpEngine); if (configuration.getCustomizer() != null) { configuration.getCustomizer().apply(builder); } return builder.build(); } }
.build(); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
.build(); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
.build(); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
@Override public RestClient createClient() { ClientConnectionManager cm = new PoolingClientConnectionManager(); HttpClient httpClient = new DefaultHttpClient(cm); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient); ResteasyClient client = new ResteasyClientBuilder().register(RestEasyDelegateJacksonProvider.class).httpEngine(engine).build(); registerComponents(client, definition.getComponents()); ResteasyWebTarget target = client.target(definition.getBaseUrl()); if (definition.isCacheable()) { target.register(BrowserCacheFeature.class); } return new RestEasyClient(target, definition); }
HttpConnectionParams.setSoKeepalive(params, true); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
private ResteasyClient getClient(UserCredentials userCredentials) { ClientHttpEngine httpEngine = new ApacheHttpClient4Engine(createHttpClient()); ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine).build(); if (userCredentials != null) { client.register(new BasicAuthentication(userCredentials.getUsername(), PassEncoder.decodeAsString(userCredentials.getPassword()))); } return client; }