Deprecated AsyncRestTemplate and related types
This commit deprecates `AsyncRestTemplate` and related types (`AsyncClientHttpRequestFactory` etc.) in favor of the Spring 5.0 `WebClient`. Issue: SPR-15294
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,7 +29,9 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.AbstractClientHttpRequest}
|
||||
*/
|
||||
@Deprecated
|
||||
abstract class AbstractAsyncClientHttpRequest implements AsyncClientHttpRequest {
|
||||
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,7 +29,9 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
abstract class AbstractBufferingAsyncClientHttpRequest extends AbstractAsyncClientHttpRequest {
|
||||
|
||||
private ByteArrayOutputStream bufferedOutput = new ByteArrayOutputStream(1024);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -32,7 +32,9 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @see AsyncClientHttpRequestFactory#createAsyncRequest
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ClientRequest}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AsyncClientHttpRequest extends HttpRequest, HttpOutputMessage {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -31,17 +31,19 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.3
|
||||
* @see AsyncClientHttpRequestInterceptor
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AsyncClientHttpRequestExecution {
|
||||
|
||||
/**
|
||||
* Resume the request execution by invoking the next interceptor in the chain
|
||||
* or executing the request to the remote service.
|
||||
* @param request the HTTP request, containing the HTTP method and headers
|
||||
* @param body the body of the request
|
||||
* @return a corresponding future handle
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body) throws IOException;
|
||||
/**
|
||||
* Resume the request execution by invoking the next interceptor in the chain
|
||||
* or executing the request to the remote service.
|
||||
* @param request the HTTP request, containing the HTTP method and headers
|
||||
* @param body the body of the request
|
||||
* @return a corresponding future handle
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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,7 +27,9 @@ import org.springframework.http.HttpMethod;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ClientHttpConnector}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AsyncClientHttpRequestFactory {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.http.client;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.client.support.InterceptingAsyncHttpAccessor;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
@@ -36,8 +35,10 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.3
|
||||
* @see org.springframework.web.client.AsyncRestTemplate
|
||||
* @see InterceptingAsyncHttpAccessor
|
||||
* @see org.springframework.http.client.support.InterceptingAsyncHttpAccessor
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AsyncClientHttpRequestInterceptor {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -49,7 +49,9 @@ import org.springframework.util.concurrent.SuccessCallback;
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @see HttpComponentsClientHttpRequestFactory#createRequest
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
|
||||
|
||||
private final HttpAsyncClient httpClient;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -43,7 +43,9 @@ import org.springframework.util.Assert;
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.0
|
||||
* @see HttpAsyncClient
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public class HttpComponentsAsyncClientHttpRequestFactory extends HttpComponentsClientHttpRequestFactory
|
||||
implements AsyncClientHttpRequestFactory, InitializingBean {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -36,7 +36,9 @@ import org.springframework.util.StreamUtils;
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @see HttpComponentsAsyncClientHttpRequest#executeAsync()
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
final class HttpComponentsAsyncClientHttpResponse extends AbstractClientHttpResponse {
|
||||
|
||||
private final HttpResponse httpResponse;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -34,84 +34,86 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @author Jakub Narloch
|
||||
* @author Rossen Stoyanchev
|
||||
* @see InterceptingAsyncClientHttpRequestFactory
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
class InterceptingAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
|
||||
|
||||
private AsyncClientHttpRequestFactory requestFactory;
|
||||
private AsyncClientHttpRequestFactory requestFactory;
|
||||
|
||||
private List<AsyncClientHttpRequestInterceptor> interceptors;
|
||||
private List<AsyncClientHttpRequestInterceptor> interceptors;
|
||||
|
||||
private URI uri;
|
||||
private URI uri;
|
||||
|
||||
private HttpMethod httpMethod;
|
||||
private HttpMethod httpMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new instance of {@link InterceptingAsyncClientHttpRequest}.
|
||||
*
|
||||
* @param requestFactory the async request factory
|
||||
* @param interceptors the list of interceptors
|
||||
* @param uri the request URI
|
||||
* @param httpMethod the HTTP method
|
||||
*/
|
||||
public InterceptingAsyncClientHttpRequest(AsyncClientHttpRequestFactory requestFactory,
|
||||
List<AsyncClientHttpRequestInterceptor> interceptors, URI uri, HttpMethod httpMethod) {
|
||||
/**
|
||||
* Creates new instance of {@link InterceptingAsyncClientHttpRequest}.
|
||||
*
|
||||
* @param requestFactory the async request factory
|
||||
* @param interceptors the list of interceptors
|
||||
* @param uri the request URI
|
||||
* @param httpMethod the HTTP method
|
||||
*/
|
||||
public InterceptingAsyncClientHttpRequest(AsyncClientHttpRequestFactory requestFactory,
|
||||
List<AsyncClientHttpRequestInterceptor> interceptors, URI uri, HttpMethod httpMethod) {
|
||||
|
||||
this.requestFactory = requestFactory;
|
||||
this.interceptors = interceptors;
|
||||
this.uri = uri;
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
this.requestFactory = requestFactory;
|
||||
this.interceptors = interceptors;
|
||||
this.uri = uri;
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ListenableFuture<ClientHttpResponse> executeInternal(HttpHeaders headers, byte[] body)
|
||||
throws IOException {
|
||||
@Override
|
||||
protected ListenableFuture<ClientHttpResponse> executeInternal(HttpHeaders headers, byte[] body)
|
||||
throws IOException {
|
||||
|
||||
return new AsyncRequestExecution().executeAsync(this, body);
|
||||
}
|
||||
return new AsyncRequestExecution().executeAsync(this, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return httpMethod;
|
||||
}
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return httpMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
||||
private class AsyncRequestExecution implements AsyncClientHttpRequestExecution {
|
||||
private class AsyncRequestExecution implements AsyncClientHttpRequestExecution {
|
||||
|
||||
private Iterator<AsyncClientHttpRequestInterceptor> iterator;
|
||||
private Iterator<AsyncClientHttpRequestInterceptor> iterator;
|
||||
|
||||
public AsyncRequestExecution() {
|
||||
this.iterator = interceptors.iterator();
|
||||
}
|
||||
public AsyncRequestExecution() {
|
||||
this.iterator = interceptors.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body)
|
||||
throws IOException {
|
||||
@Override
|
||||
public ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body)
|
||||
throws IOException {
|
||||
|
||||
if (this.iterator.hasNext()) {
|
||||
AsyncClientHttpRequestInterceptor interceptor = this.iterator.next();
|
||||
return interceptor.intercept(request, body, this);
|
||||
}
|
||||
else {
|
||||
URI theUri = request.getURI();
|
||||
HttpMethod theMethod = request.getMethod();
|
||||
HttpHeaders theHeaders = request.getHeaders();
|
||||
if (this.iterator.hasNext()) {
|
||||
AsyncClientHttpRequestInterceptor interceptor = this.iterator.next();
|
||||
return interceptor.intercept(request, body, this);
|
||||
}
|
||||
else {
|
||||
URI theUri = request.getURI();
|
||||
HttpMethod theMethod = request.getMethod();
|
||||
HttpHeaders theHeaders = request.getHeaders();
|
||||
|
||||
AsyncClientHttpRequest delegate = requestFactory.createAsyncRequest(theUri, theMethod);
|
||||
delegate.getHeaders().putAll(theHeaders);
|
||||
if (body.length > 0) {
|
||||
StreamUtils.copy(body, delegate.getBody());
|
||||
}
|
||||
AsyncClientHttpRequest delegate = requestFactory.createAsyncRequest(theUri, theMethod);
|
||||
delegate.getHeaders().putAll(theHeaders);
|
||||
if (body.length > 0) {
|
||||
StreamUtils.copy(body, delegate.getBody());
|
||||
}
|
||||
|
||||
return delegate.executeAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
return delegate.executeAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,7 +29,9 @@ import org.springframework.http.HttpMethod;
|
||||
* @author Jakub Narloch
|
||||
* @since 4.3
|
||||
* @see InterceptingAsyncClientHttpRequest
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public class InterceptingAsyncClientHttpRequestFactory implements AsyncClientHttpRequestFactory {
|
||||
|
||||
private AsyncClientHttpRequestFactory delegate;
|
||||
|
||||
@@ -50,7 +50,9 @@ import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
* @since 4.1.2
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
|
||||
*/
|
||||
@Deprecated
|
||||
class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements ClientHttpRequest {
|
||||
|
||||
private final Bootstrap bootstrap;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -56,7 +56,9 @@ import org.springframework.util.Assert;
|
||||
* @author Brian Clozel
|
||||
* @author Mark Paluch
|
||||
* @since 4.1.2
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
|
||||
*/
|
||||
@Deprecated
|
||||
public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
|
||||
AsyncClientHttpRequestFactory, InitializingBean, DisposableBean {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -32,7 +32,9 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.1.2
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
|
||||
*/
|
||||
@Deprecated
|
||||
class Netty4ClientHttpResponse extends AbstractClientHttpResponse {
|
||||
|
||||
private final ChannelHandlerContext context;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -39,7 +39,9 @@ import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
* @author Arjen Poutsma
|
||||
* @author Roy Clarkson
|
||||
* @since 4.3
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
class OkHttp3AsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
|
||||
|
||||
private final OkHttpClient client;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Roy Clarkson
|
||||
* @since 4.3
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class OkHttp3ClientHttpRequestFactory
|
||||
implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory, DisposableBean {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -36,7 +36,9 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.0
|
||||
* @see org.springframework.http.client.SimpleClientHttpRequestFactory#createRequest
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
final class SimpleBufferingAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
|
||||
|
||||
private final HttpURLConnection connection;
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @see java.net.HttpURLConnection
|
||||
* @see HttpComponentsClientHttpRequestFactory
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory {
|
||||
|
||||
private static final int DEFAULT_CHUNK_SIZE = 4096;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -37,7 +37,9 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.0
|
||||
* @see org.springframework.http.client.SimpleClientHttpRequestFactory#createRequest
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
final class SimpleStreamingAsyncClientHttpRequest extends AbstractAsyncClientHttpRequest {
|
||||
|
||||
private final HttpURLConnection connection;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -23,14 +23,12 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.AsyncClientHttpRequest;
|
||||
import org.springframework.http.client.AsyncClientHttpRequestFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for {@link org.springframework.web.client.AsyncRestTemplate}
|
||||
* and other HTTP accessing gateway helpers, defining common properties
|
||||
* such as the {@link AsyncClientHttpRequestFactory} to operate on.
|
||||
* such as the {@link org.springframework.http.client.AsyncClientHttpRequestFactory} to operate on.
|
||||
*
|
||||
* <p>Not intended to be used directly. See
|
||||
* {@link org.springframework.web.client.AsyncRestTemplate}.
|
||||
@@ -38,19 +36,21 @@ import org.springframework.util.Assert;
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @see org.springframework.web.client.AsyncRestTemplate
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public class AsyncHttpAccessor {
|
||||
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private AsyncClientHttpRequestFactory asyncRequestFactory;
|
||||
private org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory;
|
||||
|
||||
/**
|
||||
* Set the request factory that this accessor uses for obtaining {@link
|
||||
* org.springframework.http.client.ClientHttpRequest HttpRequests}.
|
||||
*/
|
||||
public void setAsyncRequestFactory(AsyncClientHttpRequestFactory asyncRequestFactory) {
|
||||
public void setAsyncRequestFactory(org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory) {
|
||||
Assert.notNull(asyncRequestFactory, "'asyncRequestFactory' must not be null");
|
||||
this.asyncRequestFactory = asyncRequestFactory;
|
||||
}
|
||||
@@ -59,21 +59,21 @@ public class AsyncHttpAccessor {
|
||||
* Return the request factory that this accessor uses for obtaining {@link
|
||||
* org.springframework.http.client.ClientHttpRequest HttpRequests}.
|
||||
*/
|
||||
public AsyncClientHttpRequestFactory getAsyncRequestFactory() {
|
||||
public org.springframework.http.client.AsyncClientHttpRequestFactory getAsyncRequestFactory() {
|
||||
return this.asyncRequestFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link AsyncClientHttpRequest} via this template's {@link
|
||||
* AsyncClientHttpRequestFactory}.
|
||||
* Create a new {@link org.springframework.http.client.AsyncClientHttpRequest} via this template's
|
||||
* {@link org.springframework.http.client.AsyncClientHttpRequestFactory}.
|
||||
* @param url the URL to connect to
|
||||
* @param method the HTTP method to execute (GET, POST, etc.)
|
||||
* @return the created request
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
protected AsyncClientHttpRequest createAsyncRequest(URI url, HttpMethod method)
|
||||
protected org.springframework.http.client.AsyncClientHttpRequest createAsyncRequest(URI url, HttpMethod method)
|
||||
throws IOException {
|
||||
AsyncClientHttpRequest request = getAsyncRequestFactory().createAsyncRequest(url, method);
|
||||
org.springframework.http.client.AsyncClientHttpRequest request = getAsyncRequestFactory().createAsyncRequest(url, method);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Created asynchronous " + method.name() + " request for \"" + url + "\"");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -19,9 +19,6 @@ package org.springframework.http.client.support;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.client.AsyncClientHttpRequestFactory;
|
||||
import org.springframework.http.client.AsyncClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.InterceptingAsyncClientHttpRequestFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -31,38 +28,40 @@ import org.springframework.util.CollectionUtils;
|
||||
* @author Jakub Narloch
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.3
|
||||
* @deprecated as of Spring 5.0, with no direct replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class InterceptingAsyncHttpAccessor extends AsyncHttpAccessor {
|
||||
|
||||
private List<AsyncClientHttpRequestInterceptor> interceptors =
|
||||
private List<org.springframework.http.client.AsyncClientHttpRequestInterceptor> interceptors =
|
||||
new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* Set the request interceptors that this accessor should use.
|
||||
* @param interceptors the list of interceptors
|
||||
*/
|
||||
public void setInterceptors(List<AsyncClientHttpRequestInterceptor> interceptors) {
|
||||
this.interceptors = interceptors;
|
||||
}
|
||||
/**
|
||||
* Set the request interceptors that this accessor should use.
|
||||
* @param interceptors the list of interceptors
|
||||
*/
|
||||
public void setInterceptors(List<org.springframework.http.client.AsyncClientHttpRequestInterceptor> interceptors) {
|
||||
this.interceptors = interceptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the request interceptor that this accessor uses.
|
||||
*/
|
||||
public List<AsyncClientHttpRequestInterceptor> getInterceptors() {
|
||||
return this.interceptors;
|
||||
}
|
||||
/**
|
||||
* Return the request interceptor that this accessor uses.
|
||||
*/
|
||||
public List<org.springframework.http.client.AsyncClientHttpRequestInterceptor> getInterceptors() {
|
||||
return this.interceptors;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AsyncClientHttpRequestFactory getAsyncRequestFactory() {
|
||||
AsyncClientHttpRequestFactory delegate = super.getAsyncRequestFactory();
|
||||
if (!CollectionUtils.isEmpty(getInterceptors())) {
|
||||
return new InterceptingAsyncClientHttpRequestFactory(delegate, getInterceptors());
|
||||
}
|
||||
else {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public org.springframework.http.client.AsyncClientHttpRequestFactory getAsyncRequestFactory() {
|
||||
org.springframework.http.client.AsyncClientHttpRequestFactory delegate = super.getAsyncRequestFactory();
|
||||
if (!CollectionUtils.isEmpty(getInterceptors())) {
|
||||
return new org.springframework.http.client.InterceptingAsyncClientHttpRequestFactory(delegate, getInterceptors());
|
||||
}
|
||||
else {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -18,10 +18,8 @@ package org.springframework.web.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.http.client.AsyncClientHttpRequest;
|
||||
|
||||
/**
|
||||
* Callback interface for code that operates on an {@link AsyncClientHttpRequest}. Allows
|
||||
* Callback interface for code that operates on an {@link org.springframework.http.client.AsyncClientHttpRequest}. Allows
|
||||
* to manipulate the request headers, and write to the request body.
|
||||
*
|
||||
* <p>Used internally by the {@link AsyncRestTemplate}, but also useful for application code.
|
||||
@@ -29,8 +27,10 @@ import org.springframework.http.client.AsyncClientHttpRequest;
|
||||
* @author Arjen Poutsma
|
||||
* @see org.springframework.web.client.AsyncRestTemplate#execute
|
||||
* @since 4.0
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated
|
||||
public interface AsyncRequestCallback {
|
||||
|
||||
/**
|
||||
@@ -40,6 +40,6 @@ public interface AsyncRequestCallback {
|
||||
* @param request the active HTTP request
|
||||
* @throws java.io.IOException in case of I/O errors
|
||||
*/
|
||||
void doWithRequest(AsyncClientHttpRequest request) throws IOException;
|
||||
void doWithRequest(org.springframework.http.client.AsyncClientHttpRequest request) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -37,7 +37,9 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @since 4.0
|
||||
* @see AsyncRestTemplate
|
||||
* @see RestOperations
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.WebClient}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AsyncRestOperations {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -33,13 +33,10 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.AsyncClientHttpRequest;
|
||||
import org.springframework.http.client.AsyncClientHttpRequestFactory;
|
||||
import org.springframework.http.client.ClientHttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.client.support.InterceptingAsyncHttpAccessor;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
@@ -59,15 +56,17 @@ import org.springframework.web.util.UriTemplateHandler;
|
||||
* <p><strong>Note:</strong> by default {@code AsyncRestTemplate} relies on
|
||||
* standard JDK facilities to establish HTTP connections. You can switch to use
|
||||
* a different HTTP library such as Apache HttpComponents, Netty, and OkHttp by
|
||||
* using a constructor accepting an {@link AsyncClientHttpRequestFactory}.
|
||||
* using a constructor accepting an {@link org.springframework.http.client.AsyncClientHttpRequestFactory}.
|
||||
*
|
||||
* <p>For more information, please refer to the {@link RestTemplate} API documentation.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @see RestTemplate
|
||||
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.WebClient}
|
||||
*/
|
||||
public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements AsyncRestOperations {
|
||||
@Deprecated
|
||||
public class AsyncRestTemplate extends org.springframework.http.client.support.InterceptingAsyncHttpAccessor implements AsyncRestOperations {
|
||||
|
||||
private final RestTemplate syncTemplate;
|
||||
|
||||
@@ -97,14 +96,14 @@ public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code AsyncRestTemplate} using the given
|
||||
* {@link AsyncClientHttpRequestFactory}.
|
||||
* {@link org.springframework.http.client.AsyncClientHttpRequestFactory}.
|
||||
* <p>This constructor will cast the given asynchronous
|
||||
* {@code AsyncClientHttpRequestFactory} to a {@link ClientHttpRequestFactory}. Since
|
||||
* all implementations of {@code ClientHttpRequestFactory} provided in Spring also
|
||||
* implement {@code AsyncClientHttpRequestFactory}, this should not result in a
|
||||
* {@code ClassCastException}.
|
||||
*/
|
||||
public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory) {
|
||||
public AsyncRestTemplate(org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory) {
|
||||
this(asyncRequestFactory, (ClientHttpRequestFactory) asyncRequestFactory);
|
||||
}
|
||||
|
||||
@@ -115,18 +114,18 @@ public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements
|
||||
* @param syncRequestFactory the synchronous request factory
|
||||
*/
|
||||
public AsyncRestTemplate(
|
||||
AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) {
|
||||
org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) {
|
||||
|
||||
this(asyncRequestFactory, new RestTemplate(syncRequestFactory));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@code AsyncRestTemplate} using the given
|
||||
* {@link AsyncClientHttpRequestFactory} and synchronous {@link RestTemplate}.
|
||||
* {@link org.springframework.http.client.AsyncClientHttpRequestFactory} and synchronous {@link RestTemplate}.
|
||||
* @param requestFactory the asynchronous request factory to use
|
||||
* @param restTemplate the synchronous template to use
|
||||
*/
|
||||
public AsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate) {
|
||||
public AsyncRestTemplate(org.springframework.http.client.AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate) {
|
||||
Assert.notNull(restTemplate, "RestTemplate must not be null");
|
||||
this.syncTemplate = restTemplate;
|
||||
setAsyncRequestFactory(requestFactory);
|
||||
@@ -505,7 +504,7 @@ public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements
|
||||
Assert.notNull(url, "'url' must not be null");
|
||||
Assert.notNull(method, "'method' must not be null");
|
||||
try {
|
||||
AsyncClientHttpRequest request = createAsyncRequest(url, method);
|
||||
org.springframework.http.client.AsyncClientHttpRequest request = createAsyncRequest(url, method);
|
||||
if (requestCallback != null) {
|
||||
requestCallback.doWithRequest(request);
|
||||
}
|
||||
@@ -647,7 +646,7 @@ public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWithRequest(final AsyncClientHttpRequest request) throws IOException {
|
||||
public void doWithRequest(final org.springframework.http.client.AsyncClientHttpRequest request) throws IOException {
|
||||
if (this.adaptee != null) {
|
||||
this.adaptee.doWithRequest(new ClientHttpRequest() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user