當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。