Polishing
This commit is contained in:
@@ -40,15 +40,15 @@ import org.springframework.util.concurrent.SuccessCallback;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ClientHttpRequest} implementation that uses Apache HttpComponents HttpClient to
|
* {@link ClientHttpRequest} implementation based on
|
||||||
* execute requests.
|
* Apache HttpComponents HttpAsyncClient.
|
||||||
*
|
*
|
||||||
* <p>Created via the {@link org.springframework.http.client.HttpComponentsClientHttpRequestFactory}.
|
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
|
||||||
*
|
*
|
||||||
* @author Oleg Kalnichevski
|
* @author Oleg Kalnichevski
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory#createRequest
|
* @see HttpComponentsClientHttpRequestFactory#createRequest
|
||||||
*/
|
*/
|
||||||
final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
|
final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
|
||||||
|
|
||||||
@@ -59,10 +59,10 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC
|
|||||||
private final HttpContext httpContext;
|
private final HttpContext httpContext;
|
||||||
|
|
||||||
|
|
||||||
HttpComponentsAsyncClientHttpRequest(HttpAsyncClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
|
HttpComponentsAsyncClientHttpRequest(HttpAsyncClient client, HttpUriRequest request, HttpContext context) {
|
||||||
this.httpClient = httpClient;
|
this.httpClient = client;
|
||||||
this.httpRequest = httpRequest;
|
this.httpRequest = request;
|
||||||
this.httpContext = httpContext;
|
this.httpContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -92,26 +92,23 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC
|
|||||||
entityEnclosingRequest.setEntity(requestEntity);
|
entityEnclosingRequest.setEntity(requestEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
final HttpResponseFutureCallback callback = new HttpResponseFutureCallback(this.httpRequest);
|
HttpResponseFutureCallback callback = new HttpResponseFutureCallback(this.httpRequest);
|
||||||
final Future<HttpResponse> futureResponse =
|
Future<HttpResponse> futureResponse = this.httpClient.execute(this.httpRequest, this.httpContext, callback);
|
||||||
this.httpClient.execute(this.httpRequest, this.httpContext, callback);
|
|
||||||
return new ClientHttpResponseFuture(futureResponse, callback);
|
return new ClientHttpResponseFuture(futureResponse, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class HttpResponseFutureCallback implements FutureCallback<HttpResponse> {
|
private static class HttpResponseFutureCallback implements FutureCallback<HttpResponse> {
|
||||||
|
|
||||||
private final ListenableFutureCallbackRegistry<ClientHttpResponse> callbacks =
|
|
||||||
new ListenableFutureCallbackRegistry<>();
|
|
||||||
|
|
||||||
private final HttpUriRequest httpRequest;
|
private final HttpUriRequest httpRequest;
|
||||||
|
|
||||||
|
private final ListenableFutureCallbackRegistry<ClientHttpResponse> callbacks =
|
||||||
|
new ListenableFutureCallbackRegistry<>();
|
||||||
|
|
||||||
public HttpResponseFutureCallback(HttpUriRequest httpRequest) {
|
public HttpResponseFutureCallback(HttpUriRequest httpRequest) {
|
||||||
this.httpRequest = httpRequest;
|
this.httpRequest = httpRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addCallback(ListenableFutureCallback<? super ClientHttpResponse> callback) {
|
public void addCallback(ListenableFutureCallback<? super ClientHttpResponse> callback) {
|
||||||
this.callbacks.addCallback(callback);
|
this.callbacks.addCallback(callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
import org.springframework.util.StreamUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ClientHttpResponse} implementation that uses
|
* {@link ClientHttpResponse} implementation based on
|
||||||
* Apache HttpComponents HttpClient to execute requests.
|
* Apache HttpComponents HttpAsyncClient.
|
||||||
*
|
*
|
||||||
* <p>Created via the {@link HttpComponentsAsyncClientHttpRequest}.
|
* <p>Created via the {@link HttpComponentsAsyncClientHttpRequest}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link org.springframework.http.client.ClientHttpRequest} implementation that uses
|
* {@link ClientHttpRequest} implementation based on
|
||||||
* Apache HttpComponents HttpClient to execute requests.
|
* Apache HttpComponents HttpClient.
|
||||||
*
|
*
|
||||||
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
|
* <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 Oleg Kalnichevski
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
@@ -57,10 +55,10 @@ final class HttpComponentsClientHttpRequest extends AbstractBufferingClientHttpR
|
|||||||
private final HttpContext httpContext;
|
private final HttpContext httpContext;
|
||||||
|
|
||||||
|
|
||||||
HttpComponentsClientHttpRequest(HttpClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
|
HttpComponentsClientHttpRequest(HttpClient client, HttpUriRequest request, HttpContext context) {
|
||||||
this.httpClient = httpClient;
|
this.httpClient = client;
|
||||||
this.httpRequest = httpRequest;
|
this.httpRequest = request;
|
||||||
this.httpContext = httpContext;
|
this.httpContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
import org.springframework.util.StreamUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link org.springframework.http.client.ClientHttpResponse} implementation that uses
|
* {@link ClientHttpResponse} implementation based on
|
||||||
* Apache HttpComponents HttpClient to execute requests.
|
* Apache HttpComponents HttpClient.
|
||||||
*
|
*
|
||||||
* <p>Created via the {@link HttpComponentsClientHttpRequest}.
|
* <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 Oleg Kalnichevski
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import org.springframework.http.MediaType;
|
|||||||
import org.springframework.http.StreamingHttpOutputMessage;
|
import org.springframework.http.StreamingHttpOutputMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ClientHttpRequest} implementation that uses Apache HttpComponents
|
* {@link ClientHttpRequest} implementation based on
|
||||||
* HttpClient to execute requests.
|
* Apache HttpComponents HttpClient in streaming mode.
|
||||||
*
|
*
|
||||||
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
|
* <p>Created via the {@link HttpComponentsClientHttpRequestFactory}.
|
||||||
*
|
*
|
||||||
@@ -45,7 +45,8 @@ import org.springframework.http.StreamingHttpOutputMessage;
|
|||||||
* @since 4.0
|
* @since 4.0
|
||||||
* @see HttpComponentsClientHttpRequestFactory#createRequest(java.net.URI, org.springframework.http.HttpMethod)
|
* @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;
|
private final HttpClient httpClient;
|
||||||
|
|
||||||
@@ -56,10 +57,10 @@ final class HttpComponentsStreamingClientHttpRequest extends AbstractClientHttpR
|
|||||||
private Body body;
|
private Body body;
|
||||||
|
|
||||||
|
|
||||||
HttpComponentsStreamingClientHttpRequest(HttpClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
|
HttpComponentsStreamingClientHttpRequest(HttpClient client, HttpUriRequest request, HttpContext context) {
|
||||||
this.httpClient = httpClient;
|
this.httpClient = client;
|
||||||
this.httpRequest = httpRequest;
|
this.httpRequest = request;
|
||||||
this.httpContext = httpContext;
|
this.httpContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ import org.springframework.util.concurrent.ListenableFuture;
|
|||||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
import org.springframework.util.concurrent.SettableListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link org.springframework.http.client.ClientHttpRequest} implementation
|
* {@link ClientHttpRequest} implementation based on Netty 4.
|
||||||
* that uses Netty 4 to execute requests.
|
|
||||||
*
|
*
|
||||||
* <p>Created via the {@link Netty4ClientHttpRequestFactory}.
|
* <p>Created via the {@link Netty4ClientHttpRequestFactory}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ import org.springframework.http.HttpHeaders;
|
|||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link org.springframework.http.client.ClientHttpResponse} implementation
|
* {@link ClientHttpResponse} implementation based on Netty 4.
|
||||||
* that uses Netty 4 to parse responses.
|
|
||||||
*
|
*
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @since 4.1.2
|
* @since 4.1.2
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.springframework.util.concurrent.ListenableFuture;
|
|||||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
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}.
|
* <p>Created via the {@link OkHttp3ClientHttpRequestFactory}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.http.HttpHeaders;
|
|||||||
import org.springframework.http.HttpMethod;
|
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}.
|
* <p>Created via the {@link OkHttp3ClientHttpRequestFactory}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.springframework.util.concurrent.ListenableFuture;
|
|||||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
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}.
|
* <p>Created via the {@link OkHttpClientHttpRequestFactory}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.http.HttpHeaders;
|
|||||||
import org.springframework.http.HttpMethod;
|
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}.
|
* <p>Created via the {@link OkHttpClientHttpRequestFactory}.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user