本文整理汇总了Java中com.google.api.client.http.HttpIOExceptionHandler类的典型用法代码示例。如果您正苦于以下问题:Java HttpIOExceptionHandler类的具体用法?Java HttpIOExceptionHandler怎么用?Java HttpIOExceptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpIOExceptionHandler类属于com.google.api.client.http包,在下文中一共展示了HttpIOExceptionHandler类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.google.api.client.http.HttpIOExceptionHandler; //导入依赖的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));
}
示例2: makeIoExceptionHandler
import com.google.api.client.http.HttpIOExceptionHandler; //导入依赖的package包/类
private HttpIOExceptionHandler makeIoExceptionHandler(
final Iterable<HttpIOExceptionHandler> ioExceptionHandlers) {
return new HttpIOExceptionHandler() {
@Override
public boolean handleIOException(HttpRequest request, boolean supportsRetry)
throws IOException {
for (HttpIOExceptionHandler handler : ioExceptionHandlers) {
if (handler.handleIOException(request, supportsRetry)) {
return true;
}
}
return false;
}
};
}
示例3: LoggingResponseHandler
import com.google.api.client.http.HttpIOExceptionHandler; //导入依赖的package包/类
/**
* @param delegateResponseHandler The HttpUnsuccessfulResponseHandler to invoke to
* really handle errors.
* @param delegateIOExceptionHandler The HttpIOExceptionResponseHandler to delegate to.
* @param responseCodesToLog The set of response codes to log URLs for.
*/
public LoggingResponseHandler(
HttpUnsuccessfulResponseHandler delegateResponseHandler,
HttpIOExceptionHandler delegateIOExceptionHandler,
Set<Integer> responseCodesToLog) {
this.delegateResponseHandler = delegateResponseHandler;
this.delegateIOExceptionHandler = delegateIOExceptionHandler;
this.responseCodesToLog = ImmutableSet.copyOf(responseCodesToLog);
}