本文整理匯總了Java中org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.setParams方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiThreadedHttpConnectionManager.setParams方法的具體用法?Java MultiThreadedHttpConnectionManager.setParams怎麽用?Java MultiThreadedHttpConnectionManager.setParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
的用法示例。
在下文中一共展示了MultiThreadedHttpConnectionManager.setParams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initHttpClient
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
protected void initHttpClient() {
if (MockServer.isTestMode()) {
return;
}
HostConfiguration hostConfiguration = new HostConfiguration();
hostConfiguration.setHost(diamondConfigure.getDomainNameList().get(this.domainNamePos.get()),
diamondConfigure.getPort());
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.closeIdleConnections(diamondConfigure.getPollingIntervalTime() * 4000);
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setStaleCheckingEnabled(diamondConfigure.isConnectionStaleCheckingEnabled());
params.setMaxConnectionsPerHost(hostConfiguration, diamondConfigure.getMaxHostConnections());
params.setMaxTotalConnections(diamondConfigure.getMaxTotalConnections());
params.setConnectionTimeout(diamondConfigure.getConnectionTimeout());
// 設置讀超時為1分鍾,
// [email protected]
params.setSoTimeout(60 * 1000);
connectionManager.setParams(params);
httpClient = new HttpClient(connectionManager);
httpClient.setHostConfiguration(hostConfiguration);
}
示例2: FullTextSearchEngine
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
* @param multiThreadedHttpConnectionManager
* The
* @link {@link MultiThreadedHttpConnectionManager} that the fulltext search
* engine will use
* @throws FullTextSearchException
* If an error occured
*/
@Autowired
public FullTextSearchEngine(
@Qualifier("multiThreadedHttpConnectionManager")
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager)
throws FullTextSearchException {
Assert.notNull(multiThreadedHttpConnectionManager,
"multiThreadedHttpConnectionManager can not be null");
HttpConnectionManagerParams p = new HttpConnectionManagerParams();
p.setSoTimeout(0);
p.setConnectionTimeout(0);
multiThreadedHttpConnectionManager.setParams(p);
this.httpClient = new HttpClient(multiThreadedHttpConnectionManager);
if (this.httpClient == null) {
throw new FullTextSearchException(
"Can not instanciate http client with multiThreadedHttpConnectionManager : "
+ multiThreadedHttpConnectionManager);
}
}
示例3: loadProxyConfig
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
* Load proxy configuration when proxy config has changed
*/
private void loadProxyConfig(){
connectionManager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setSoTimeout(proxyConfig.getSoTimeout());
params.setConnectionTimeout(proxyConfig.getConnectionTimeout());
params.setMaxTotalConnections(proxyConfig.getMaxTotalConnections());
params.setDefaultMaxConnectionsPerHost(proxyConfig
.getDefaultMaxConnectionsPerHost());
connectionManager.setParams(params);
httpClient = new HttpClient(connectionManager);
configureCallbacks();
}
示例4: connectHTTP
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
*
* Public Section
*
*/
public void connectHTTP(String strUser, String strPass, String strHost, boolean insecure) {
//Connect WebDAV with credentials
hostConfig = new HostConfiguration();
hostConfig.setHost(strHost);
connectionManager = new MultiThreadedHttpConnectionManager();
connectionManagerParams = new HttpConnectionManagerParams();
connectionManagerParams.setMaxConnectionsPerHost(hostConfig, this.intMaxConnections);
connectionManager.setParams(connectionManagerParams);
client = new HttpClient(connectionManager);
creds = new UsernamePasswordCredentials(strUser, strPass);
client.getState().setCredentials(AuthScope.ANY, creds);
client.setHostConfiguration(hostConfig);
if (insecure) {
Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
Protocol.registerProtocol("https", easyhttps);
}
Status.print("WebDav Connection generated");
}
示例5: RobotsTxtParser
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
public RobotsTxtParser(int timeout, int cacheSize) {
robotsTxtCache = ExpiringLRUMap.create(cacheSize);
int timeToWaitForResponse = (int) (timeout * DateUtils.MILLIS_PER_SECOND);
HttpConnectionManagerParams hmcp = new HttpConnectionManagerParams();
hmcp.setSoTimeout(timeToWaitForResponse);
hmcp.setConnectionTimeout(timeToWaitForResponse);
hcm = new MultiThreadedHttpConnectionManager();
hcm.setParams(hmcp);
client = new HttpClient(hcm);
String proxyHost = FWProps.getStringProperty("http.proxyHost");
int proxyPort = FWProps.getIntegerProperty("http.proxyPort");
if (StringUtils.isNotBlank(proxyHost) && proxyPort > 0) {
client.getHostConfiguration().setProxy(proxyHost, proxyPort);
}
}
示例6: initHttpClient
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
protected void initHttpClient() {
if (MockServer.isTestMode()) {
return;
}
HostConfiguration hostConfiguration = new HostConfiguration();
hostConfiguration.setHost(
diamondConfigure.getDomainNameList().get(
this.domainNamePos.get()), diamondConfigure.getPort());
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.closeIdleConnections(diamondConfigure
.getPollingIntervalTime() * 4000);
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setStaleCheckingEnabled(diamondConfigure
.isConnectionStaleCheckingEnabled());
params.setMaxConnectionsPerHost(hostConfiguration,
diamondConfigure.getMaxHostConnections());
params.setMaxTotalConnections(diamondConfigure.getMaxTotalConnections());
params.setConnectionTimeout(diamondConfigure.getConnectionTimeout());
// ���ö���ʱΪ1����,
// [email protected]
params.setSoTimeout(60 * 1000);
connectionManager.setParams(params);
httpClient = new HttpClient(connectionManager);
httpClient.setHostConfiguration(hostConfiguration);
}
示例7: Stubs
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
public Stubs(ConfigurationContext ctx, String bbUrl) throws AxisFault
{
this.ctx = ctx;
this.bbUrl = bbUrl;
/*
* Must use deprecated class of setting up security because the SOAP
* response doesn't include a security header. Using the deprecated
* OutflowConfiguration class we can specify that the security
* header is only for the outgoing SOAP message.
*/
ofc = new OutflowConfiguration();
ofc.setActionItems("UsernameToken Timestamp");
ofc.setUser("session");
ofc.setPasswordType("PasswordText");
final MultiThreadedHttpConnectionManager conMan = new MultiThreadedHttpConnectionManager();
final HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setMaxTotalConnections(1000);
params.setDefaultMaxConnectionsPerHost(100);
params.setSoTimeout(60000);
params.setConnectionTimeout(30000);
conMan.setParams(params);
httpClient = new HttpClient(conMan);
final HttpClientParams clientParams = httpClient.getParams();
clientParams.setAuthenticationPreemptive(false);
clientParams.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
contextWebservice = new ContextWSStub(ctx, PathUtils.filePath(bbUrl, "webapps/ws/services/Context.WS"));
initStub(contextWebservice);
}
示例8: buildClient
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
* Builds an HTTP client with the given settings. Settings are NOT reset to their default values after a client has
* been created.
*
* @return the created client.
*/
public HttpClient buildClient() {
if (httpsProtocolSocketFactory != null) {
Protocol.registerProtocol("https", new Protocol("https", httpsProtocolSocketFactory, 443));
}
HttpClientParams clientParams = new HttpClientParams();
clientParams.setAuthenticationPreemptive(isPreemptiveAuthentication());
clientParams.setContentCharset(getContentCharSet());
clientParams.setParameter(HttpClientParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(
connectionRetryAttempts, false));
HttpConnectionManagerParams connMgrParams = new HttpConnectionManagerParams();
connMgrParams.setConnectionTimeout(getConnectionTimeout());
connMgrParams.setDefaultMaxConnectionsPerHost(getMaxConnectionsPerHost());
connMgrParams.setMaxTotalConnections(getMaxTotalConnections());
connMgrParams.setReceiveBufferSize(getReceiveBufferSize());
connMgrParams.setSendBufferSize(getSendBufferSize());
connMgrParams.setTcpNoDelay(isTcpNoDelay());
MultiThreadedHttpConnectionManager connMgr = new MultiThreadedHttpConnectionManager();
connMgr.setParams(connMgrParams);
HttpClient httpClient = new HttpClient(clientParams, connMgr);
if (proxyHost != null) {
HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setProxy(proxyHost, proxyPort);
httpClient.setHostConfiguration(hostConfig);
if (proxyUsername != null) {
AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort);
UsernamePasswordCredentials proxyCredentials = new UsernamePasswordCredentials(proxyUsername,
proxyPassword);
httpClient.getState().setProxyCredentials(proxyAuthScope, proxyCredentials);
}
}
return httpClient;
}
示例9: setConnectionManagerSettings
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
/**
* Sets <code>HTTPConnectionManagerSettings</code>.
*
* @param connectionManagerSettings The connection manager settings.
*/
public void setConnectionManagerSettings(HTTPConnectionManagerSettings connectionManagerSettings)
{
this.connectionManagerSettings = connectionManagerSettings;
initHttpConnectionManagerParams(connectionManagerSettings);
connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.setParams(connectionParams);
}
示例10: AutoscalerCloudControllerClient
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
private AutoscalerCloudControllerClient() {
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(AS_CC_CLIENT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(AS_CC_CLIENT_MAX_TOTAL_CONNECTIONS);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
try {
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
int port = conf.getInt("autoscaler.cloudController.port", AutoscalerConstants
.CLOUD_CONTROLLER_DEFAULT_PORT);
String hostname = conf.getString("autoscaler.cloudController.hostname", "localhost");
String epr = "https://" + hostname + ":" + port + "/" + AutoscalerConstants.CLOUD_CONTROLLER_SERVICE_SFX;
int cloudControllerClientTimeout = conf.getInt("autoscaler.cloudController.clientTimeout", 180000);
stub = new CloudControllerServiceStub(ctx, epr);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, cloudControllerClientTimeout);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,
cloudControllerClientTimeout);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
.TRUE);
} catch (Exception e) {
log.error("Could not initialize cloud controller client", e);
}
}
示例11: CloudControllerServiceClient
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
private CloudControllerServiceClient(String epr) throws AxisFault {
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(StratosConstants.CLOUD_CONTROLLER_CLIENT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(StratosConstants.CLOUD_CONTROLLER_CLIENT_MAX_TOTAL_CONNECTIONS);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
String ccSocketTimeout = System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_SOCKET_TIMEOUT) == null ?
StratosConstants.DEFAULT_CLIENT_SOCKET_TIMEOUT :
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_SOCKET_TIMEOUT);
String ccConnectionTimeout =
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT) == null ?
StratosConstants.DEFAULT_CLIENT_CONNECTION_TIMEOUT :
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT);
try {
stub = new CloudControllerServiceStub(ctx, epr);
stub._getServiceClient().getOptions()
.setProperty(HTTPConstants.SO_TIMEOUT, Integer.valueOf(ccSocketTimeout));
stub._getServiceClient().getOptions()
.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(ccConnectionTimeout));
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
.TRUE);
} catch (AxisFault axisFault) {
String msg = "Could not initialize cloud controller service client";
log.error(msg, axisFault);
throw new AxisFault(msg, axisFault);
}
}
示例12: AutoscalerServiceClient
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
private AutoscalerServiceClient(String epr) throws AxisFault {
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(StratosConstants.AUTOSCALER_CLIENT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(StratosConstants.AUTOSCALER_CLIENT_MAX_TOTAL_CONNECTIONS);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
String autosclaerSocketTimeout = System.getProperty(StratosConstants.AUTOSCALER_CLIENT_SOCKET_TIMEOUT) == null ?
StratosConstants.DEFAULT_CLIENT_SOCKET_TIMEOUT :
System.getProperty(StratosConstants.AUTOSCALER_CLIENT_SOCKET_TIMEOUT);
String autosclaerConnectionTimeout = System.getProperty(StratosConstants.AUTOSCALER_CLIENT_CONNECTION_TIMEOUT)
== null ? StratosConstants.DEFAULT_CLIENT_CONNECTION_TIMEOUT :
System.getProperty(StratosConstants.AUTOSCALER_CLIENT_CONNECTION_TIMEOUT);
try {
stub = new AutoscalerServiceStub(ctx, epr);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,
Integer.valueOf(autosclaerSocketTimeout));
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,
Integer.valueOf(autosclaerConnectionTimeout));
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
.TRUE);
} catch (AxisFault axisFault) {
String msg = "Could not initialize autoscaler service client";
log.error(msg, axisFault);
throw new AxisFault(msg, axisFault);
}
}
示例13: StratosManagerServiceClient
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
private StratosManagerServiceClient(String epr) throws AxisFault {
MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(StratosConstants.STRATOS_MANAGER_CLIENT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(StratosConstants.STRATOS_MANAGER_CLIENT_MAX_TOTAL_CONNECTIONS);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
String ccSocketTimeout = System.getProperty(StratosConstants.STRATOS_MANAGER_CLIENT_SOCKET_TIMEOUT) == null ?
StratosConstants.DEFAULT_CLIENT_SOCKET_TIMEOUT :
System.getProperty(StratosConstants.STRATOS_MANAGER_CLIENT_SOCKET_TIMEOUT);
String ccConnectionTimeout = System.getProperty(StratosConstants.STRATOS_MANAGER_CLIENT_CONNECTION_TIMEOUT)
== null ?
StratosConstants.DEFAULT_CLIENT_CONNECTION_TIMEOUT :
System.getProperty(StratosConstants.STRATOS_MANAGER_CLIENT_CONNECTION_TIMEOUT);
try {
stub = new StratosManagerServiceStub(ctx, epr);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, Integer.valueOf
(ccSocketTimeout));
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, Integer.valueOf
(ccConnectionTimeout));
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
.TRUE);
} catch (AxisFault axisFault) {
String msg = "Could not initialize stratos manager service client";
log.error(msg, axisFault);
throw new AxisFault(msg, axisFault);
}
}
示例14: UrlInputStreamImpl
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
private UrlInputStreamImpl() {
int timeToWaitForResponse = (int) (DEFAULT_TIMEOUT * DateUtils.MILLIS_PER_SECOND);
HttpConnectionManagerParams hmcp = new HttpConnectionManagerParams();
hmcp.setSoTimeout(timeToWaitForResponse);
hmcp.setConnectionTimeout(timeToWaitForResponse);
hcm = new MultiThreadedHttpConnectionManager();
hcm.setParams(hmcp);
client = new HttpClient(hcm);
String proxyHost = FWProps.getStringProperty("http.proxyHost");
int proxyPort = FWProps.getIntegerProperty("http.proxyPort");
if (StringUtils.isNotBlank(proxyHost) && proxyPort > 0) {
client.getHostConfiguration().setProxy(proxyHost, proxyPort);
}
}
示例15: VisualIndexHandler
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; //導入方法依賴的package包/類
public VisualIndexHandler(String webServiceHost, String collectionName) {
this.webServiceHost = webServiceHost;
this.collectionName = collectionName;
MultiThreadedHttpConnectionManager cm = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setMaxTotalConnections(100);
params.setDefaultMaxConnectionsPerHost(20);
params.setConnectionTimeout(5000);
cm.setParams(params);
this.httpClient = new HttpClient(cm);
}