org.apache.commons.httpclient.HttpClient.setHttpConnectionManager()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中org.apache.commons.httpclient.HttpClient.setHttpConnectionManager()方法的一些代码示例,展示了HttpClient.setHttpConnectionManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.setHttpConnectionManager()方法的具体详情如下:
包路径:org.apache.commons.httpclient.HttpClient
类名称:HttpClient
方法名:setHttpConnectionManager

HttpClient.setHttpConnectionManager介绍

[英]Assigns the HttpConnectionManager to use with the HttpClient.
[中]分配要与HttpClient一起使用的HttpConnectionManager。

代码示例

代码示例来源:origin: foxinmy/weixin4j

public void setHttpConnectionManager(
    HttpConnectionManager httpConnectionManager) {
  if (httpConnectionManager == null) {
    throw new IllegalArgumentException(
        "'httpConnectionManager' must not be null");
  }
  httpClient.setHttpConnectionManager(httpConnectionManager);
}

代码示例来源:origin: tracee/tracee

@Override
public synchronized void setHttpConnectionManager(HttpConnectionManager httpConnectionManager) {
  delegate.setHttpConnectionManager(httpConnectionManager);
}

代码示例来源:origin: com.foxinmy/weixin4j-base

public void setHttpConnectionManager(
    HttpConnectionManager httpConnectionManager) {
  if (httpConnectionManager == null) {
    throw new IllegalArgumentException(
        "'httpConnectionManager' must not be null");
  }
  httpClient.setHttpConnectionManager(httpConnectionManager);
}

代码示例来源:origin: deas/alfresco

public WebScriptCallerImpl()
{
  httpClient = new HttpClient();
  httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
}

代码示例来源:origin: org.eclipse.mylyn.commons/xmlrpc

private static HttpClient createHttpClient(String userAgent) {
  HttpClient httpClient = new HttpClient();
  httpClient.setHttpConnectionManager(WebUtil.getConnectionManager());
  httpClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
  WebUtil.configureHttpClient(httpClient, userAgent);
  return httpClient;
}

代码示例来源:origin: org.springframework.ws/org.springframework.ws

@Override
protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
  postMethod.setRequestEntity(new ByteArrayRequestEntity(requestBuffer.toByteArray()));
  requestBuffer = null;
  try {
    httpClient.executeMethod(postMethod);
  } catch (IllegalStateException ex) {
    if ("Connection factory has been shutdown.".equals(ex.getMessage())) {
      // The application context has been closed, resulting in a connection factory shutdown and an ISE.
      // Let's create a new connection factory for this connection only.
      connectionManager = new MultiThreadedHttpConnectionManager();
      httpClient.setHttpConnectionManager(connectionManager);
      httpClient.executeMethod(postMethod);
    } else {
      throw ex;
    }
  }
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

@Override
protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
  postMethod.setRequestEntity(new ByteArrayRequestEntity(requestBuffer.toByteArray()));
  requestBuffer = null;
  try {
    httpClient.executeMethod(postMethod);
  } catch (IllegalStateException ex) {
    if ("Connection factory has been shutdown.".equals(ex.getMessage())) {
      // The application context has been closed, resulting in a connection factory shutdown and an ISE.
      // Let's create a new connection factory for this connection only.
      connectionManager = new MultiThreadedHttpConnectionManager();
      httpClient.setHttpConnectionManager(connectionManager);
      httpClient.executeMethod(postMethod);
    } else {
      throw ex;
    }
  }
}

代码示例来源:origin: spring-projects/spring-ws

@Override
protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
  postMethod.setRequestEntity(new ByteArrayRequestEntity(requestBuffer.toByteArray()));
  requestBuffer = null;
  try {
    httpClient.executeMethod(postMethod);
  } catch (IllegalStateException ex) {
    if ("Connection factory has been shutdown.".equals(ex.getMessage())) {
      // The application context has been closed, resulting in a connection factory shutdown and an ISE.
      // Let's create a new connection factory for this connection only.
      connectionManager = new MultiThreadedHttpConnectionManager();
      httpClient.setHttpConnectionManager(connectionManager);
      httpClient.executeMethod(postMethod);
    } else {
      throw ex;
    }
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
  postMethod.setRequestEntity(new ByteArrayRequestEntity(requestBuffer.toByteArray()));
  requestBuffer = null;
  try {
    httpClient.executeMethod(postMethod);
  } catch (IllegalStateException ex) {
    if ("Connection factory has been shutdown.".equals(ex.getMessage())) {
      // The application context has been closed, resulting in a connection factory shutdown and an ISE.
      // Let's create a new connection factory for this connection only.
      connectionManager = new MultiThreadedHttpConnectionManager();
      httpClient.setHttpConnectionManager(connectionManager);
      httpClient.executeMethod(postMethod);
    } else {
      throw ex;
    }
  }
}

代码示例来源:origin: org.alfresco/alfresco-repository

public BitlyUrlShortenerImpl()
{
  httpClient = new HttpClient();
  httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
  HostConfiguration hostConfiguration = new HostConfiguration();
  hostConfiguration.setHost("api-ssl.bitly.com", 443, Protocol.getProtocol("https"));
  httpClient.setHostConfiguration(hostConfiguration);
}

代码示例来源:origin: Alfresco/alfresco-repository

public BitlyUrlShortenerImpl()
{
  httpClient = new HttpClient();
  httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
  HostConfiguration hostConfiguration = new HostConfiguration();
  hostConfiguration.setHost("api-ssl.bitly.com", 443, Protocol.getProtocol("https"));
  httpClient.setHostConfiguration(hostConfiguration);
}

代码示例来源:origin: org.alfresco/alfresco-repository

public HttpClientTransmitterImpl()
{
  protocolMap = new TreeMap<String,Protocol>();
  protocolMap.put(HTTP_SCHEME_NAME, httpProtocol);
  protocolMap.put(HTTPS_SCHEME_NAME, httpsProtocol);
  httpClient = new HttpClient();
  httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
  httpMethodFactory = new StandardHttpMethodFactoryImpl();
  jsonErrorSerializer = new ExceptionJsonSerializer();
  // Create an HTTP Proxy Host if appropriate system properties are set
  httpProxyHost = HttpClientHelper.createProxyHost("http.proxyHost", "http.proxyPort", DEFAULT_HTTP_PORT);
  httpProxyCredentials = HttpClientHelper.createProxyCredentials("http.proxyUser", "http.proxyPassword");
  httpAuthScope = createProxyAuthScope(httpProxyHost);
  // Create an HTTPS Proxy Host if appropriate system properties are set
  httpsProxyHost = HttpClientHelper.createProxyHost("https.proxyHost", "https.proxyPort", DEFAULT_HTTPS_PORT);
  httpsProxyCredentials = HttpClientHelper.createProxyCredentials("https.proxyUser", "https.proxyPassword");
  httpsAuthScope = createProxyAuthScope(httpsProxyHost);
}

代码示例来源:origin: Alfresco/alfresco-repository

public HttpClientTransmitterImpl()
{
  protocolMap = new TreeMap<String,Protocol>();
  protocolMap.put(HTTP_SCHEME_NAME, httpProtocol);
  protocolMap.put(HTTPS_SCHEME_NAME, httpsProtocol);
  httpClient = new HttpClient();
  httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
  httpMethodFactory = new StandardHttpMethodFactoryImpl();
  jsonErrorSerializer = new ExceptionJsonSerializer();
  // Create an HTTP Proxy Host if appropriate system properties are set
  httpProxyHost = HttpClientHelper.createProxyHost("http.proxyHost", "http.proxyPort", DEFAULT_HTTP_PORT);
  httpProxyCredentials = HttpClientHelper.createProxyCredentials("http.proxyUser", "http.proxyPassword");
  httpAuthScope = createProxyAuthScope(httpProxyHost);
  // Create an HTTPS Proxy Host if appropriate system properties are set
  httpsProxyHost = HttpClientHelper.createProxyHost("https.proxyHost", "https.proxyPort", DEFAULT_HTTPS_PORT);
  httpsProxyCredentials = HttpClientHelper.createProxyCredentials("https.proxyUser", "https.proxyPassword");
  httpsAuthScope = createProxyAuthScope(httpsProxyHost);
}

代码示例来源:origin: com.payneteasy.superfly/superfly-client-opt

protected void configureHttpClient() throws IOException, GeneralSecurityException {
  httpClient.getParams().setAuthenticationPreemptive(isAuthenticationPreemptive());
  initCredentials();
  initSocketFactory();
  initProtocolIfNeeded();
  if (httpConnectionManager != null) {
    httpClient.setHttpConnectionManager(httpConnectionManager);
  }
  List<Header> headers = getDefaultHeaders();
  httpClient.getHostConfiguration().getParams().setParameter(HostParams.DEFAULT_HEADERS, headers);
  httpClient.getParams().setParameter(HttpClientParams.USER_AGENT,
      "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/11.04 Chromium/18.0.1025.151 Chrome/18.0.1025.151 Safari/535.19");
  httpClient.getParams().setParameter(HttpClientParams.HTTP_CONTENT_CHARSET, "UTF-8");
  httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
  httpClient.getParams().setConnectionManagerTimeout(connectionManagerTimeout);
  httpClient.getParams().setSoTimeout(soTimeout);
  if (connectionTimeout >= 0) {
    httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
  }
}

代码示例来源:origin: org.apache.camel/camel-http

answer.setHttpConnectionManager(httpConnectionManager);
HttpClientConfigurer configurer = getHttpClientConfigurer();
if (configurer != null) {

代码示例来源:origin: mguessan/davmail

/**
 * Create and set connection pool.
 *
 * @param httpClient httpClient instance
 */
public static void createMultiThreadedHttpConnectionManager(HttpClient httpClient) {
  MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
  connectionManager.getParams().setDefaultMaxConnectionsPerHost(Settings.getIntProperty("davmail.exchange.maxConnections", 100));
  connectionManager.getParams().setConnectionTimeout(Settings.getIntProperty("davmail.exchange.connectionTimeout", 10) * 1000);
  connectionManager.getParams().setSoTimeout(Settings.getIntProperty("davmail.exchange.soTimeout", 120) * 1000);
  synchronized (LOCK) {
    ALL_CONNECTION_MANAGERS.add(connectionManager);
    httpConnectionManagerThread.addConnectionManager(connectionManager);
  }
  httpClient.setHttpConnectionManager(connectionManager);
}

代码示例来源:origin: org.geoserver.extension/wps-core

client.setHttpConnectionManager(manager);

代码示例来源:origin: org.codehaus.xfire/xfire-core

int maxTotalConn  = getIntValue(MAX_TOTAL_CONNECTIONS, DEFAULT_MAX_TOTAL_CONNECTIONS);
conParams.setMaxTotalConnections(maxTotalConn);
client.setHttpConnectionManager(manager);
((HttpChannel) getMessage().getChannel()).setProperty(HTTP_CLIENT, client);

代码示例来源:origin: org.mule.transports/mule-transport-http

protected HttpClient doClientConnect() throws Exception
{
  HttpState state = new HttpState();
  if (getProxyUsername() != null)
  {
    Credentials credentials;
    if (isProxyNtlmAuthentication())
    {
      credentials = new NTCredentials(getProxyUsername(), getProxyPassword(), getProxyHostname(), "");
    }
    else
    {
      credentials = new UsernamePasswordCredentials(getProxyUsername(), getProxyPassword());
    }
    AuthScope authscope = new AuthScope(getProxyHostname(), getProxyPort());
    state.setProxyCredentials(authscope, credentials);
  }
  HttpClient client = new HttpClient();
  client.setState(state);
  client.setHttpConnectionManager(getClientConnectionManager());
  return client;
}

代码示例来源:origin: org.sonatype.nexus/nexus-proxy

public static void applyProxyToHttpClient( HttpClient httpClient, RemoteStorageContext ctx, Logger logger )
  httpClient.setHttpConnectionManager( new CustomMultiThreadedHttpConnectionManager() );

相关文章