List of usage examples for org.apache.commons.httpclient.params HttpConnectionManagerParams HttpConnectionManagerParams
HttpConnectionManagerParams
From source file:org.wso2.carbon.device.mgt.extensions.remote.session.authentication.oauth.OAuthTokenValidatorStubFactory.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 w w . ja v a 2s . co m*/ private HttpClient createHttpClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(Integer .parseInt(tokenValidationProperties.get(RemoteSessionConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST))); params.setMaxTotalConnections(Integer .parseInt(tokenValidationProperties.get(RemoteSessionConstants.MAXIMUM_TOTAL_HTTP_CONNECTION))); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }
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 w w w . j a v a2 s . c o 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 ww w .j av a 2 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 *///from w ww .j av a2 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 */// ww w. java 2 s . co 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 *///from w ww.j av 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.event.output.adapter.soap.SoapEventAdapter.java
private HttpClient createMultiThreadedHttpConnectionManager(int connectionTimeOut, int maxConnectionPerHost) { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(maxConnectionPerHost); params.setConnectionTimeout(connectionTimeOut); MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); httpConnectionManager.setParams(params); return new HttpClient(httpConnectionManager); }
From source file:org.wso2.carbon.micro.integrator.core.internal.ServiceComponent.java
private ConfigurationContext getClientConfigurationContext() throws AxisFault { String clientRepositoryLocation = serverConfig.getFirstProperty(CLIENT_REPOSITORY_LOCATION); String clientAxis2XmlLocationn = serverConfig.getFirstProperty(CLIENT_AXIS2_XML_LOCATION); ConfigurationContext clientConfigContextToReturn = ConfigurationContextFactory .createConfigurationContextFromFileSystem(clientRepositoryLocation, clientAxis2XmlLocationn); MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); // Set the default max connections per host int defaultMaxConnPerHost = 500; Parameter defaultMaxConnPerHostParam = clientConfigContextToReturn.getAxisConfiguration() .getParameter("defaultMaxConnPerHost"); if (defaultMaxConnPerHostParam != null) { defaultMaxConnPerHost = Integer.parseInt((String) defaultMaxConnPerHostParam.getValue()); }/*from w ww . j a v a2 s .com*/ params.setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); // Set the max total connections int maxTotalConnections = 15000; Parameter maxTotalConnectionsParam = clientConfigContextToReturn.getAxisConfiguration() .getParameter("maxTotalConnections"); if (maxTotalConnectionsParam != null) { maxTotalConnections = Integer.parseInt((String) maxTotalConnectionsParam.getValue()); } params.setMaxTotalConnections(maxTotalConnections); params.setSoTimeout(600000); params.setConnectionTimeout(600000); httpConnectionManager.setParams(params); clientConfigContextToReturn.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, httpConnectionManager); // registerHouseKeepingTask(clientConfigContextToReturn); clientConfigContextToReturn.setProperty(ServerConstants.WORK_DIR, serverWorkDir); return clientConfigContextToReturn; }
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 */// ww w . j ava 2s . 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:org.wso2.esb.integration.common.utils.clients.axis2client.ConfigurationContextProvider.java
public ConfigurationContextProvider() { try {//from w w w . j av a 2 s.c o m MultiThreadedHttpConnectionManager httpConnectionManager; HttpClient httpClient; HttpConnectionManagerParams params; configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem( TestConfigurationProvider.getResourceLocation() + File.separator + "client", null); httpConnectionManager = new MultiThreadedHttpConnectionManager(); params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(25); httpConnectionManager.setParams(params); httpClient = new HttpClient(httpConnectionManager); configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE); } catch (AxisFault axisFault) { log.error(axisFault); } }