List of usage examples for org.apache.http.conn ClientConnectionManager getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.springframework.ws.transport.http.HttpComponentsMessageSender.java
/** * Sets the maximum number of connections allowed for the underlying HttpClient. * * @param maxTotalConnections the maximum number of connections allowed * @see ThreadSafeClientConnManager#setMaxTotal(int) */// w w w .j av a 2 s . c om public void setMaxTotalConnections(int maxTotalConnections) { if (maxTotalConnections <= 0) { throw new IllegalArgumentException("maxTotalConnections must be a positive value"); } ClientConnectionManager connectionManager = getHttpClient().getConnectionManager(); if (!(connectionManager instanceof ThreadSafeClientConnManager)) { throw new IllegalArgumentException( "maxTotalConnections is not supported on " + connectionManager.getClass().getName() + ". Use " + ThreadSafeClientConnManager.class.getName() + " instead"); } ((ThreadSafeClientConnManager) connectionManager).setMaxTotal(maxTotalConnections); }
From source file:org.springframework.ws.transport.http.HttpComponentsMessageSender.java
/** * Sets the maximum number of connections per host for the underlying HttpClient. The maximum number of connections * per host can be set in a form accepted by the {@code java.util.Properties} class, like as follows: * <p/>/*from www . j a va2 s .c om*/ * <pre> * https://www.example.com=1 * http://www.example.com:8080=7 * http://www.springframework.org=10 * </pre> * <p/> * The host can be specified as a URI (with scheme and port). * * @param maxConnectionsPerHost a properties object specifying the maximum number of connection * @see org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager#setMaxForRoute(org.apache.http.conn.routing.HttpRoute, * int) */ public void setMaxConnectionsPerHost(Map<String, String> maxConnectionsPerHost) throws URISyntaxException { ClientConnectionManager connectionManager = getHttpClient().getConnectionManager(); if (!(connectionManager instanceof ThreadSafeClientConnManager)) { throw new IllegalArgumentException( "maxConnectionsPerHost is not supported on " + connectionManager.getClass().getName() + ". Use " + ThreadSafeClientConnManager.class.getName() + " instead"); } for (Object o : maxConnectionsPerHost.keySet()) { String host = (String) o; URI uri = new URI(host); HttpHost httpHost = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); int maxHostConnections = Integer.parseInt(maxConnectionsPerHost.get(host)); ((ThreadSafeClientConnManager) connectionManager).setMaxForRoute(new HttpRoute(httpHost), maxHostConnections); } }
From source file:com.microsoft.exchange.impl.http.CustomHttpComponentsMessageSender.java
/** * Method to expose {@link ThreadSafeClientConnManager#setDefaultMaxPerRoute(int)} * Only sets the value if the {@link #getHttpClient()} is configured with a {@link ThreadSafeClientConnManager}. * /*from w ww .j av a2 s . c om*/ * @param defaultMaxPerRoute * @return true if the property was set */ protected boolean overrideDefaultMaxPerRoute(int defaultMaxPerRoute) { ClientConnectionManager connectionManager = getHttpClient().getConnectionManager(); if (connectionManager instanceof ThreadSafeClientConnManager) { ((ThreadSafeClientConnManager) connectionManager).setDefaultMaxPerRoute(defaultMaxPerRoute); return true; } else { logger.error( "ignoring call to overrideDefaultMaxPerRoute as existing ClientConnectionManager is not an instance of ThreadSafeClientConnManager: " + connectionManager.getClass()); return false; } }