當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpRequestInitializer.initialize方法代碼示例

本文整理匯總了Java中com.google.api.client.http.HttpRequestInitializer.initialize方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpRequestInitializer.initialize方法的具體用法?Java HttpRequestInitializer.initialize怎麽用?Java HttpRequestInitializer.initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.api.client.http.HttpRequestInitializer的用法示例。


在下文中一共展示了HttpRequestInitializer.initialize方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setHttpBackoffTimeout

import com.google.api.client.http.HttpRequestInitializer; //導入方法依賴的package包/類
private static HttpRequestInitializer setHttpBackoffTimeout(final HttpRequestInitializer requestInitializer,
                                                            final int connectTimeoutMs, final int readTimeoutMs) {
    return new HttpRequestInitializer() {
        @Override
        public void initialize(HttpRequest httpRequest) throws IOException {
            requestInitializer.initialize(httpRequest);

            // Configure exponential backoff on error
            // https://developers.google.com/api-client-library/java/google-http-java-client/backoff
            ExponentialBackOff backoff = new ExponentialBackOff();
            HttpUnsuccessfulResponseHandler backoffHandler = new HttpBackOffUnsuccessfulResponseHandler(backoff)
                    .setBackOffRequired(HttpBackOffUnsuccessfulResponseHandler.BackOffRequired.ALWAYS);
            httpRequest.setUnsuccessfulResponseHandler(backoffHandler);

            httpRequest.setConnectTimeout(connectTimeoutMs);
            httpRequest.setReadTimeout(readTimeoutMs);
        }
    };
}
 
開發者ID:pinterest,項目名稱:secor,代碼行數:20,代碼來源:GsUploadManager.java

示例2: createHttpTimeout

import com.google.api.client.http.HttpRequestInitializer; //導入方法依賴的package包/類
public final HttpRequestInitializer createHttpTimeout(@NotNull final HttpRequestInitializer requestInitializer, final int value) {
    //As seeon on: https://developers.google.com/apps-script/guides/rest/quickstart/java
    return httpRequest -> {
        requestInitializer.initialize(httpRequest);
        // This allows the API to call (and avoid timing out on)
        // functions that take up to 6 minutes to complete (the maximum
        // allowed script run time), plus a little overhead.
        httpRequest.setReadTimeout(value);
    };
}
 
開發者ID:ViniciusArnhold,項目名稱:ProjectAltaria,代碼行數:11,代碼來源:GoogleClientServiceFactory.java

示例3: setHttpTimeout

import com.google.api.client.http.HttpRequestInitializer; //導入方法依賴的package包/類
private static HttpRequestInitializer setHttpTimeout(final HttpRequestInitializer requestInitializer) {
    return new HttpRequestInitializer() {
        @Override
        public void initialize(HttpRequest httpRequest) throws IOException {
            requestInitializer.initialize(httpRequest);
            httpRequest.setConnectTimeout(20 * 60000);  // 3 minutes connect timeout
            httpRequest.setReadTimeout(20 * 60000);  // 3 minutes read timeout
        }
    };
}
 
開發者ID:axel-halin,項目名稱:Thesis-JHipster,代碼行數:11,代碼來源:SpreadsheetUtils.java

示例4: setHttpTimeout

import com.google.api.client.http.HttpRequestInitializer; //導入方法依賴的package包/類
public static HttpRequestInitializer setHttpTimeout(final HttpRequestInitializer requestInitializer) {
  return request -> {
    requestInitializer.initialize(request);
    request.setConnectTimeout((int) TimeUnit.MINUTES.toMillis(2));
    request.setReadTimeout((int) TimeUnit.MINUTES.toMillis(2));
    request.setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()));
  };
}
 
開發者ID:spinnaker,項目名稱:halyard,代碼行數:9,代碼來源:GoogleCredentials.java

示例5: setHttpTimeout

import com.google.api.client.http.HttpRequestInitializer; //導入方法依賴的package包/類
/**
 * Create a HttpRequestInitializer from the given one, except set
 * the HTTP read timeout to be longer than the default (to allow
 * called scripts time to execute).
 *
 * @param {HttpRequestInitializer} requestInitializer the initializer
 *     to copy and adjust; typically a Credential object.
 * @return an initializer with an extended read timeout.
 */
private static HttpRequestInitializer setHttpTimeout(
        final HttpRequestInitializer requestInitializer) {
    return new HttpRequestInitializer() {
        @Override
        public void initialize(HttpRequest httpRequest) throws IOException {
            requestInitializer.initialize(httpRequest);
            // This allows the API to call (and avoid timing out on)
            // functions that take up to 6 minutes to complete (the maximum
            // allowed script run time), plus a little overhead.
            httpRequest.setReadTimeout(380000);
        }
    };
}
 
開發者ID:kinneerc,項目名稱:giv-planner,代碼行數:23,代碼來源:AppsScriptApi.java

示例6: initialize

import com.google.api.client.http.HttpRequestInitializer; //導入方法依賴的package包/類
@Override
public void initialize(HttpRequest request) throws IOException {
  List<HttpIOExceptionHandler> ioExceptionHandlers = new ArrayList<>();
  List<HttpUnsuccessfulResponseHandler> unsuccessfulResponseHandlers = new ArrayList<>();
  List<HttpExecuteInterceptor> interceptors = new ArrayList<>();
  List<HttpResponseInterceptor> responseInterceptors = new ArrayList<>();
  for (HttpRequestInitializer initializer : initializers) {
    initializer.initialize(request);
    if (request.getIOExceptionHandler() != null) {
      ioExceptionHandlers.add(request.getIOExceptionHandler());
      request.setIOExceptionHandler(null);
    }
    if (request.getUnsuccessfulResponseHandler() != null) {
      unsuccessfulResponseHandlers.add(request.getUnsuccessfulResponseHandler());
      request.setUnsuccessfulResponseHandler(null);
    }
    if (request.getInterceptor() != null) {
      interceptors.add(request.getInterceptor());
      request.setInterceptor(null);
    }
    if (request.getResponseInterceptor() != null) {
      responseInterceptors.add(request.getResponseInterceptor());
      request.setResponseInterceptor(null);
    }
  }
  request.setIOExceptionHandler(
      makeIoExceptionHandler(ioExceptionHandlers));
  request.setUnsuccessfulResponseHandler(
      makeUnsuccessfulResponseHandler(unsuccessfulResponseHandlers));
  request.setInterceptor(
      makeInterceptor(interceptors));
  request.setResponseInterceptor(
      makeResponseInterceptor(responseInterceptors));
}
 
開發者ID:GoogleCloudPlatform,項目名稱:bigdata-interop,代碼行數:35,代碼來源:ChainingHttpRequestInitializer.java

示例7: setHttpTimeout

import com.google.api.client.http.HttpRequestInitializer; //導入方法依賴的package包/類
/**
 * Extend the given HttpRequestInitializer (usually a credentials object)
 * with additional initialize() instructions.
 *
 * @param requestInitializer the initializer to copy and adjust; typically
 *         a credential object.
 * @return an initializer with an extended read timeout.
 */
public static HttpRequestInitializer setHttpTimeout(
        final HttpRequestInitializer requestInitializer) {
    return new HttpRequestInitializer() {
        @Override
        public void initialize(HttpRequest httpRequest)
                throws java.io.IOException {
            requestInitializer.initialize(httpRequest);
            // This allows the API to call (and avoid timing out on)
            // functions that take up to 6 minutes to complete (the maximum
            // allowed script run time), plus a little overhead.
            httpRequest.setReadTimeout(380000);
        }
    };
}
 
開發者ID:ACLay,項目名稱:TATupload,代碼行數:23,代碼來源:NetManager.java


注:本文中的com.google.api.client.http.HttpRequestInitializer.initialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。