Polishing

This commit is contained in:
Juergen Hoeller 2016-10-31 12:28:44 +01:00
parent 61d7d1621b
commit 7f280a3b17
11 changed files with 39 additions and 47 deletions

View File

@ -40,15 +40,15 @@ import org.springframework.util.concurrent.SuccessCallback;
/**
* {@link ClientHttpRequest} implementation that uses Apache HttpComponents HttpClient to
* execute requests.
* {@link ClientHttpRequest} implementation based on
* Apache HttpComponents HttpAsyncClient.
*
* <p>Created via the {@link org.springframework.http.client.HttpComponentsClientHttpRequestFactory}.
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
*
* @author Oleg Kalnichevski
* @author Arjen Poutsma
* @since 4.0
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory#createRequest
* @see HttpComponentsClientHttpRequestFactory#createRequest
*/
final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
@ -59,10 +59,10 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC
private final HttpContext httpContext;
HttpComponentsAsyncClientHttpRequest(HttpAsyncClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
this.httpClient = httpClient;
this.httpRequest = httpRequest;
this.httpContext = httpContext;
HttpComponentsAsyncClientHttpRequest(HttpAsyncClient client, HttpUriRequest request, HttpContext context) {
this.httpClient = client;
this.httpRequest = request;
this.httpContext = context;
}
@ -92,26 +92,23 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC
entityEnclosingRequest.setEntity(requestEntity);
}
final HttpResponseFutureCallback callback = new HttpResponseFutureCallback(this.httpRequest);
final Future<HttpResponse> futureResponse =
this.httpClient.execute(this.httpRequest, this.httpContext, callback);
HttpResponseFutureCallback callback = new HttpResponseFutureCallback(this.httpRequest);
Future<HttpResponse> futureResponse = this.httpClient.execute(this.httpRequest, this.httpContext, callback);
return new ClientHttpResponseFuture(futureResponse, callback);
}
private static class HttpResponseFutureCallback implements FutureCallback<HttpResponse> {
private final ListenableFutureCallbackRegistry<ClientHttpResponse> callbacks =
new ListenableFutureCallbackRegistry<>();
private final HttpUriRequest httpRequest;
private final ListenableFutureCallbackRegistry<ClientHttpResponse> callbacks =
new ListenableFutureCallbackRegistry<>();
public HttpResponseFutureCallback(HttpUriRequest httpRequest) {
this.httpRequest = httpRequest;
}
public void addCallback(ListenableFutureCallback<? super ClientHttpResponse> callback) {
this.callbacks.addCallback(callback);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,8 +27,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.util.StreamUtils;
/**
* {@link ClientHttpResponse} implementation that uses
* Apache HttpComponents HttpClient to execute requests.
* {@link ClientHttpResponse} implementation based on
* Apache HttpComponents HttpAsyncClient.
*
* <p>Created via the {@link HttpComponentsAsyncClientHttpRequest}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,13 +35,11 @@ import org.springframework.http.HttpMethod;
import org.springframework.util.StringUtils;
/**
* {@link org.springframework.http.client.ClientHttpRequest} implementation that uses
* Apache HttpComponents HttpClient to execute requests.
* {@link ClientHttpRequest} implementation based on
* Apache HttpComponents HttpClient.
*
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
*
* <p><b>NOTE:</b> Requires Apache HttpComponents 4.3 or higher, as of Spring 4.0.
*
* @author Oleg Kalnichevski
* @author Arjen Poutsma
* @author Juergen Hoeller
@ -57,10 +55,10 @@ final class HttpComponentsClientHttpRequest extends AbstractBufferingClientHttpR
private final HttpContext httpContext;
HttpComponentsClientHttpRequest(HttpClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
this.httpClient = httpClient;
this.httpRequest = httpRequest;
this.httpContext = httpContext;
HttpComponentsClientHttpRequest(HttpClient client, HttpUriRequest request, HttpContext context) {
this.httpClient = client;
this.httpRequest = request;
this.httpContext = context;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,13 +29,11 @@ import org.springframework.http.HttpHeaders;
import org.springframework.util.StreamUtils;
/**
* {@link org.springframework.http.client.ClientHttpResponse} implementation that uses
* Apache HttpComponents HttpClient to execute requests.
* {@link ClientHttpResponse} implementation based on
* Apache HttpComponents HttpClient.
*
* <p>Created via the {@link HttpComponentsClientHttpRequest}.
*
* <p><b>NOTE:</b> Requires Apache HttpComponents 4.3 or higher, as of Spring 4.0.
*
* @author Oleg Kalnichevski
* @author Arjen Poutsma
* @since 3.1

View File

@ -36,8 +36,8 @@ import org.springframework.http.MediaType;
import org.springframework.http.StreamingHttpOutputMessage;
/**
* {@link ClientHttpRequest} implementation that uses Apache HttpComponents
* HttpClient to execute requests.
* {@link ClientHttpRequest} implementation based on
* Apache HttpComponents HttpClient in streaming mode.
*
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
*
@ -45,7 +45,8 @@ import org.springframework.http.StreamingHttpOutputMessage;
* @since 4.0
* @see HttpComponentsClientHttpRequestFactory#createRequest(java.net.URI, org.springframework.http.HttpMethod)
*/
final class HttpComponentsStreamingClientHttpRequest extends AbstractClientHttpRequest implements StreamingHttpOutputMessage {
final class HttpComponentsStreamingClientHttpRequest extends AbstractClientHttpRequest
implements StreamingHttpOutputMessage {
private final HttpClient httpClient;
@ -56,10 +57,10 @@ final class HttpComponentsStreamingClientHttpRequest extends AbstractClientHttpR
private Body body;
HttpComponentsStreamingClientHttpRequest(HttpClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
this.httpClient = httpClient;
this.httpRequest = httpRequest;
this.httpContext = httpContext;
HttpComponentsStreamingClientHttpRequest(HttpClient client, HttpUriRequest request, HttpContext context) {
this.httpClient = client;
this.httpRequest = request;
this.httpContext = context;
}

View File

@ -42,8 +42,7 @@ import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.SettableListenableFuture;
/**
* {@link org.springframework.http.client.ClientHttpRequest} implementation
* that uses Netty 4 to execute requests.
* {@link ClientHttpRequest} implementation based on Netty 4.
*
* <p>Created via the {@link Netty4ClientHttpRequestFactory}.
*

View File

@ -28,8 +28,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
/**
* {@link org.springframework.http.client.ClientHttpResponse} implementation
* that uses Netty 4 to parse responses.
* {@link ClientHttpResponse} implementation based on Netty 4.
*
* @author Arjen Poutsma
* @since 4.1.2

View File

@ -31,7 +31,7 @@ import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.SettableListenableFuture;
/**
* {@link AsyncClientHttpRequest} implementation that uses OkHttp 3.x to execute requests.
* {@link AsyncClientHttpRequest} implementation based on OkHttp 3.x.
*
* <p>Created via the {@link OkHttp3ClientHttpRequestFactory}.
*

View File

@ -26,7 +26,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
/**
* {@link ClientHttpRequest} implementation that uses OkHttp 3.x to execute requests.
* {@link ClientHttpRequest} implementation based on OkHttp 3.x.
*
* <p>Created via the {@link OkHttp3ClientHttpRequestFactory}.
*

View File

@ -31,7 +31,7 @@ import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.SettableListenableFuture;
/**
* {@link AsyncClientHttpRequest} implementation that uses OkHttp 2.x to execute requests.
* {@link AsyncClientHttpRequest} implementation based on OkHttp 2.x.
*
* <p>Created via the {@link OkHttpClientHttpRequestFactory}.
*

View File

@ -26,7 +26,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
/**
* {@link ClientHttpRequest} implementation that uses OkHttp 2.x to execute requests.
* {@link ClientHttpRequest} implementation based on OkHttp 2.x.
*
* <p>Created via the {@link OkHttpClientHttpRequestFactory}.
*