List of usage examples for org.apache.http.params HttpConnectionParams setStaleCheckingEnabled
public static void setStaleCheckingEnabled(HttpParams httpParams, boolean z)
From source file:org.rhq.modules.plugins.wildfly10.ASConnection.java
public ASConnection(ASConnectionParams params) { asConnectionParams = params;//ww w.j a va 2 s . co m // Check and store the basic parameters if (asConnectionParams.getHost() == null) { throw new IllegalArgumentException("Management host cannot be null."); } if (asConnectionParams.getPort() <= 0 || asConnectionParams.getPort() > 65535) { throw new IllegalArgumentException("Invalid port: " + asConnectionParams.getPort()); } UsernamePasswordCredentials credentials = null; if (asConnectionParams.getUsername() != null && asConnectionParams.getPassword() != null) { credentials = new UsernamePasswordCredentials(asConnectionParams.getUsername(), asConnectionParams.getPassword()); } keepAliveTimeout = asConnectionParams.getKeepAliveTimeout(); managementUri = buildManagementUri(); // Each ASConnection instance will have its own HttpClient instance. Setup begins here SchemeRegistry schemeRegistry = new SchemeRegistryBuilder(asConnectionParams).buildSchemeRegistry(); // HttpClient will use a pooling connection manager to allow concurrent request processing PoolingClientConnectionManager httpConnectionManager = new PoolingClientConnectionManager(schemeRegistry); httpConnectionManager.setDefaultMaxPerRoute(MAX_POOLED_CONNECTIONS); httpConnectionManager.setMaxTotal(MAX_POOLED_CONNECTIONS); httpClient = new DefaultHttpClient(httpConnectionManager); HttpParams httpParams = httpClient.getParams(); // Disable stale connection checking on connection lease to get better performance // See http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html HttpConnectionParams.setStaleCheckingEnabled(httpParams, false); httpClient.setReuseStrategy(new CustomConnectionReuseStrategy(this)); if (keepAliveTimeout > 0) { httpClient.setKeepAliveStrategy(new CustomConnectionKeepAliveStrategy(this)); // Initial schedule of a cleaning task. Subsequent executions will be scheduled as needed. // See ConnectionManagerCleaner implementation. cleanerExecutor.schedule(new ConnectionManagerCleaner(this), keepAliveTimeout / 2, TimeUnit.MILLISECONDS); } HttpClientParams.setRedirecting(httpParams, false); if (credentials != null) { httpClient.getCredentialsProvider().setCredentials( new AuthScope(asConnectionParams.getHost(), asConnectionParams.getPort()), credentials); } mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); shutdown = false; }