当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionPool类代码示例

本文整理汇总了Java中com.squareup.okhttp.ConnectionPool的典型用法代码示例。如果您正苦于以下问题:Java ConnectionPool类的具体用法?Java ConnectionPool怎么用?Java ConnectionPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectionPool类属于com.squareup.okhttp包,在下文中一共展示了ConnectionPool类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createClient

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
private OkHttpClient createClient() {
  OkHttpClient client = new OkHttpClient();
  client.setFollowProtocolRedirects(followRedirects);
  if (connectTimeout != DEFAULT_TIMEOUT) {
    client.setConnectTimeout(connectTimeout, SECONDS);
  }
  if (readTimeout != DEFAULT_TIMEOUT) {
    client.setReadTimeout(readTimeout, SECONDS);
  }
  if (allowInsecure) {
    client.setSslSocketFactory(createInsecureSslSocketFactory());
  }
  // If we don't set this reference, there's no way to clean shutdown persistent connections.
  client.setConnectionPool(ConnectionPool.getDefault());
  return client;
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:17,代码来源:Main.java

示例2: createHttpClient

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
/**
 * @return a new http client
 */
private OkHttpClient createHttpClient() {
    OkHttpClient client = new OkHttpClient();
    client.setReadTimeout(connectorOptions.getReadTimeout(), TimeUnit.SECONDS);
    client.setWriteTimeout(connectorOptions.getWriteTimeout(), TimeUnit.SECONDS);
    client.setConnectTimeout(connectorOptions.getConnectTimeout(), TimeUnit.SECONDS);
    client.setFollowRedirects(connectorOptions.isFollowRedirects());
    client.setFollowSslRedirects(connectorOptions.isFollowRedirects());
    client.setProxySelector(ProxySelector.getDefault());
    client.setCookieHandler(CookieHandler.getDefault());
    client.setCertificatePinner(CertificatePinner.DEFAULT);
    client.setAuthenticator(AuthenticatorAdapter.INSTANCE);
    client.setConnectionPool(ConnectionPool.getDefault());
    client.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
    client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
    client.setSocketFactory(SocketFactory.getDefault());
    Internal.instance.setNetwork(client, Network.DEFAULT);

    return client;
}
 
开发者ID:apiman,项目名称:apiman,代码行数:23,代码来源:HttpConnectorFactory.java

示例3: HawkularMetricsClient

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
/**
 * Constructor.
 * @param metricsServer
 */
public HawkularMetricsClient(URL metricsServer) {
    this.serverUrl = metricsServer;
    httpClient = new OkHttpClient();
    httpClient.setReadTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
    httpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT, TimeUnit.SECONDS);
    httpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS);
    httpClient.setFollowRedirects(true);
    httpClient.setFollowSslRedirects(true);
    httpClient.setProxySelector(ProxySelector.getDefault());
    httpClient.setCookieHandler(CookieHandler.getDefault());
    httpClient.setCertificatePinner(CertificatePinner.DEFAULT);
    httpClient.setAuthenticator(AuthenticatorAdapter.INSTANCE);
    httpClient.setConnectionPool(ConnectionPool.getDefault());
    httpClient.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
    httpClient.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
    httpClient.setSocketFactory(SocketFactory.getDefault());
    Internal.instance.setNetwork(httpClient, Network.DEFAULT);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:23,代码来源:HawkularMetricsClient.java

示例4: createDefaultHttpClient

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
private OkHttpClient createDefaultHttpClient() {
    OkHttpClient httpClient = new OkHttpClient();
    httpClient.setConnectTimeout(10, TimeUnit.SECONDS);
    httpClient.setReadTimeout(10, TimeUnit.SECONDS);
    httpClient.setWriteTimeout(20, TimeUnit.SECONDS);
    httpClient.setConnectionPool(new ConnectionPool(20, 2 * 60 * 1000));
    return httpClient;
}
 
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:9,代码来源:EvernoteClientFactory.java

示例5: RouteSelector

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:13,代码来源:RouteSelector.java

示例6: startPollingOnChangeEndpoint

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
public void startPollingOnChangeEndpoint(
    OnServerContentChangeListener onServerContentChangeListener) {
  if (mOnChangePollingEnabled) {
    // polling already enabled
    return;
  }
  mOnChangePollingEnabled = true;
  mOnServerContentChangeListener = onServerContentChangeListener;
  mOnChangePollingClient = new OkHttpClient();
  mOnChangePollingClient
      .setConnectionPool(new ConnectionPool(1, LONG_POLL_KEEP_ALIVE_DURATION_MS))
      .setConnectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
  enqueueOnChangeEndpointLongPolling();
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:15,代码来源:DevServerHelper.java

示例7: okClient

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
OkClient okClient() {
  val client = okHttpClientConfig.create();
  client.setConnectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs));
  client.setRetryOnConnectionFailure(retryOnConnectionFailure);
  client.interceptors().add(new RetryingInterceptor(maxElapsedBackoffMs));
  return new OkClient(client);
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:10,代码来源:RetrofitConfig.java

示例8: okClient

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
OkClient okClient() {
  OkHttpClient client = okHttpClientConfig.create();
  client.setConnectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs));
  client.setRetryOnConnectionFailure(retryOnConnectionFailure);
  return new OkClient(client);
}
 
开发者ID:spinnaker,项目名称:halyard,代码行数:9,代码来源:RetrofitConfig.java

示例9: HttpConnection

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
public HttpConnection(ConnectionPool paramConnectionPool, Connection paramConnection, Socket paramSocket)
  throws IOException
{
  this.pool = paramConnectionPool;
  this.connection = paramConnection;
  this.socket = paramSocket;
  this.source = Okio.buffer(Okio.source(paramSocket));
  this.sink = Okio.buffer(Okio.sink(paramSocket));
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:10,代码来源:HttpConnection.java

示例10: RouteSelector

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool, Dns dns, RouteDatabase routeDatabase) {
    this.address = address;
    this.uri = uri;
    this.proxySelector = proxySelector;
    this.pool = pool;
    this.dns = dns;
    this.routeDatabase = routeDatabase;
    this.postponedRoutes = new LinkedList<Route>();

    resetNextProxy(uri, address.getProxy());
}
 
开发者ID:goodev,项目名称:android-discourse,代码行数:12,代码来源:RouteSelector.java

示例11: provideClient

import com.squareup.okhttp.ConnectionPool; //导入依赖的package包/类
@Provides
@Singleton
Client provideClient(OkHttpClient client) {
    client = new OkHttpClient();
    client.setConnectTimeout(30, TimeUnit.SECONDS); // connect timeout
    client.setReadTimeout(30, TimeUnit.SECONDS);    // socket timeout
    client.setConnectionPool(new ConnectionPool(0, 5 * 60 * 1000));
    return new OkClient(client);
}
 
开发者ID:thanksmister,项目名称:BitcoinBlue,代码行数:10,代码来源:ApiModule.java


注:本文中的com.squareup.okhttp.ConnectionPool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。