List of usage examples for org.apache.commons.httpclient HttpConnectionManager setParams
public abstract void setParams(HttpConnectionManagerParams paramHttpConnectionManagerParams);
From source file:org.wso2.carbon.device.mgt.input.adapter.http.oauth.OAuthTokenValidaterStubFactory.java
/** * This created httpclient pool that can be used to connect to external entity. This connection can be configured * via broker.xml by setting up the required http connection parameters. * * @return an instance of HttpClient that is configured with MultiThreadedHttpConnectionManager *///from www . java 2 s . co m private HttpClient createHttpClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost( Integer.parseInt(globalProperties.get(HTTPEventAdapterConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST))); params.setMaxTotalConnections( Integer.parseInt(globalProperties.get(HTTPEventAdapterConstants.MAXIMUM_TOTAL_HTTP_CONNECTION))); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }
From source file:org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth.OAuthTokenValidaterStubFactory.java
/** * This created httpclient pool that can be used to connect to external entity. This connection can be configured * via broker.xml by setting up the required http connection parameters. * * @return an instance of HttpClient that is configured with MultiThreadedHttpConnectionManager *///from w ww. ja v a2 s. c o m private HttpClient createHttpClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(Integer.parseInt(eventAdapterConfiguration.getProperties() .get(HTTPEventAdapterConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST))); params.setMaxTotalConnections(Integer.parseInt(eventAdapterConfiguration.getProperties() .get(HTTPEventAdapterConstants.MAXIMUM_TOTAL_HTTP_CONNECTION))); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }
From source file:org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.OAuthTokenValidaterStubFactory.java
/** * This created httpclient pool that can be used to connect to external entity. This connection can be configured * via broker.xml by setting up the required http connection parameters. * * @return an instance of HttpClient that is configured with MultiThreadedHttpConnectionManager */// w ww . j a v a 2 s.co m private HttpClient createHttpClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(Integer.parseInt( tokenValidationProperties.getProperty(WebsocketConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST))); params.setMaxTotalConnections(Integer .parseInt(tokenValidationProperties.getProperty(WebsocketConstants.MAXIMUM_TOTAL_HTTP_CONNECTION))); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }
From source file:org.wso2.carbon.device.mgt.mobile.windows.api.common.authenticator.OAuthTokenValidationStubFactory.java
/** * Creates an instance of MultiThreadedHttpConnectionManager using HttpClient 3.x APIs * * @param properties Properties to configure MultiThreadedHttpConnectionManager * @return An instance of properly configured MultiThreadedHttpConnectionManager *//*from ww w. ja v a 2 s.c o m*/ private HttpConnectionManager createConnectionManager(Properties properties) { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Parameters required to initialize HttpClient instances " + "associated with OAuth token validation service stub are not provided"); } String maxConnectionsPerHostParam = properties .getProperty(PluginConstants.AuthenticatorProperties.MAX_CONNECTION_PER_HOST); if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) { if (log.isDebugEnabled()) { log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " + "which is 2, will be used"); } } else { params.setDefaultMaxConnectionsPerHost(Integer.parseInt(maxConnectionsPerHostParam)); } String maxTotalConnectionsParam = properties .getProperty(PluginConstants.AuthenticatorProperties.MAX_TOTAL_CONNECTIONS); if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) { if (log.isDebugEnabled()) { log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " + "which is 10, will be used"); } } else { params.setMaxTotalConnections(Integer.parseInt(maxTotalConnectionsParam)); } HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return connectionManager; }
From source file:org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.oauth.OAuthTokenValidaterStubFactory.java
/** * This created httpclient pool that can be used to connect to external entity. This connection can be configured * via broker.xml by setting up the required http connection parameters. * * @return an instance of HttpClient that is configured with MultiThreadedHttpConnectionManager *//* ww w. jav a 2 s .com*/ private HttpClient createHttpClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(Integer .parseInt(tokenValidationProperties.get(WebsocketConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST))); params.setMaxTotalConnections( Integer.parseInt(tokenValidationProperties.get(WebsocketConstants.MAXIMUM_TOTAL_HTTP_CONNECTION))); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }
From source file:org.wso2.carbon.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory.java
/** * Creates an instance of MultiThreadedHttpConnectionManager using HttpClient 3.x APIs * * @param properties Properties to configure MultiThreadedHttpConnectionManager * @return An instance of properly configured MultiThreadedHttpConnectionManager *///from w w w .jav a2s . c o m private HttpConnectionManager createConnectionManager(Properties properties) { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Parameters required to initialize HttpClient instances " + "associated with OAuth token validation service stub are not provided"); } String maxConnectionsPerHostParam = properties.getProperty("MaxConnectionsPerHost"); if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) { if (log.isDebugEnabled()) { log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " + "which is 2, will be used"); } } else { params.setDefaultMaxConnectionsPerHost(Integer.parseInt(maxConnectionsPerHostParam)); } String maxTotalConnectionsParam = properties.getProperty("MaxTotalConnections"); if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) { if (log.isDebugEnabled()) { log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " + "which is 10, will be used"); } } else { params.setMaxTotalConnections(Integer.parseInt(maxTotalConnectionsParam)); } HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return connectionManager; }
From source file:sos.scheduler.job.JobSchedulerHttpPostJob.java
public int postFile(File inputFile, String inputFileSpec, File outputFile, String contentType, String url) throws Exception { int rc = 0;//from ww w. j ava 2 s. c o m try { if (inputFile.isDirectory()) { Vector filelist = SOSFile.getFilelist(inputFile.getCanonicalPath(), inputFileSpec, 0); Iterator iterator = filelist.iterator(); while (iterator.hasNext()) { rc = this.postFile((File) iterator.next(), inputFileSpec, outputFile, contentType, url); } return rc; } else { PostMethod post = new PostMethod(url); String content = SOSFile.readFile(inputFile); getLogger().debug9("post before replacements: " + content); content = mergedVariables.substitute(content); getLogger().debug5("Posting: " + content); StringRequestEntity req = new StringRequestEntity(content); // post.setRequestEntity(new InputStreamRequestEntity(new FileInputStream(inputFile), inputFile.length())); post.setRequestEntity(req); post.setRequestHeader("Content-type", contentType); HttpClient httpClient = new HttpClient(); if (this.getTimeout() > 0) { HttpConnectionManager httpManager = httpClient.getHttpConnectionManager(); HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setConnectionTimeout(this.getTimeout() * 1000); httpManager.setParams(httpParams); } rc = httpClient.executeMethod(post); if (outputFile != null) logResponse(inputFile, outputFile, post.getResponseBodyAsStream()); return rc; } } catch (Exception e) { throw new Exception("error occurred in HTTP POST: " + e.getMessage()); } }
From source file:terrastore.client.connection.resteasy.HTTPConnectionFactory.java
public HTTPConnectionFactory() { HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setDefaultMaxConnectionsPerHost(Runtime.getRuntime().availableProcessors() * 10); httpParams.setMaxTotalConnections(Runtime.getRuntime().availableProcessors() * 10); HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager(); httpManager.setParams(httpParams); this.client = new HttpClient(httpManager); }
From source file:terrastore.integration.IntegrationTest.java
@BeforeClass public static void setUpClass() throws Exception { System.err.println("Waiting " + SETUP_TIME + " millis for system to set up ..."); Thread.sleep(SETUP_TIME);/* ww w . jav a 2s . c om*/ // HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setDefaultMaxConnectionsPerHost(100); httpParams.setMaxTotalConnections(100); HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager(); httpManager.setParams(httpParams); HTTP_CLIENT.setHttpConnectionManager(httpManager); }
From source file:terrastore.metrics.PerformanceTest.java
@BeforeClass public static void setUpClass() throws Exception { HTTP_CLIENT.setHttpConnectionManager(new MultiThreadedHttpConnectionManager()); System.err.println("Waiting " + SETUP_TIME + " millis for system to set up ..."); Thread.sleep(SETUP_TIME);/*from w w w. j a va2s . c o m*/ // HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setDefaultMaxConnectionsPerHost(100); httpParams.setMaxTotalConnections(100); HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager(); httpManager.setParams(httpParams); HTTP_CLIENT.setHttpConnectionManager(httpManager); }